b-unit has asked for the wisdom of the Perl Monks concerning the following question:
Do I have a problem with the socket set up or is the code wrong. I would be grateful for any help or suggestions b-unit briancgs@aol.com#!/usr/local/bin/perl use SNMP_Session; use BER; use Socket; $session = SNMPv1_Session->open_trap_session (); while (($trap, $sender, $sender_port) = $session->receive_trap ()) { $DATE = localtime(time); # chomp ($DATE= `/bin/date \'+%a %b %e %T\'` ); print STDERR "n$DATE - " . inet_ntoa($sender) . " - port: $sender_ +port\n"; print_trap ($session, $trap); } sub print_trap ($$) { ($this, $trap) = @_; my($community, $ent, $agent, $gen, $spec, $dt, @bindings) = $this->decode_trap_request ($trap); print " Community:\t".$community."\n"; print " Enterprise:\t".BER::pretty_oid ($ent)."\n"; print " Agent addr:\t".inet_ntoa ($agent)."\n"; print " Generic ID:\t$gen\n"; print " Specific ID:\t$spec\n"; print " Uptime:\t".BER::pretty_uptime_value ($dt)."\n"; $prefix = " bindings:\t"; my ($binding, $oid, $value); while ($bindings ne ''){ print "binds = ".$bindings.\n; ($binding,$bindings) = &decode_sequence ($bindings); ($oid, $value) = decode_by_template ($binding,"%0%@"); print $prefix.BER::pretty_oid ($oid)." => ".pretty_print ($val +ue)."\n"; $prefix = "\t\t"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Unknown Socket error (0+$!)
by tye (Sage) on Jan 26, 2009 at 19:55 UTC | |
by ikegami (Patriarch) on Jan 26, 2009 at 20:33 UTC | |
by tye (Sage) on Jan 26, 2009 at 21:06 UTC |