Problem with the agent->register

German Silva <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <CAP-FeduiFv9+QR+rwjh_ZjFaDJrAmtjBLCme4Vz7aWHG-oNEow@mail.gmail.com>
I'm trying to extend the net-SNMP agent my platform is CentOS 6.2 and here
the list of packages I have installed:

net-snmp.i686                               1:5.5-37.el6_2.1
 @updates
net-snmp-devel.i686                         1:5.5-37.el6_2.1
 @updates
net-snmp-libs.i686                          1:5.5-37.el6_2.1
 @updates
net-snmp-perl.i686                          1:5.5-37.el6_2.1
 @updates
net-snmp-python.i686                        1:5.5-37.el6_2.1
 @updates
net-snmp-utils.i686                         1:5.5-37.el6_2.1
 @updates
cluster-snmp.i686                           0.16.2-14.el6
base
libvirt-snmp.i686                           0.0.2-3.el6
base
php-snmp.i686                               5.3.3-3.el6_2.6
updates
rsyslog-snmp.i686                           4.6.2-12.el6
 base

Here my /etc/snmp/snmpd.conf relevant portion:

###############################################################################
# Further Information
#
#  See the snmpd.conf manual page, and the output of "snmpd -H".

###############################################################################
# call the perl script to emulate the UPS-MIB


perl  do "/tmp/snmpd_extend.pl"

here my /usr/share/snmp/snmp_perl.pl file:

##
## SNMPD perl initialization file.
##

use NetSNMP::agent;
$agent = new NetSNMP::agent('dont_init_agent' => 1,
    'dont_init_lib' => 1);

and here my /tmp/snmpd_extend.pl script:

#!/usr/bin/perl

use NetSNMP::OID (':all');
use NetSNMP::agent (':all');
use NetSNMP::ASN qw(ASN_OCTET_STR ASN_INTEGER);


sub snmp_extend_handler {

  print debug "entering snmp_extend subroutine....\n";

  my ($handler, $registration_info, $request_info, $requests) = @_;
  my $request;
  my $string_value = "hello world";
  my $integer_value = "8675309";

  for($request = $requests; $request; $request = $request->next()) {
    my $oid = $request->getOID();
    if ($request_info->getMode() == MODE_GET) {
      if ($oid == new NetSNMP::OID(".1.3.6.1.4.1.33.1.0")) {
        $request->setValue(ASN_OCTET_STR, $string_value);
      }
      elsif ($oid == new NetSNMP::OID(".1.3.6.1.4.1.33.1.1")) {
        $request->setValue(ASN_INTEGER, $integer_value);
      }
    } elsif ($request_info->getMode() == MODE_GETNEXT) {
      if ($oid == new NetSNMP::OID(".1.3.6.1.4.1.33.1.0")) {
        $request->setOID(".1.3.6.1.4.1.33.1.1");
        $request->setValue(ASN_INTEGER, $integer_value);
      }
      elsif ($oid < new NetSNMP::OID(".1.3.6.1.4.1.33.1.0")) {
        $request->setOID(".1.3.6.1.4.1.33.1.0");
        $request->setValue(ASN_OCTET_STR, $string_value);
      }
    }
  }
 print debug "leaving the snmp_extend subroutine....\n" ;
}

  open (debug, ">>/tmp/perl_debug.log") or die "can't open the debug file";

  print debug "snmpd_extend starting .....\n";
  print debug " received $0 @ [$regat] [$debugging] [$verbose] \n";

  if (!$agent) { print debug "NO AGENT DEFINED.... \n" ;}

  my $rootOID =".1.3.6.1.4.1.33";
  my $regoid = new NetSNMP::OID($rootOID);
  my $program = $0;

#  my $agent = new NetSNMP::agent();
#  $agent->register($program, $regoid, \&snmp_extend_handler1111);

  print debug "---->AGENT=[$agent]\n";
  if ($agent->register($program, $regoid, \&snmp_extend_handler) == 0)
    {
     print debug "Agent registered successfully...\n" ;
    }
  else
    {
     print debug "AGENT REGISTRATION FAILED !!!!...\n" ;
    }

  $agent->agent_check_and_process(0);

close (debug);
[root@OS-ITNM tmp]#

My problem is that the agent->register is not returning 0 meaning it was
not able to register.

Regards,

German Silva

------------------------------------------------------------------------------
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second 
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev

_______________________________________________
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.