-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_snmp_get.pl
47 lines (44 loc) · 1.77 KB
/
test_snmp_get.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/perl
use strict;
use warnings;
use Carp;
sub POE::Kernel::ASSERT_DEFAULT () { 1 }
#sub POE::Kernel::TRACE_DEFAULT () { 1 }
sub POE::Kernel::TRACE_PROFILE() { 1 }
use POE;
use Net::SNMP;
use Mole::Snmp;
my $debug = 0;
my $i;
Mole::Snmp->spawn();
POE::Session->create(
inline_states => { _start => sub {
my ($kernel, $session) = @_[KERNEL, SESSION];
printf("TEST_SNMP KERNEL: %s\n", $kernel) if $debug;
printf("TEST_SNMP SESSION: %s\n", $session) if $debug;
printf("TEST_SNMP SESSION ID: %s\n", $session->ID) if $debug;
while (<>) {
chomp $_;
my $postback = $session->postback('handler');
$poe_kernel->post("SNMP", "get", $postback, $_, ".1.3.6.1.2.1.1.5.0", "password");
}
},
_stop => sub {
print "Stopping TEST_SNMP\n";
printf("Line Count %s\n", $i);
},
handler=> sub {
my ($kernel, $aryref) = @_[KERNEL, ARG1];
my $varlist = shift @$aryref;
my $mgmtip = shift @$aryref;
my $RO = shift @$aryref;
printf("TEST_SNMP HANDLER COUNT: %s\n", scalar keys (%{$varlist})) if $debug;
foreach my $oid (Net::SNMP::oid_lex_sort(keys(%{$varlist}))) {
$i++;
#printf("%s\t%s\t%s = %s\n", $mgmtip, $RO, $oid, $varlist->{$oid});
}
}
},
);
$poe_kernel->run();
exit 0;