develooper Front page | perl.beginners | Postings from December 2002

Feeling a bit 'trapped' by Net::SNMP

Thread Next
From:
Ian Zapczynski
Date:
December 23, 2002 07:41
Subject:
Feeling a bit 'trapped' by Net::SNMP
Message ID:
3E072F49.10103@quarterleaf.com
Hello all,

I hope my question isn't too specific for this list.  I'm still learning 
the basic concepts of SNMP, but I need my current script to send an SNMP 
trap to a host here upon failure.  I am hoping to use Net::SNMP to do 
so, but I think I'm unclear of the syntax due to my current lack of 
understanding of the SNMP protocol.

I have a subroutine which looks like this:

sub sendSNMP {
        my ($event) = @_;
        my ($session, $error) = Net::SNMP->session(
                hostname      => $SNMP_HOST,
                version       => "2",
                timeout       => $SNMP_TIMEOUT
        );
        die "SNMP session to $SNMP_HOST failed - $error" unless $session;
        my (@oid_value) = ( 
".1.3.6.1.4.1.1000.3.$SNMP_SERVERID.$SNMP_JOBID.0.$event",'INTEGER','');
        my $result = $session->snmpv2_trap(
                -varbindlist     => \@oid_value,
        );
        my $error_message = $session->error;
        die "SNMP trap could not be sent to $SNMP_HOST because 
$error_message" unless defined ($result);
        $session->close;
}

I'm quite sure my problem is in not understanding what -varbindlist is 
supposed to be populated with.  I took the above from an example I saw 
on the 'net which I probably misinterpreted.

I am really trying to translate a command line used by snmpnotify to 
communicate with HP Openview to a function using the Net::SNMP module. 
 The only thing I know I must specify is a complete OID as constructed 
above.  But can anyone else tell me exactly what is supposed to be in 
-varbindlist?  The perldoc specifies:

sysUpTime.0 - ('1.3.6.1.2.1.1.3.0', TIMETICKS, $timeticks)

snmpTrapOID.0 - ('1.3.6.1.6.3.1.1.4.1.0', OBJECT_IDENTIFIER, $oid)

I don't understand though if this is meant to be literal or just examples.  

When I run the script with the syntax above or the other attempts I've 
made, $error_message contains "Unknown ASN.1 type [INTEGER]"

A pointer to an RFC would even be appreciated.  For some reason, I can't 
seem to find one which explains what I'm looking for.

Thanks for any and all insight!  


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About