From 2a5cbfe5fa9930b3ac72a618e956a14878e20043 Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Thu, 17 Mar 2016 21:42:19 +0000 Subject: NMS: Strip netmask from management ips where relevant --- clients/ping.pl | 2 +- clients/snmpfetchng.pl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/clients/ping.pl b/clients/ping.pl index 47119f1..27aa878 100755 --- a/clients/ping.pl +++ b/clients/ping.pl @@ -15,7 +15,7 @@ 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 ORDER BY random()"); +my $q = $dbh->prepare("SELECT switch,host(ip) as ip,host(secondary_ip) as secondary_ip FROM switches WHERE ip is not null ORDER BY random()"); my $lq = $dbh->prepare("SELECT linknet,addr1,addr2 FROM linknets"); while (1) { diff --git a/clients/snmpfetchng.pl b/clients/snmpfetchng.pl index 68baddd..0a52af0 100755 --- a/clients/snmpfetchng.pl +++ b/clients/snmpfetchng.pl @@ -29,7 +29,7 @@ EOF # Borrowed from snmpfetch.pl our $qswitch = $dbh->prepare(<<"EOF") SELECT - *, + sysname,switch,host(ip) as ip,community, DATE_TRUNC('second', now() - last_updated - poll_frequency) AS overdue FROM switches -- cgit v1.2.3 From 06b47ddd070fb1b46de53c7187acbf27878b8f07 Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Thu, 17 Mar 2016 21:49:58 +0000 Subject: NMS: Throw away good sense to avoid deadlock --- clients/snmpfetchng.pl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/clients/snmpfetchng.pl b/clients/snmpfetchng.pl index 0a52af0..e813499 100755 --- a/clients/snmpfetchng.pl +++ b/clients/snmpfetchng.pl @@ -38,7 +38,6 @@ $qualification ORDER BY overdue DESC LIMIT ? -FOR UPDATE OF switches EOF or die "Couldn't prepare qswitch"; our $qlock = $dbh->prepare("UPDATE switches SET locked='t', last_updated=now() WHERE switch=?") @@ -95,6 +94,7 @@ sub inner_loop $switch{'start'} = time; $qlock->execute($switch{'id'}) or die "Couldn't lock switch"; + $dbh->commit; my $s = SNMP::Session->new(DestHost => $switch{'mgtip'}, Community => $switch{'community'}, UseEnums => 1, @@ -105,7 +105,6 @@ sub inner_loop $outstanding--; } } - $dbh->commit; mylog( "Polling " . @switches . " switches: $poll_todo"); SNMP::MainLoop(5); } -- cgit v1.2.3