From d637b9f2d67647fd14de3a814192b0d7dd3d332a Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Sat, 19 Mar 2016 17:00:01 +0000 Subject: SNMP fetch: make sure we commit --- clients/snmpfetchng.pl | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) (limited to 'clients/snmpfetchng.pl') diff --git a/clients/snmpfetchng.pl b/clients/snmpfetchng.pl index e813499..394abae 100755 --- a/clients/snmpfetchng.pl +++ b/clients/snmpfetchng.pl @@ -9,7 +9,7 @@ use Data::Dumper; use lib '../include'; use nms; -SNMP::addMibDirs("/tmp/tmp.esQYrkg9MW/v2"); +SNMP::addMibDirs("/srv/tgmanage/mibs"); SNMP::loadModules('SNMPv2-MIB'); SNMP::loadModules('ENTITY-MIB'); SNMP::loadModules('IF-MIB'); @@ -48,8 +48,6 @@ my @switches = (); my $sth = $dbh->prepare("INSERT INTO snmp (switch,data) VALUES((select switch from switches where sysname=?), ?)"); -our $outstanding = 0; - sub mylog { my $msg = shift; @@ -61,17 +59,11 @@ sub mylog sub populate_switches { @switches = (); - my $limit = $nms::config::snmp_max - $outstanding; - if ($limit < 0) { - mylog("Something wrong. Too many outstanding polls going."); - $limit = 1; - } - if ($outstanding > 0) { - mylog("Outstanding polls: $outstanding . Current limit: $limit"); - } + my $limit = $nms::config::snmp_max; + print "called populate\n"; $qswitch->execute($limit) or die "Couldn't get switch"; - + $dbh->commit; while (my $ref = $qswitch->fetchrow_hashref()) { push @switches, { 'sysname' => $ref->{'sysname'}, @@ -87,7 +79,6 @@ sub inner_loop populate_switches(); my $poll_todo = ""; for my $refswitch (@switches) { - $outstanding++; my %switch = %{$refswitch}; $poll_todo .= "$switch{'sysname'} "; @@ -102,7 +93,6 @@ sub inner_loop my $ret = $s->bulkwalk(0, 10, @nms::config::snmp_objects, sub{ callback(\%switch, @_); }); if (!defined($ret)) { mylog("Fudge: ". $s->{'ErrorStr'}); - $outstanding--; } } mylog( "Polling " . @switches . " switches: $poll_todo"); @@ -146,8 +136,7 @@ sub callback{ $qunlock->execute($switch{'id'}) or die "Couldn't unlock switch"; $dbh->commit; - $outstanding--; - mylog( "Polled $switch{'sysname'} in " . (time - $switch{'start'}) . "s. ($outstanding outstanding polls)"); + mylog( "Polled $switch{'sysname'} in " . (time - $switch{'start'}) . "s."); } while (1) { inner_loop(); -- cgit v1.2.3 From a39e47202c108453cac8402b810cc0029c21c1c9 Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Sat, 19 Mar 2016 20:50:02 +0000 Subject: NMS: Intelligent, undocumented active-ports-search --- clients/snmpfetchng.pl | 1 - 1 file changed, 1 deletion(-) (limited to 'clients/snmpfetchng.pl') diff --git a/clients/snmpfetchng.pl b/clients/snmpfetchng.pl index 394abae..bece8ab 100755 --- a/clients/snmpfetchng.pl +++ b/clients/snmpfetchng.pl @@ -60,7 +60,6 @@ sub populate_switches { @switches = (); my $limit = $nms::config::snmp_max; - print "called populate\n"; $qswitch->execute($limit) or die "Couldn't get switch"; $dbh->commit; -- cgit v1.2.3 From 9294a2f2b20a9289a9b5c4a4b72f308de85d8c30 Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Mon, 21 Mar 2016 11:57:33 +0100 Subject: NMS: Fix switch movement and poll timeout --- clients/snmpfetchng.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'clients/snmpfetchng.pl') diff --git a/clients/snmpfetchng.pl b/clients/snmpfetchng.pl index bece8ab..36dd675 100755 --- a/clients/snmpfetchng.pl +++ b/clients/snmpfetchng.pl @@ -95,7 +95,7 @@ sub inner_loop } } mylog( "Polling " . @switches . " switches: $poll_todo"); - SNMP::MainLoop(5); + SNMP::MainLoop(10); } sub callback{ -- cgit v1.2.3 From 10271b0e95a424e191926a945fe785e9cce046c1 Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Tue, 22 Mar 2016 16:05:04 +0100 Subject: NMS: Update schema to FAP --- clients/snmpfetchng.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'clients/snmpfetchng.pl') diff --git a/clients/snmpfetchng.pl b/clients/snmpfetchng.pl index 36dd675..630347d 100755 --- a/clients/snmpfetchng.pl +++ b/clients/snmpfetchng.pl @@ -23,13 +23,13 @@ $dbh->{RaiseError} = 1; my $qualification = <<"EOF"; (last_updated IS NULL OR now() - last_updated > poll_frequency) AND (locked='f' OR now() - last_updated > '15 minutes'::interval) -AND ip is not null +AND mgmt_v4_addr is not null EOF # Borrowed from snmpfetch.pl our $qswitch = $dbh->prepare(<<"EOF") SELECT - sysname,switch,host(ip) as ip,community, + sysname,switch,host(mgmt_v4_addr) as ip,community, DATE_TRUNC('second', now() - last_updated - poll_frequency) AS overdue FROM switches -- cgit v1.2.3 From 28eabb470e5ddfa051ef23be4ca3d89677304331 Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Thu, 24 Mar 2016 00:43:05 +0100 Subject: NMS: Tweak SNMP fetching (getting more data) --- clients/snmpfetchng.pl | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'clients/snmpfetchng.pl') diff --git a/clients/snmpfetchng.pl b/clients/snmpfetchng.pl index 630347d..bbdb00d 100755 --- a/clients/snmpfetchng.pl +++ b/clients/snmpfetchng.pl @@ -9,13 +9,12 @@ use Data::Dumper; use lib '../include'; use nms; +SNMP::initMib(); SNMP::addMibDirs("/srv/tgmanage/mibs"); -SNMP::loadModules('SNMPv2-MIB'); -SNMP::loadModules('ENTITY-MIB'); -SNMP::loadModules('IF-MIB'); -SNMP::loadModules('LLDP-MIB'); -SNMP::loadModules('IP-MIB'); -SNMP::loadModules('IP-FORWARD-MIB'); +SNMP::addMibDirs("/srv/tgmanage/mibs/StandardMibs"); +SNMP::addMibDirs("/srv/tgmanage/mibs/JuniperMibs"); +SNMP::loadModules('ALL'); + our $dbh = nms::db_connect(); $dbh->{AutoCommit} = 0; $dbh->{RaiseError} = 1; -- cgit v1.2.3 From 25409cdc01450279ce56b78ce962956a9990a175 Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Fri, 25 Mar 2016 23:28:12 +0100 Subject: Tweak linknet pings --- clients/snmpfetchng.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'clients/snmpfetchng.pl') diff --git a/clients/snmpfetchng.pl b/clients/snmpfetchng.pl index bbdb00d..2f5e785 100755 --- a/clients/snmpfetchng.pl +++ b/clients/snmpfetchng.pl @@ -10,9 +10,9 @@ use lib '../include'; use nms; SNMP::initMib(); -SNMP::addMibDirs("/srv/tgmanage/mibs"); SNMP::addMibDirs("/srv/tgmanage/mibs/StandardMibs"); SNMP::addMibDirs("/srv/tgmanage/mibs/JuniperMibs"); +SNMP::addMibDirs("/srv/tgmanage/mibs"); SNMP::loadModules('ALL'); our $dbh = nms::db_connect(); -- cgit v1.2.3