diff options
author | Kristian Lyngstol <kly@kly.no> | 2016-03-17 06:52:27 +0000 |
---|---|---|
committer | Kristian Lyngstol <kly@kly.no> | 2016-03-17 06:52:27 +0000 |
commit | 344b05a0c708c5b916d7b66de98366bc0bdad639 (patch) | |
tree | 30785d5df90be79603262a06369d32a256e12aba | |
parent | 20afe93187d1ebec66e181b8426b66de94a52c76 (diff) |
ping: Simplify drop-output to unclutter the log.
-rwxr-xr-x | clients/ping.pl | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/clients/ping.pl b/clients/ping.pl index 78fb515..47119f1 100755 --- a/clients/ping.pl +++ b/clients/ping.pl @@ -10,11 +10,12 @@ use Data::Dumper; use lib '../include'; use nms; +$|++; my $dbh = nms::db_connect(); $dbh->{AutoCommit} = 0; $dbh->{RaiseError} = 1; -my $q = $dbh->prepare("SELECT switch,ip,secondary_ip FROM switches WHERE ip is not null"); +my $q = $dbh->prepare("SELECT switch,ip,secondary_ip FROM switches WHERE ip is not null ORDER BY random()"); my $lq = $dbh->prepare("SELECT linknet,addr1,addr2 FROM linknets"); while (1) { @@ -54,7 +55,9 @@ while (1) { $latency //= "\\N"; $dbh->pg_putcopydata("$switch\t$latency\n"); } - print "Dropped: $drops\n"; + if ($drops > 0) { + print "$drops "; + } $dbh->pg_putcopyend(); $dbh->do('COPY ping_secondary_ip (switch, latency_ms) FROM STDIN'); # date is implicitly now. |