diff options
author | Ole Mathias Heggem <ole@sdok.no> | 2017-04-19 23:16:07 +0200 |
---|---|---|
committer | Ole Mathias Heggem <ole@sdok.no> | 2017-04-19 23:16:07 +0200 |
commit | 7b97188b728c85c498acc8acdce1750c472f2c85 (patch) | |
tree | 12c1436ab7eb97e9434e774671e8ffea134d61db /collectors/ping.pl | |
parent | f70f65f7466a480a45a8260b35887cb7ed36b466 (diff) | |
parent | 7d404abf07d865d253ac2cfc353741e8d4af4867 (diff) |
Merge remote-tracking branch 'refs/remotes/tech-server/master'
Diffstat (limited to 'collectors/ping.pl')
-rwxr-xr-x | collectors/ping.pl | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/collectors/ping.pl b/collectors/ping.pl index 6cb3bb5..408f414 100755 --- a/collectors/ping.pl +++ b/collectors/ping.pl @@ -21,14 +21,6 @@ my $lq = $dbh->prepare("SELECT linknet,addr1,addr2 FROM linknets WHERE addr1 is my $last = time(); my $target = 0.7; -# Hack to avoid starting the collector before graphite is up. -sleep(5); -my $sock = IO::Socket::IP->new( - PeerHost => "$nms::config::graphite_host:$nms::config::graphite_port", - Timeout => 20, - ) or die "Cannot connect - $@"; - - $sock->blocking( 0 ); while (1) { my $now = time(); my $elapsed = ($now - $last); @@ -38,7 +30,7 @@ while (1) { $last = time(); # ping loopbacks my $ping = Net::Oping->new; - $ping->timeout(0.4); + $ping->timeout(0.3); $q->execute; my %ip_to_switch = (); @@ -75,18 +67,16 @@ while (1) { $dbh->do('COPY ping (switch, latency_ms) FROM STDIN'); # date is implicitly now. my $drops = 0; - my $now_graphite = time(); while (my ($ip, $latency) = each %$result) { my $switch = $ip_to_switch{$ip}; - my $sysname = $sw_to_sysname{$switch}; if (!defined($switch)) { next; } + my $sysname = $sw_to_sysname{$switch}; if (!defined($latency)) { $drops += $dropped{$ip}; } - print $sock "ping.$sysname.ipv4 " . ($latency || "NaN") . " $now_graphite\n"; $latency //= "\\N"; $dbh->pg_putcopydata("$switch\t$latency\n"); } @@ -103,7 +93,6 @@ while (1) { next if (!defined($switch)); my $sysname = $sw_to_sysname{$switch}; - print $sock "ping.$sysname.ipv6 " . ($latency || "NaN") . " $now_graphite\n"; $latency //= "\\N"; $dbh->pg_putcopydata("$switch\t$latency\n"); } |