diff options
author | Steinar H. Gunderson <sgunderson@bigfoot.com> | 2014-04-06 11:47:34 +0200 |
---|---|---|
committer | Steinar H. Gunderson <sgunderson@bigfoot.com> | 2014-04-06 11:47:34 +0200 |
commit | b7a93569f3616ff9c24a1cf799b6a9389b323d5f (patch) | |
tree | 4e2e0f0469f7a13904b22fb2bff01bca01c90156 | |
parent | 7ea6c6205ef652018f5fdfc54d76d6212dc2b59a (diff) |
Make accesspoints.pl use the new SNMP function. (UNTESTED!).
-rwxr-xr-x | clients/accesspoints.pl | 23 |
1 files changed, 3 insertions, 20 deletions
diff --git a/clients/accesspoints.pl b/clients/accesspoints.pl index d998252..3e62996 100755 --- a/clients/accesspoints.pl +++ b/clients/accesspoints.pl @@ -6,7 +6,6 @@ use DBI; use POSIX; use Time::HiRes; use Net::Ping; -require 'SNMP_Session.pm'; use lib '../include'; use nms; @@ -29,14 +28,14 @@ sub poll_loop { my $community = $cores->{$core}{'community'}; printf "Polling %s (%s)\n", $core, $ip; eval { - my $session = SNMPv2c_Session->open($ip, $community, 161) or die "Couldn't talk to switch"; + my $session = nms::snmp_open_session($ip, $community); $qaps->execute($cores->{$core}{'switch'}); while (my $aps = $qaps->fetchrow_hashref()) { my $sysname = $aps->{'sysname'}; my $blade = $aps->{'blade'}; my $port = $aps->{'port'}; - my $oid = BER::encode_oid(1,3,6,1,2,1,105,1,1,1,9,$blade,$port); # POWER-ETHERNET-MIB...pethPsePortType - my $mode = fetch_snmp($session, $oid); + my $oid = "1.3.6.1.2.1.105.1.1.1.9.$blade.$port"; # POWER-ETHERNET-MIB...pethPsePortType + my $mode = $session->get_request(-varbindlist=>[$oid])->{$oid}; $qpoll->execute($mode, $aps->{'switch'}); printf "%s (%s:%s/%s): %s\n", $sysname, $core, $blade, $port, $mode; } @@ -50,22 +49,6 @@ sub poll_loop { } } -# Kokt fra snmpfetch.pl, vi bør nok lage et lib -sub fetch_snmp { - my ($session, $oid) = @_; - - if ($session->get_request_response($oid)) { - my ($bindings) = $session->decode_get_response ($session->{pdu_buffer}); - my $binding; - while ($bindings ne '') { - ($binding,$bindings) = &decode_sequence ($bindings); - my ($oid,$value) = &decode_by_template ($binding, "%O%@"); - return BER::pretty_print($value); - } - } - die "Couldn't get info from switch"; -} - sub mylog { my $msg = shift; my $time = POSIX::ctime(time); |