[prev in list] [next in list] [prev in thread] [next in thread]
List: net-snmp-users
Subject: Re: OID registration failure - PERL agent
From: rgcole01 () comcast ! net
Date: 2010-05-31 14:00:43
Message-ID: 1605045554.27145701275314443375.JavaMail.root () sz0139a ! westchester ! pa ! mail ! comcast ! net
[Download RAW message or body]
Joao,
Thanks for your help. I added the "use NetSNMP::ASN qw(ASN_OCTET_STR ASN_INTEGER);" \
to my PERL code and it ran fine. However, I had to leave the matching OID in the \
code with a trailing ".0" in the code for the snmpget command to carry the full OID \
(with the trailing .0 ).
Thanks again,
Bob
----- Original Message -----
From: "Joao Ferreira" <jmcferreira@critical-links.com>
To: rgcole01@comcast.net
Cc: "Net-SNMP support" <net-snmp-users@lists.sourceforge.net>
Sent: Monday, May 31, 2010 6:51:14 AM GMT -05:00 US/Canada Eastern
Subject: Re: OID registration failure - PERL agent
On Mon, 2010-05-31 at 11:45 +0100, Joao Ferreira gmail wrote:
> hello Bob
>
> I ran your sub-agent on my system and I only needed to add this at the
> top:
>
> use NetSNMP::ASN qw(ASN_OCTET_STR ASN_INTEGER);
>
> I was getting this in the snmpd logs:
>
> "May 31 07:35:24 xone snmpd[5680]: unknown var value type: 0 "
>
> agent was complaining about not knowing what ASN_OCTET_STRING was :)
>
> you should be ok now....
I also had to remove the trailing ".0" from the code.... like this:
if ($oid == new NetSNMP::OID(".1.3.6.1.4.1.8072.9999.9999.7375.1")) {
$request->setValue(ASN_OCTET_STR, "hello world!");
}
I'm quite sure you really don't want the ".0" in the end of the OID's by
I'm not 100% sure....
U need to have a closer look
Joao
>
> Joao
>
>
> On Sun, 2010-05-30 at 15:39 +0000, rgcole01@comcast.net wrote:
> > I have been having trouble getting the perl mib agent examples going. Does not \
> > seem to register the OID. Below I include a) test-mib.pl, b) snmpd.conf, c) \
> > output from 'snmpd' cmd, d) output from good 'snmpget' and f) failed 'snmpget' on \
> > new OID.
> > Any suggestions?
> >
> > Thanks,
> > Bob Cole
> > ===========================================
> >
> >
> >
> > test-mib.pl:
> > ===========================================
> > use NetSNMP::OID (':all');
> > use NetSNMP::agent (':all');
> >
> >
> > sub myhandler {
> > my ($handler, $registration_info, $request_info, $requests) = @_;
> > my $request;
> >
> > for($request = $requests; $request; $request = $request->next()) {
> > my $oid = $request->getOID();
> > if ($request_info->getMode() == MODE_GET) {
> > # ... generally, you would calculate value from oid
> > if ($oid == new NetSNMP::OID(".1.3.6.1.4.1.8072.9999.9999.7375.1.0")) {
> > $request->setValue(ASN_OCTET_STR, "hello world!");
> > }
> > } elsif ($request_info->getMode() == MODE_GETNEXT) {
> > # ... generally, you would calculate value from oid
> > if ($oid < new NetSNMP::OID(".1.3.6.1.4.1.8072.9999.9999.7375.1.0")) {
> > $request->setOID(".1.3.6.1.4.1.8072.9999.9999.7375.1.0");
> > $request->setValue(ASN_OCTET_STR, "hello world!");
> > }
> > }
> > #elsif ($request_info->getMode() == MODE_SET_RESERVE1) {
> > # if ($oid != new NetSNMP::OID(".1.3.6.1.4.1.8072.9999.9999.7375.1.0")) {
> > # do error checking here
> > # $request->setError($request_info, SNMP_ERR_NOSUCHNAME);
> > # }
> > #} elsif ($request_info->getMode() == MODE_SET_ACTION) {
> > # ... (or use the value)
> > # $value = $request->getValue();
> > #}
> > }
> > }
> >
> >
> > #
> > # Associate the handler with a particular OID tree
> > #
> > my $rootOID = ".1.3.6.1.4.1.8072.9999.9999.7375";
> > my $regoid = new NetSNMP::OID($rootOID);
> > $agent->register("Bob Net-SNMP Agen", $regoid, \&myhandler);
> >
> > print STDERR "Loaded the Bob example perl snmpagent handler\n";
> >
> > ===========================================
> >
> >
> > snmpd.conf:
> > ===========================================
> > ###########################################################################
> > #
> > # snmpd.conf
> > #
> > # - created by the snmpconf configuration program
> > #
> > ###########################################################################
> > # SECTION: System Information Setup
> > #
> > # This section defines some of the information reported in
> > # the "system" mib group in the mibII tree.
> >
> > # syslocation: The [typically physical] location of the system.
> > # Note that setting this value here means that when trying to
> > # perform an snmp SET operation to the sysLocation.0 variable will make
> > # the agent return the "notWritable" error code. IE, including
> > # this token in the snmpd.conf file will disable write access to
> > # the variable.
> > # arguments: location_string
> >
> > syslocation rgc_laptop
> >
> > # syscontact: The contact information for the administrator
> > # Note that setting this value here means that when trying to
> > # perform an snmp SET operation to the sysContact.0 variable will make
> > # the agent return the "notWritable" error code. IE, including
> > # this token in the snmpd.conf file will disable write access to
> > # the variable.
> > # arguments: contact_string
> >
> > syscontact rgcole01@comcast.net
> > # sysservices: The proper value for the sysServices object.
> > # arguments: sysservices_number
> >
> > sysservices 0
> >
> >
> >
> >
> > ###########################################################################
> > # SECTION: Access Control Setup
> > #
> > # This section defines who is allowed to talk to your running
> > # snmp agent.
> >
> > # rwuser: a SNMPv3 read-write user
> > # arguments: user [noauth|auth|priv] [restriction_oid]
> >
> > rwuser localhost noauth
> >
> > # rouser: a SNMPv3 read-only user
> > # arguments: user [noauth|auth|priv] [restriction_oid]
> >
> > rouser localhost noauth
> >
> > # rocommunity: a SNMPv1/SNMPv2c read-only access community name
> > # arguments: community [default|hostname|network/bits] [oid]
> >
> > rocommunity public
> >
> > # rwcommunity: a SNMPv1/SNMPv2c read-write access community name
> > # arguments: community [default|hostname|network/bits] [oid]
> >
> > rwcommunity public
> >
> >
> > #####
> > #
> > # Embedded perl MIB support here
> > #
> > #####
> >
> > #perl print "\nStarting up the snmpd agent!\n\n";
> >
> > perl do "/home/rgc/IETF/DEVELOPMENT/TEST/test-mib.pl";
> >
> >
> > ===========================================
> >
> > 'snmpd -DPERL' output:
> > ===========================================
> > > snmpd -DPERL
> > No log handling enabled - turning on stderr logging
> > registered debug token PERL, 1
> > Loaded the Bob example perl snmpagent handler
> > root@chapman:~/.snmp# NET-SNMP version 5.5
> >
> > root@chapman:~/.snmp# unknown var value type: 0
> >
> > ===========================================
> >
> >
> > 'snmpget -v 2c -c public 127.0.0.1 sysUpTime.0' output:
> > ===========================================
> > > snmpget -v 2c -c public 127.0.0.1 sysUpTime.0
> > DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (1929) 0:00:19.29
> >
> > ===========================================
> >
> >
> > 'snmpget -v 2c -c public 127.0.0.1 .1.3.6.1.4.1.8072.9999.9999.7375.1.0' \
> > output: ===========================================
> > > snmpget -v 2c -c public 127.0.0.1 .1.3.6.1.4.1.8072.9999.9999.7375.1.0
> > NET-SNMP-MIB::netSnmpPlaypen.7375.1.0 = No Such Instance currently exists at this \
> > OID
> > ===========================================
> >
> > ------------------------------------------------------------------------------
> >
> > _______________________________________________
> > Net-snmp-users mailing list
> > Net-snmp-users@lists.sourceforge.net
> > Please see the following page to unsubscribe or change other options:
> > https://lists.sourceforge.net/lists/listinfo/net-snmp-users
------------------------------------------------------------------------------
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic