Hi,

I am trying to run the following piece of code to emulate the perl agent 
functionality.
However whenever I do a get using the following, I get an error:

Query: /usr/local/bin/snmpget -v 2c -c private 127.0.0.1 
.1.3.6.1.4.1.8072.9999.9999.7375.1.0
Error: Timeout: No Response from 127.0.0.1.

I haven't changed anything in the snmpd.conf file except for the addition of 
the perl "do" statement.

##########################################################################################################
use NetSNMP::agent;

my $agent;
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();
                    #}
            }
        }

$agent = new NetSNMP::agent(
                        'Name' => 'Net-SNMP Agent'
                        );


$agent->register("Net-SNMP Agent", ".1.3.6.1.4.1.8072.9999.9999.7375",
                 \&myhandler);

print STDERR "Loaded the example perl snmpagent handler\n";

$agent->main_loop();


Regards
Tanisha

"If you think you can, or you think you can't...You are Right"   -- Henry Ford


________________________________
"DISCLAIMER: This message is proprietary to Aricent and is intended solely for 
the use of the individual to whom it is addressed. It may contain privileged or 
confidential information and should not be circulated or used for any purpose 
other than for what it is intended. If you have received this message in 
error,please notify the originator immediately. If you are not the intended 
recipient, you are notified that you are strictly prohibited from using, 
copying, altering, or disclosing the contents of this message. Aricent accepts 
no responsibility for loss or damage arising from the use of the information 
transmitted by this email including damage from virus."
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
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

Reply via email to