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:

 
-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

 
-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

How about this:

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

Thanx for the gr8 and fast reply...