Debian Codegraph @

perl/SNMP/examples/async2.pl

raw
1 use SNMP;
2
3 $SNMP::auto_init_mib = 0;
4
5 $sess = new SNMP::Session();
6
7 sub poller_handler {
8 if (++$i>500) { die "completed 500 polls\n"; };
9 # VarList is undefined if TIMEOUT occured
10 if (!defined($_[1])) {
11 warn "request timed out[$_[0]->{ErrorStr}]\n";
12 return;
13 }
14 # print "$i) ",$_[1][0]->tag, " = ", $_[1][0]->val, "\n";
15 }
16
17 # $sess->get([[".1.3.6.1.2.1.1.3.0"]], [\&poller_handler, $sess]);
18
19 SNMP::MainLoop(.1,sub {for (1..50) {$sess->get([['.1.3.6.1.2.1.1.3.0']], [\&poller_handler, $sess]);} });