Here is my scripts:
Code: Select all
#!/usr/bin/perl
#
# Usage: f5-bigip-tmm-cpu.pl <hostname> <snmp community>
#
#
use Net::SNMP qw(:snmp);
my $host = $ARGV[0];
my $snmp_comm = $ARGV[1];
chomp $host;
chomp $snmp_comm;
my $tmmTotalCyl = '.1.3.6.1.4.1.3375.2.1.1.2.1.41.0';
my $tmmIdleCyl = '.1.3.6.1.4.1.3375.2.1.1.2.1.42.0';
my $tmmSleepCyl = '.1.3.6.1.4.1.3375.2.1.1.2.1.43.0';
my ($session, $error) = Net::SNMP->session(
-hostname => $host,
-community => $snmp_comm,
-port => 161,
-version => 'snmpv2c',
-nonblocking => 0
);
if (!defined $session)
{
print "Received no SNMP response from $host\n";
print STDERR "Error: $error\n";
exit -1;
}
# poll CPU oids
my $polled_oids = $session->get_request(
-varbindlist =>
[$tmmTotalCyl, $tmmIdleCyl, $tmmSleepCyl] );
# calculate CPU Utilization
my $tmm_cpu = (( $polled_oids->{$tmmTotalCyl} -
($polled_oids->{$tmmIdleCyl} + $polled_oids->{$tmmSleepCyl}))
/ $polled_oids->{$tmmTotalCyl} ) * 100 ;
# Round to integer
$tmm_cpu = int($tmm_cpu + .5);
# print CPU Utilization to stdout for cli validation
print $tmm_cpu;
Code: Select all
Can't locate Net/SNMP.pm in @INC (@INC contains: /usr/lib/perl5/5.8.5/i386-linux-thread-multi /usr/lib/perl5/5.8.5 /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.4/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.3/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.2/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.1/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl/5.8.4 /usr/lib/perl5/site_perl/5.8.3 /usr/lib/perl5/site_perl/5.8.2 /usr/lib/perl5/site_perl/5.8.1 /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.4/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.3/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.2/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.1/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl/5.8.4 /usr/lib/perl5/vendor_perl/5.8.3 /usr/lib/perl5/vendor_perl/5.8.2 /usr/lib/perl5/vendor_perl/5.8.1 /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl .) at f5-bigip-tmm-cpu.pl line 6.
BEGIN failed--compilation aborted at f5-bigip-tmm-cpu.pl line 6.
Code: Select all
use Net::SNMP qw(:snmp);
I verified my NET-SNMP is installed. What suggestions are there to fix this problem?