ccc
01-14-2006, 06:39 AM
hi
I've written this perl script:
#!/usr/bin/perl -w
use strict;
use warnings;
my $mail = "postmaster\@domain.net";
my $next_hop = "127.0.0.1"; #...in case nothing matches later
my $good_next_hop = "192.168.0.15";
foreach (`ping 192.168.24.1 -c 4`) {
$next_hop = $1 if /hop:\s+([0-9.]+)/;
}
if ($next_hop ne $good_next_hop) {
`echo "primary firewall is down" | mailx -s "primary firewall is down" $mail`
}
exit;
it should send a mail to the postmaster if the Redirect Host (New nexthop)
will be different than 192.168.0.15
this script will be scheduled every half hour
but I have another big problem
if I do a ping for a first time I get following:
first ping:
# ping 192.168.24.1 -c 4
PING 192.168.24.1 (192.168.24.1) 56(84) bytes of data.
From 192.168.0.10: icmp_seq=1 Redirect Host(New nexthop: 192.168.0.15)
64 bytes from 192.168.24.1: icmp_seq=1 ttl=255 time=37.8 ms
64 bytes from 192.168.24.1: icmp_seq=2 ttl=255 time=33.6 ms
64 bytes from 192.168.24.1: icmp_seq=3 ttl=255 time=35.1 ms
64 bytes from 192.168.24.1: icmp_seq=4 ttl=255 time=37.8 ms
--- 192.168.24.1 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3002ms
rtt min/avg/max/mdev = 33.658/324.144/37.895/1.831 ms
second ping:
# ping 192.168.24.1 -c 4
PING 192.168.24.1 (192.168.24.1) 56(84) bytes of data.
64 bytes from 192.168.24.1: icmp_seq=1 ttl=255 time=34.7 ms
64 bytes from 192.168.24.1: icmp_seq=2 ttl=255 time=36.2 ms
64 bytes from 192.168.24.1: icmp_seq=3 ttl=255 time=37.1 ms
64 bytes from 192.168.24.1: icmp_seq=4 ttl=255 time=34.3 ms
--- 192.168.24.1 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3003ms
rtt min/avg/max/mdev = 34.393/35.641/37.153/1.152 ms
first ping looks for the next hop but following next one next it doesn't.
now I will get many wrong mails.
knows someone any ping command to look every time for the next hop ?
I've written this perl script:
#!/usr/bin/perl -w
use strict;
use warnings;
my $mail = "postmaster\@domain.net";
my $next_hop = "127.0.0.1"; #...in case nothing matches later
my $good_next_hop = "192.168.0.15";
foreach (`ping 192.168.24.1 -c 4`) {
$next_hop = $1 if /hop:\s+([0-9.]+)/;
}
if ($next_hop ne $good_next_hop) {
`echo "primary firewall is down" | mailx -s "primary firewall is down" $mail`
}
exit;
it should send a mail to the postmaster if the Redirect Host (New nexthop)
will be different than 192.168.0.15
this script will be scheduled every half hour
but I have another big problem
if I do a ping for a first time I get following:
first ping:
# ping 192.168.24.1 -c 4
PING 192.168.24.1 (192.168.24.1) 56(84) bytes of data.
From 192.168.0.10: icmp_seq=1 Redirect Host(New nexthop: 192.168.0.15)
64 bytes from 192.168.24.1: icmp_seq=1 ttl=255 time=37.8 ms
64 bytes from 192.168.24.1: icmp_seq=2 ttl=255 time=33.6 ms
64 bytes from 192.168.24.1: icmp_seq=3 ttl=255 time=35.1 ms
64 bytes from 192.168.24.1: icmp_seq=4 ttl=255 time=37.8 ms
--- 192.168.24.1 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3002ms
rtt min/avg/max/mdev = 33.658/324.144/37.895/1.831 ms
second ping:
# ping 192.168.24.1 -c 4
PING 192.168.24.1 (192.168.24.1) 56(84) bytes of data.
64 bytes from 192.168.24.1: icmp_seq=1 ttl=255 time=34.7 ms
64 bytes from 192.168.24.1: icmp_seq=2 ttl=255 time=36.2 ms
64 bytes from 192.168.24.1: icmp_seq=3 ttl=255 time=37.1 ms
64 bytes from 192.168.24.1: icmp_seq=4 ttl=255 time=34.3 ms
--- 192.168.24.1 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3003ms
rtt min/avg/max/mdev = 34.393/35.641/37.153/1.152 ms
first ping looks for the next hop but following next one next it doesn't.
now I will get many wrong mails.
knows someone any ping command to look every time for the next hop ?