Forum Discussion
jaskel_40663
Nimbostratus
Feb 05, 2009Odd issues with SNMP and TMM Usage
I'm using this script (which is floating around in the forums):
!/usr/bin/perl
Usage: f5-bigip-tmm-cpu.pl
use Net::SNMP qw(:snmp);
my $host = $ARGV[0];
my $snmp_comm = $AR...
jaskel_40663
Nimbostratus
Feb 09, 2009I borrowed pretty heavily from the original script, but I think I have a version that is a little closer to my reality. I read the docs and found that it needed to have an interval for a delta calculation to get the appropriate. After running this a few times it seems to be pretty much right on with the percentage of TMM CPU utilzation:
!/usr/bin/perl
use Net::SNMP qw(:snmp);
my $host = $ARGV[0];
my $snmp_comm = $ARGV[1];
($time,$idle,$sleep) = &getValue($host,$snmp_comm);
sleep(5);
($time1,$idle1,$sleep1) = &getValue($host,$snmp_comm);
$time_delta = $time1 - $time;
$idle_delta = $idle1 - $idle;
$sleep_delta = $sleep1 - $sleep;
$tmm_usage = (($time_delta - ($idle_delta + $sleep_delta)) / $time_delta )*100;
$tmm_usage = int($tmm_usage + .5);
print "$tmm_usage";
sub getValue {
use Net::SNMP qw(:snmp);
my ($host,$snmp_comm) = (@_);
my $tmmTotalCycles = '.1.3.6.1.4.1.3375.2.1.1.2.1.41.0';
my $tmmIdleCycles = '.1.3.6.1.4.1.3375.2.1.1.2.1.42.0';
my $tmmSleepCycles = '.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 "Recieved no SNMP response from $host\n";
print STDERR "Error: $error\n";
exit -1;
}
my $polled_oids = $session->get_request(
-varbindlist => [$tmmTotalCycles,$tmmIdleCycles,$tmmSleepCycles]
);
my $total_time = $polled_oids->{$tmmTotalCycles};
my $total_idle = $polled_oids->{$tmmIdleCycles};
my $total_sleep = $polled_oids->{$tmmSleepCycles};
return($total_time,$total_idle,$total_sleep);
}
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects