diff options
author | Kristian Lyngstol <kristian@bohemians.org> | 2016-05-23 00:51:00 +0200 |
---|---|---|
committer | Kristian Lyngstol <kristian@bohemians.org> | 2016-05-23 00:51:00 +0200 |
commit | f264fba8cddc51bf16f7797fcf447350fa6e55d0 (patch) | |
tree | 893f1e658911e35e4830eca9b47396dd8b26f39e /collectors | |
parent | e7022dcbe2863f0e682f1200de9ed81ef00e2103 (diff) |
Ping and expose ipv6 as a true equal/superior
Fixes #80
I should go to bed.
Also: Fixes a tiny little issue where we didn't take into account the
nature if the OPing timeout? Or has it changed? Either way, no longer do we
store thousands of ping replies - per second.
Diffstat (limited to 'collectors')
-rwxr-xr-x | collectors/ping.pl | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/collectors/ping.pl b/collectors/ping.pl index 590379c..c50ea87 100755 --- a/collectors/ping.pl +++ b/collectors/ping.pl @@ -15,13 +15,14 @@ my $dbh = nms::db_connect(); $dbh->{AutoCommit} = 0; $dbh->{RaiseError} = 1; -my $q = $dbh->prepare("SELECT switch,host(mgmt_v4_addr) as ip,host(mgmt_v6_addr) as secondary_ip FROM switches WHERE mgmt_v4_addr is not null ORDER BY random()"); +my $q = $dbh->prepare("SELECT switch,host(mgmt_v4_addr) as ip,host(mgmt_v6_addr) as secondary_ip FROM switches WHERE mgmt_v4_addr is not null or mgmt_v6_addr is not null ORDER BY random()"); my $lq = $dbh->prepare("SELECT linknet,addr1,addr2 FROM linknets WHERE addr1 is not null and addr2 is not null"); while (1) { + sleep(0.5); # ping loopbacks my $ping = Net::Oping->new; - $ping->timeout(0.3); + $ping->timeout(0.2); $q->execute; my %ip_to_switch = (); @@ -32,8 +33,10 @@ while (1) { my $switch = $ref->{'switch'}; my $ip = $ref->{'ip'}; - $ping->host_add($ip); - $ip_to_switch{$ip} = $switch; + if (defined($ip) ) { + $ping->host_add($ip); + $ip_to_switch{$ip} = $switch; + } my $secondary_ip = $ref->{'secondary_ip'}; if (defined($secondary_ip)) { @@ -81,7 +84,7 @@ while (1) { $dbh->commit; # ping linknets $ping = Net::Oping->new; - $ping->timeout(0.3); + $ping->timeout(0.2); $lq->execute; my @linknets = (); |