Hi Experts,

 

            I have net-snmp 5.4.2.1 version with my system. When I try to
execute below perl script it is showing error as can't locate object method
" via package "Net::SNMP" (perhaps you forgot to load "Net::SNMP"?)

 

use Net::SNMP;

use RRDs;

 

$database = "/var/www/rrd/cpuload.rrd";

 

#

# Open snmp session and get interface data

#

 

   my ($session, $error) = Net::SNMP->session(

      -hostname  => shift || 'localhost',

      -community => shift || 'public',

      -port      => shift || 161

   );

 

   if (!defined($session)) {

      printf("ERROR: %s.\n", $error);

      exit 1;

   }

 

$oid_ssCpuRawUser    = '.1.3.6.1.4.1.2021.11.50.0';

$oid_ssCpuRawSystem  = '.1.3.6.1.4.1.2021.11.51.0';

$oid_ssCpuRawNice    = '.1.3.6.1.4.1.2021.11.52.0';

$oid_ssCpuRawIdle    = '.1.3.6.1.4.1.2021.11.53.0';

 

 

$database = "/var/www/ipro/rrd/cpuload.rrd";

 

 

$ssCpuRawUser    = $session->get_request($oid_ssCpuRawUser);

$ssCpuRawSystem  = $session->get_request($oid_ssCpuRawSystem);

$ssCpuRawNice    = $session->get_request($oid_ssCpuRawNice);

$ssCpuRawIdle    = $session->get_request($oid_ssCpuRawIdle);

 

$cpurawuser   = $ssCpuRawUser->{$oid_ssCpuRawUser};

$cpurawsystem = $ssCpuRawSystem->{$oid_ssCpuRawSystem};

$cpurawnice   = $ssCpuRawNice->{$oid_ssCpuRawnice};

$cpurawidle   = $ssCpuRawIdle->{$oid_ssCpuRawIdle};

 

printf("CPU Raw User::%d\n",$cpurawuser);

printf("CPU Raw System::%d\n",$cpurawsystem);

printf("CPU Raw Nice::%d\n",$cpurawnice);

printf("CPU Raw idle::%d\n",$cpurawidle);

 

#

# Update the database for cpuload

#

RRDs::update ($database,
"N:".$cpurawuser.":".$cpurawsystem.":".$cpurawnice.":".$cpurawidle);

my $Err = RRDs::error;

 

 

Please let me know how to solve the error coming or how to make the script
workable over net-snmp.

 

Br,

APT

 

 

 

------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
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

Reply via email to