Here is what I use for the TMM CPU:
$ more f5-bigip-tmm-cpu.pl
!/usr/bin/perl
Usage: f5-bigip-tmm-cpu.pl
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_0 = $session->get_request(
-varbindlist =>
[$tmmTotalCyl, $tmmIdleCyl, $tmmSleepCyl] );
sleep 10;
my $polled_oids_1 = $session->get_request(
-varbindlist =>
[$tmmTotalCyl, $tmmIdleCyl, $tmmSleepCyl] );
calculate CPU Utilization
my $tmm_cpu = (( ($polled_oids_1->{$tmmTotalCyl} - $polled_oids_0->{$tmmTotalCyl
}) -
( ($polled_oids_1->{$tmmIdleCyl} - $polled_oids_0->{$tmmIdleCyl}
) +
($polled_oids_1->{$tmmSleepCyl} - $polled_oids_0->{$tmmSleepCyl}
) ))
/ ($polled_oids_1->{$tmmTotalCyl} - $polled_oids_0->{$tmmTotalCy
l}) ) * 100 ;
Round to integer
$tmm_cpu = int($tmm_cpu + .5);
print CPU Utilization to stdout for cli validation
print $tmm_cpu;