aboutsummaryrefslogtreecommitdiffstats
path: root/collectors/ping.pl
diff options
context:
space:
mode:
Diffstat (limited to 'collectors/ping.pl')
-rwxr-xr-xcollectors/ping.pl13
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 = ();