Forum Discussion
banjoooooooooo_
Nimbostratus
Oct 08, 2008Cpu and TMM monitor script
Hmm... I've been trying today to get the same results as the graphs in the TMUI for CPU and TMM usage I'm not sure why I'm getting different results and I noticed the results with my scripts below is ...
Kevin_51676
Nimbostratus
Nov 06, 2008I pipe the output of the script into Cacti for graphing purposes.
Here is what I use for the host cpu script:
$ more f5-bigip-host-cpu.pl
!/usr/bin/perl
Host CPU Monitor Script
This works for 2 Processor Boxes, running 9.3.x
There is a new method for 2 Processor Boxes, running 9.4.x
Usage: f5-bigip-host-cpu.pl
use Net::SNMP qw(:snmp);
my $host = $ARGV[0];
my $snmp_comm = $ARGV[1];
chomp $host;
chomp $snmp_comm;
my $User = '.1.3.6.1.4.1.3375.2.1.7.2.2.1.3.1';
my $Nice = '.1.3.6.1.4.1.3375.2.1.7.2.2.1.4.1';
my $System = '.1.3.6.1.4.1.3375.2.1.7.2.2.1.5.1';
my $IdleCyl = '.1.3.6.1.4.1.3375.2.1.7.2.2.1.6.1';
my $IrqCyl = '.1.3.6.1.4.1.3375.2.1.7.2.2.1.7.1';
my $SoftIrq = '.1.3.6.1.4.1.3375.2.1.7.2.2.1.8.1';
my $IoWait = '.1.3.6.1.4.1.3375.2.1.7.2.2.1.9.1';
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 =>
[$User, $Nice, $System, $IdleCyl, $IrqCyl, $SoftIrq, $IoWait]
);
sleep 10;
my $polled_oids_1 = $session->get_request(
-varbindlist =>
[$User, $Nice, $System, $IdleCyl, $IrqCyl, $SoftIrq, $IoWait]
);
Calculate Delta
$Nice = ($polled_oids_1->{$Nice} - $polled_oids_0->{$Nice});
$System = ($polled_oids_1->{$System} - $polled_oids_0->{$System});
$User = ($polled_oids_1->{$User} - $polled_oids_0->{$User});
$IdleCyl = ($polled_oids_1->{$IdleCyl} - $polled_oids_0->{$IdleCyl});
$IrqCyl = ($polled_oids_1->{$IrqCyl} - $polled_oids_0->{$IrqCyl});
$SoftIrq = ($polled_oids_1->{$SoftIrq} - $polled_oids_0->{$SoftIrq});
$IoWait = ($polled_oids_1->{$IoWait} - $polled_oids_0->{$IoWait});
calculate CPU Utilization
my $cpu = ((($Nice + $User + $System) / ($Nice + $User + $System + $IdleCyl + $I
rqCyl + $SoftIrq + $IoWait)) * 100);
Round to integer
$cpu = int;
print CPU Utilization to stdout for cli validation
print $cpu;
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