[mrtg] CPU utilization
Daniel J McDonald
dan.mcdonald at austinenergy.com
Fri Apr 27 14:36:51 CEST 2007
On Fri, 2007-04-27 at 13:32 +0530, Mahesh Bharadwaj wrote:
> CPU on cisco routers specifically cat3750 switch and PIX firewalls..we
> want to monitor it using SNMP ar may be we have a perl program for the
> same...
Ok. that's much more specific.
Cisco has three different mibs that they have supported over the years
for CPU. One or two of these are on each version of code. Assuming a
relatively recent vintage of IOS, you should be able to use this
template which checks for both cpu and cpurev variables and selects the
one that is present. I haven't verified whether this code will work on
ASAs, but it picks up the correct CPU variable on my FWSM's. Note that
older pixes (Version 6.2 and older) do not have process-mib support, so
your mileage may vary on the pixes.
You can apply a template using cfgmaker with the --host-template
directive. This template has a lot of additional configuration items
that I use to make routers2.cgi more descriptive and provide input to
bbmrtg.pl. It also works with CatOS, where the instance is often
different between platforms.
I have a slightly different template for snmp v3 hosts.
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-Cut here+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
$head_lines .= <<ECHO
#.....................................................................
# Router processor utilization.
#
ECHO
;
snmpMIB_to_OID("/usr/share/snmp/mibs/CISCO-SMI-V1SMI.my");
snmpMIB_to_OID("/usr/share/snmp/mibs/CISCO-TC-V1SMI.my");
snmpMIB_to_OID("/usr/share/snmp/mibs/CISCO-PROCESS-MIB-V1SMI.my");
my %cpu;
my (@temp) = snmpwalk($router_connect,'cpmCPUTotal5secRev');
foreach my $tempi(@temp) {
$tempi =~ /(\d+):\d/;
my $instance=$1;
my $target_name=$router_name.".cpu".$instance;
$cpu{$instance}++;
$target_lines .= <<CPU
Target[$target_name]:
cpmCPUTotal5secRev.$instance&cpmCPUTotal1minRev.$instance:
$router_connect
MaxBytes[$target_name]: 100
routers.cgi*ShortDesc[$target_name]: CPU # $instance
routers.cgi*Options[$target_name]: nototal
bb*host[$target_name]: $router_name
bb*svc[$target_name]: cpu
bb*red[$target_name]: 90
bb*yellow[$target_name]: 80
Options[$target_name]: gauge, unknaszero
Directory[$target_name]: $directory_name
WithPeak[$target_name]: wmy
YLegend[$target_name]: % Utilization
ShortLegend[$target_name]: %
Legend1[$target_name]: 5 Second Load
Legend2[$target_name]: 1 Minute Load
LegendI[$target_name]: 5sec :
LegendO[$target_name]: 1min :
Title[$target_name]: $sysname
PageTop[$target_name]: <H1>$sysname Processor Load</H1>
<TABLE>
<TR><TD>System:</TD><TD>$sysname </TD></TR>
<TR><TD>Location:</TD><TD>$syslocation </TD></TR>
</TABLE>
CPU
;
}
my (@temp) = snmpwalk($router_connect,'cpmCPUTotal5sec');
foreach my $tempi(@temp) {
$tempi =~ /(\d+):\d/;
my $instance=$1;
next if exists $cpu{$instance};
my $target_name=$router_name.".cpu".$instance;
$cpu{$instance}++;
$target_lines .= <<CPUOLD
Target[$target_name]:
cpmCPUTotal5sec.$instance&cpmCPUTotal1min.$instance:$router_connect
MaxBytes[$target_name]: 100
routers.cgi*ShortDesc[$target_name]: CPU # $instance
routers.cgi*Options[$target_name]: nototal
bb*host[$target_name]: $router_name
bb*svc[$target_name]: cpu
bb*red[$target_name]: 90
bb*yellow[$target_name]: 80
Options[$target_name]: gauge, unknaszero
Directory[$target_name]: $directory_name
WithPeak[$target_name]: wmy
YLegend[$target_name]: % Utilization
ShortLegend[$target_name]: %
Legend1[$target_name]: 5 Second Load
Legend2[$target_name]: 1 Minute Load
LegendI[$target_name]: 5sec :
LegendO[$target_name]: 1min :
Title[$target_name]: $sysname
PageTop[$target_name]: <H1>$sysname Processor Load</H1>
<TABLE>
<TR><TD>System:</TD><TD>$sysname </TD></TR>
<TR><TD>Location:</TD><TD>$syslocation </TD></TR>
</TABLE>
CPUOLD
;
}
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-Cut here+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
>
> I was only saying that is there any site where we can get the
> information about deploying the same
Not really. Cisco does a poor job of documenting their mibs,
particularly support for particular variables in particular versions of
code on specific platforms. The only way to really know is to read
every release note for every version of code they have ever released,
which is quite tedious, and guess what they have changed by an obscure
reference.
--
Daniel J McDonald, CCIE # 2495, CISSP # 78281, CNX
Austin Energy
http://www.austinenergy.com
More information about the mrtg
mailing list