diff options
author | Kristian Lyngstol <kly@kly.no> | 2016-03-16 23:46:27 +0000 |
---|---|---|
committer | Kristian Lyngstol <kly@kly.no> | 2016-03-16 23:46:27 +0000 |
commit | 319112d0ae89d689426441f2d6f353015d66edf9 (patch) | |
tree | 89383bd31411750e0d2178dc9853eedd1ce41c6a /clients/ping.pl | |
parent | 888e40e600f4851e62d213eb0db3122e8d72c5a5 (diff) |
NMS: Ping and uplinks work now
Getting packet loss to localhost now...
Diffstat (limited to 'clients/ping.pl')
-rwxr-xr-x | clients/ping.pl | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/clients/ping.pl b/clients/ping.pl index 93d759f..78fb515 100755 --- a/clients/ping.pl +++ b/clients/ping.pl @@ -5,6 +5,7 @@ use Time::HiRes; use Net::Oping; use strict; use warnings; +use Data::Dumper; use lib '../include'; use nms; @@ -38,17 +39,22 @@ while (1) { } } my $result = $ping->ping(); + my %dropped = %{$ping->get_dropped()}; die $ping->get_error if (!defined($result)); $dbh->do('COPY ping (switch, latency_ms) FROM STDIN'); # date is implicitly now. + my $drops = 0; while (my ($ip, $latency) = each %$result) { my $switch = $ip_to_switch{$ip}; next if (!defined($switch)); + if (!defined($latency)) { + $drops += $dropped{$ip}; + } $latency //= "\\N"; - $latency*=1000; $dbh->pg_putcopydata("$switch\t$latency\n"); } + print "Dropped: $drops\n"; $dbh->pg_putcopyend(); $dbh->do('COPY ping_secondary_ip (switch, latency_ms) FROM STDIN'); # date is implicitly now. |