Router ping log extract data from it Awk/Sed/grep


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Router ping log extract data from it Awk/Sed/grep
# 1  
Old 09-15-2011
Bug Router ping log extract data from it Awk/Sed/grep

Hi,

I am new to this world..

Using expect i loging to router and checking ping response to my links.
I need to genarate report using this output and that report contains only three file link name, packet loss, latency.

my output of script is like below:

Code:
 
-bash-3.00$ monmw/mwbkp
spawn telnet BHPLCAG2
sh: /usr/local/bin/stty: not found
rancid
Trying 220.224.191.16...
Connected to BHPLCAG2.rdn.ric.net.in.
Escape character is '^]'.
This system is for the use of authorized users only. Individuals using this system without authority, or in excess of their authority, are subject to having all of their activities on this system monitored and recorded by system personnel. In the course of monitoring individuals improperly using this system, or in the course of system maintenance, the activities of authorized users may also be monitored. Anyone using this system expressly consents to such monitoring and is advised that if such monitoring reveals possible evidence of criminal activity, system personnel may provide the evidence of such monitoring to law enforcement officials.
BHPLCAG2A (ttyp0)
rancid
login: Password:
### Indore RTL MW ###
 
--- JUNOS 10.0S10.1 built 2010-11-08 21:12:01 UTC
BHPLCAG2A> ping routing-instance RTL 10.61.96.1 rapid count 25
PING 10.61.96.1 (10.61.96.1): 56 data bytes
!!!!!!!!!!!!!!!!!!!!!!!!!
--- 10.61.96.1 ping statistics ---
25 packets transmitted, 25 packets received, 0% packet loss
round-trip min/avg/max/stddev = 7.466/7.802/11.434/0.762 ms
BHPLCAG2A> spawn telnet RNCHCAG2
sh: /usr/local/bin/stty: not found
rancid
Trying 220.224.139.125...
Connected to RNCHCAG2.rdn.ric.net.in.
Escape character is '^]'.
This system is for the use of authorized users only. Individuals using this system without authority, or in excess of their authority, are subject to having all of their activities on this system monitored and recorded by system personnel. In the course of monitoring individuals improperly using this system, or in the course of system maintenance, the activities of authorized users may also be monitored. Anyone using this system expressly consents to such monitoring and is advised that if such monitoring reveals possible evidence of criminal activity, system personnel may provide the evidence of such monitoring to law enforcement officials.
RNCHCAG2A (ttyp1)
login: Password:
### Patna RTL MW ###
 
--- JUNOS 10.0S10.1 built 2010-11-08 21:12:01 UTC
@RNCHCAG2A> ping routing-instance RTL 10.61.96.5 rapid count 25
PING 10.61.96.5 (10.61.96.5): 56 data bytes
!!!!!!!!!!!!!!!!!!!!!!!!!
--- 10.61.96.5 ping statistics ---
25 packets transmitted, 25 packets received, 0% packet loss
round-trip min/avg/max/stddev = 10.694/10.763/11.047/0.076 ms
RNCHCAG2A> 
-bash-3.00$

kinldy help

using following grep command my output is as below

Code:
 
-bash-3.00$ monmw/mwbkp | /usr/xpg4/bin/grep -e '###' -e 'packet' -e 'Success' -e 'round-trip'
### Indore RTL MW ###
25 packets transmitted, 25 packets received, 0% packet loss
round-trip min/avg/max/stddev = 7.472/7.669/9.284/0.389 ms
### Patna RTL MW ###
25 packets transmitted, 25 packets received, 0% packet loss
round-trip min/avg/max/stddev = 10.677/10.931/15.257/0.885 ms
-bash-3.00$

thanx/rgards
Jignesh

Last edited by pludi; 09-15-2011 at 11:21 AM..
# 2  
Old 09-15-2011
How about this:

Code:
awk '/^###/ {LINK=$2}
/packet loss/ { PL=$(NF-2) }
/^round-trip/ { print LINK OFS PL OFS $(NF-1) }' infile

This User Gave Thanks to Chubler_XL For This Post:
# 3  
Old 09-16-2011
Thanx for the gr8 and fast reply...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed / awk / grep to extract information from log

