Hi!
I have no success attempting to extend the SNMP agent with Perl in SLES11 SP3
(using a somewhat older version and tools):
Whatever I try, my agent won't register. I also searched the Internet for
tutorials, example code and explanations, but I failed.
Mainly the reason for writing this is the lack of documentation, inconsitent
documentation, and the inability to get error details.
So first I tried to used the embed Perl variant with
$agent->register($name, $OID, \&handler)
That never succeded, and there is not detailed error message (as it's available
in $@ when usinf the LDAP module, for example).
Also the manual page of NetSNMP::agent says
$agent->register("my_agent_name", ".1.3.6.1.4.1.8072.9999.9999.7375",
\&myhandler);
while some code that is supposed to work uses "new NetSNMP::OID($OID)" instead
of $OID
Further the snmpd.conf manual page says
perl 'do /path/to/file.pl';
while the manual page of NetSNMP::agent says
perl do /path/to/file.pl;
I also found the variant
perl do "/path/to/file.pl";
Thinking about it I feel that
perl "do '/path/to/file.pl';"
probably is correct. So what?
Despite of that questions remaining for the example in NetSNMP::agent and OID
".1.3.6.1.4.1.8072.9999.9999.7375" are:
Does the OID have to "join" a leaf of the OID tree, or do missing intermediate
node come into existance automagically? Can existing parts of the OID tree be
replaced, or can only new branches be created?
So after having no success in running and debugging the embedded Perl, I tried
the AgentX variant. Here also I had no success, probable due to a missing
configuration file. The manual page of NetSNMP::agent is rather vague on that:
$agent->register("my_agent_name", ".1.3.6.1.4.1.8072.9999.9999.7375",
\&myhandler);
seems to imply that some "my_agent_name" configuration file must exist in some
path. The manual page says:
Name of the agent (optional, defaults to "perl") (The snmp library will
read a NAME.conf snmp configuration file based on this argument.)
But where exactly is the file looked for, and what must be in it?
When trying to start my subagent, I get this:
Warning: Failed to connect to the agentx master agent ([NIL]):
Error registering
Argument "netSnmpPlaypen.7375" isn't numeric in subroutine entry at
/usr/lib/perl5/vendor_perl/5.10.0/x86_64-linux-thread-multi/NetSNMP/OID.pm line
152.
(The latter line is)
my $val = constant($constname, @_ ? $_[0] : 0);b
For AgentX the snmpd.conf manual page says the option is named "agentXSocket",
while "snmpd -H" lists it as "agentxsocket".
When I configured "agentx master", I saw a UNIX domain socket opened at
/var/run/agentx/master. Then I still get:
NET-SNMP version 5.4.2.1 AgentX subagent connected
Error registering
Argument "netSnmpPlaypen.7375" isn't numeric in subroutine entry at
/usr/lib/perl5/vendor_perl/5.10.0/x86_64-linux-thread-multi/NetSNMP/OID.pm line
152.
My Perl code modelled after the manual page looks like this (relevant part):
---
my $name = 'test_agent';
my $OID = '.1.3.6.1.4.1.8072.9999.9999.7375';
my $agent = new NetSNMP::agent('Name' => $name, 'AgentX' => 1);
if ($agent->register($name, new NetSNMP::OID($OID), \&handler) == 0) {
my $run = 1;
print $log "Registered $name for OID $OID\n";
while ($run) {
$agent->agent_check_and_process(1)
}
$agent->shutdown();
} else {
print STDERR "Error registering\n";
print $log "Error registering\n";
}
---
Any help appreciated.
Regards,
Ulrich
------------------------------------------------------------------------------
_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users