Example output:use strict; my (%result); # Example lines searched for # 4 packets transmitted, 4 packets received, 0% packet loss # round-trip min/avg/max/mdev = 89.483/99.807/119.926/12.344 ms while (<DATA>) { SWITCH: { /transmitted/ && do { # This will "eat up" all "packets"-information $result{$2}=$1 while /(\d+)\s+packets\s+(\S+)/ +g; last SWITCH; }; /round-trip/ && do { # this will find all values seperated by / # and will store them under their key /(\S+)\s*=\s*(\S+)/; @result{split m(/),$1}= split m(/),$2; last SWITCH; }; } } # Your %result-keys depend on the output of ping print $result{'transmitted'}-$result{'received'}," packet(s) lost\n"; print $result{'avg'}," average\n"; print Dumper(\%result); __END__ PING dslreports.com (209.123.109.175) from 10.0.1.1 : 56(84) bytes of +data. 64 bytes from www.dslreports.com (209.123.109.175): icmp_seq=0 ttl=51 +time=89.483 msec 64 bytes from www.dslreports.com (209.123.109.175): icmp_seq=1 ttl=51 +time=119.926 msec 64 bytes from www.dslreports.com (209.123.109.175): icmp_seq=2 ttl=51 +time=89.899 msec 64 bytes from www.dslreports.com (209.123.109.175): icmp_seq=3 ttl=51 +time=99.920 msec --- dslreports.com ping statistics --- 4 packets transmitted, 4 packets received, 0% packet loss round-trip min/avg/max/mdev = 89.483/99.807/119.926/12.344 ms
0 packet(s) lost 99.807 average $VAR1 = { 'received,' => '4', 'avg' => '99.807', 'min' => '89.483', 'mdev' => '12.344', 'max' => '119.926', 'transmitted,' => '4' };
In reply to Re: Re: Re: MRTG script should be easy
by Skeeve
in thread MRTG script should be easy
by jalspach
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |