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