diff options
author | Kristian Lyngstol <kristian@bohemians.org> | 2016-04-13 22:54:11 +0200 |
---|---|---|
committer | Kristian Lyngstol <kristian@bohemians.org> | 2016-04-13 22:54:11 +0200 |
commit | 10f841f10b0ec4442a19819ffaf8bc7761657d83 (patch) | |
tree | e486e6bbdc78f7b3f76703da884c891fb1f54c71 | |
parent | 8df01abbeec9fd0de80b89e1f1f893b6e414cd7e (diff) |
ping: Don't break with zero switches
-rw-r--r-- | build/test/nms-collector-test.Dockerfile | 15 | ||||
-rwxr-xr-x | collectors/ping.pl | 8 |
2 files changed, 22 insertions, 1 deletions
diff --git a/build/test/nms-collector-test.Dockerfile b/build/test/nms-collector-test.Dockerfile index f7e7441..04f7a59 100644 --- a/build/test/nms-collector-test.Dockerfile +++ b/build/test/nms-collector-test.Dockerfile @@ -1,4 +1,17 @@ FROM debian:jessie RUN apt-get update && apt-get install -y git-core -RUN git clone https://github.com/tech-server/tgnms +RUN apt-get -y install \ + libdata-dumper-simple-perl \ + libdbd-pg-perl \ + libdbi-perl \ + libnet-oping-perl \ + libsocket-perl \ + libswitch-perl \ + libtimedate-perl \ + perl \ + libjson-xs-perl \ + libjson-perl \ + perl-base \ + perl-modules +RUN git clone https://github.com/tech-server/tgnms /opt/nms CMD /opt/nms/collectors/ping.pl diff --git a/collectors/ping.pl b/collectors/ping.pl index 7902663..b5f7bbf 100755 --- a/collectors/ping.pl +++ b/collectors/ping.pl @@ -26,7 +26,9 @@ while (1) { $q->execute; my %ip_to_switch = (); my %secondary_ip_to_switch = (); + my $affected = 0; while (my $ref = $q->fetchrow_hashref) { + $affected++; my $switch = $ref->{'switch'}; my $ip = $ref->{'ip'}; @@ -39,6 +41,12 @@ while (1) { $secondary_ip_to_switch{$secondary_ip} = $switch; } } + if ($affected == 0) { + print "Nothing to do... sleeping 1 second...\n"; + sleep(1); + next; + } + my $result = $ping->ping(); my %dropped = %{$ping->get_dropped()}; die $ping->get_error if (!defined($result)); |