Hi all, I have a query that runs that outputs data in the following format - 01/09/12 11:43:40,ADMIN,4,77,Application Group Load: Name(TESTED) LoadId(5137-1-0-1XX-15343-15343) File(/dir/dir/File.T03.CI2.RYR.2012009.11433350806.ARD) InputSize(5344) OutputSize(1359) Rows(2) Time(1.9960)... (8 Replies)
Discussion started by: jeffs42885
8 Replies

2. Shell Programming and Scripting

sed or awk, cut, to extract specific data from line

Hi guys, I have been trying to do this, but... no luck so maybe you can help me. I have a line like this: Total Handled, Received, on queue Input Mgs: 140 / 14 => 0 I need to, get the number after the / until the =, to get only 14 . Any help is greatly appreciated. Thanks, (4 Replies)
Discussion started by: ocramas
4 Replies

3. Shell Programming and Scripting

Use grep sed or awk to extract string from log file and put into CSV

I'd like to copy strings from a log file and put them into a CSV. The strings could be on different line numbers, depending on size of log. Example Log File: File = foo.bat Date = 11/11/11 User = Foo Bar Size = 1024 ... CSV should look like: "foo.bat","11/11/11","Foo Bar","1024" (7 Replies)
Discussion started by: chipperuga
7 Replies

4. UNIX for Advanced & Expert Users

bash/grep/awk/sed: How to extract every appearance of text between two specific strings

I have a text wich looks like this: clid=2 cid=6 client_database_id=35 client_nickname=Peter client_type=0|clid=3 cid=22 client_database_id=57 client_nickname=Paul client_type=0|clid=5 cid=22 client_database_id=7 client_nickname=Mary client_type=0|clid=6 cid=22 client_database_id=6... (3 Replies)
Discussion started by: Pioneer1976
3 Replies

5. IP Networking

tcp n00b - can't ping router

please help! I have a sun blade with 2 x nics configured, both on different subnets. The eri0 interface (192.168.0.100) is connected to my router (192.168.0.1), but if i try to ping the router, it times out. any suggestions are welcome - i noticed the 2 mac addresses are the same, i've set... (7 Replies)
Discussion started by: badoshi
7 Replies

6. Shell Programming and Scripting

sed or awk to extract data from Xml file

Hi, I want to get data from Xml file by using sed or awk command. I want to get the following result : mon titre 1;Createur1;Dossier1 mon titre 1;Createur1;Dossier1 and save it in cvs file (fichier.cvs). FROM this Xml file (test.xml): <playlist version="1"> <trackList> <track>... (1 Reply)
Discussion started by: yeclota
1 Replies

7. Shell Programming and Scripting

Big data file - sed/grep/awk?

Morning guys. Another day another question. :rolleyes: I am knocking up a script to pull some data from a file. The problem is the file is very big (up to 1 gig in size), so this solution: for results in `grep "^\ ... works, but takes ages (we're talking minutes) to run. The data is held... (8 Replies)
Discussion started by: dlam
8 Replies

8. UNIX for Advanced & Expert Users

WEB Server Log File Analysis using awk/sed/grep

I'm trying to find a way to show large page sizes (page size in K) from multiple web server log files. Essentially I want to show only rows from a file where a specific column is larger than some value. Has anyone ever done this type of log analysis? If so, a snippet of code would be very... (2 Replies)
Discussion started by: mike_cataldo@ad
2 Replies

9. Solaris

I can't ping my linksys router from Ultra 10

To begin with, I am a Solaris newbie; however, I am very familiar with Linux. Until I began working with Solaris, I didn't realize how much more difficult networking Solaris is than Linux. Before submitting this question, I have tried to fix this problem myself. After days of research, I still... (3 Replies)
Discussion started by: cstovall
3 Replies

10. IP Networking

cannot ping router from sgi irix

anyone available to help me config sgi octane to netscape and networking mac os X? i have three macs and one sgi. setup on a dsl netopia router. all 4 computers can ping each other by addresses and by names. all the macs can ping the router, but the sgi cannot ping the router, "network is... (0 Replies)
Discussion started by: eidde
0 Replies
Login or Register to Ask a Question