snmpd help required.
Nitin sharma <[email protected]>
| Newsgroups | gmane.network.net-snmp.user |
|---|---|
| Message-ID | <CAHY4py+UVz=MjKdsRnDkVnHd+XAxUzfbBYG6+EwYBKfpLk8YXw@mail.gmail.com> |
Hi,
I am trying to embed perl in snmpd. The configuration I have done in
snmpd.conf file is
perl do "/path/to/perl.pl"
My perl script code is
use NetSNMP::agent (':all');
use Data::Dumper;
use NetSNMP::OID (':all');
my $value = "hello world";
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.1.0")) {
$request->setValue(ASN_OCTET_STR, $value);
}
} 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.1.0")) {
$request->setOID(".1.3.6.1.4.1.8072.9999.9999.7375.1.0");
$request->setValue(ASN_OCTET_STR, $value);
}
} elsif ($request_info->getMode() == MODE_SET_RESERVE1) {
if ($oid != new
NetSNMP::OID(".1.3.6.1.4.1.8072.9999.9999.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();
}
}
}
open FILE , ">>" , "/tmp/filename.txt";
$agent = new NetSNMP::agent();
my $regat = '.1.3.6.1.4.1.8072.9999.9999';
my $regoid = new NetSNMP::OID($regat);
$ag = $agent->register("my_agent_name", $regoid, \&myhandler);
print FILE Dumper($ag);
if(!ag){
print FILE "\nregisterd";
}else{
print FILE "\nNot registered";
}
close FILE;
But when I do snmpwalk over the OID (.1.3.6.1.4.1.8072.9999.9999) , then it
say there is no more OID left.
I dont know what I am missing ? Please help me to configure the problem.
Thanks
Nitin
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
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