You can use this script to get cpu utilization on all cisco routers. Use a
perl for run this script in linux or windows and use MRTG for create
graphics of utilization from your cpu.

Regardz,
Eduardo Perestrelo
Telecon Consulting
Cisco Learning Partner

#!/usr/bin/perl -w
###
### cisco-cpus host [community] [mrtg]
###
### Use cpmCPUTotalTable from CISCO-PROCESS-MIB to read CPU
### utilization statistics from all CPUs in a Cisco router.
###
### Author:       Simon Leinen  
### Date Created: 2000/02/24
### RCS $Id: cisco-cpus,v 1.1 2000/02/24 12:12:26 leinen Exp $
###
require 5.003;

use strict;

use BER;
use SNMP_Session;

my $host = shift @ARGV || die;
my $community = shift @ARGV || die;
my $mrtg = shift;
### From CISCO-PROCESS-MIB.my
###
my $cpmCPUTotalPhysicalIndex = [1,3,6,1,4,1,9,9,109,1,1,1,1,2];
my $cpmCPUTotal5sec = [1,3,6,1,4,1,9,9,109,1,1,1,1,3];
my $cpmCPUTotal1min = [1,3,6,1,4,1,9,9,109,1,1,1,1,4];
my $cpmCPUTotal5min = [1,3,6,1,4,1,9,9,109,1,1,1,1,5];

sub out_cpu_totals {
  my ($index, $phys_index, $cpu_5sec, $cpu_1min, $cpu_5min) = @_;

  if (!$mrtg) {
    grep (defined $_ && ($_=pretty_print $_),
          ($phys_index, $cpu_5sec, $cpu_1min, $cpu_5min));
    printf STDOUT ("%2d/%-3d %5.2f %5.2f %5.2f\n",
                 $index, $phys_index,
                 $cpu_5sec,
                 $cpu_1min,
                 $cpu_5min);
  } else {
  grep (defined $_ && ($_=pretty_print $_),
            ($phys_index, $cpu_5sec, $cpu_1min, $cpu_5min));
    printf STDOUT ("%5.2f\n%5.2f\n",$cpu_5sec,$cpu_5sec);
  }
}

my $session = SNMP_Session->open ($host, $community, 161)
  || die "Opening SNMP_Session";
printf STDOUT ("Idx/Phy 5sec  1min  5min\n") if (!$mrtg);
print STDOUT "-" x 24,"\n" if (!$mrtg);
$session->map_table ([
                      $cpmCPUTotalPhysicalIndex,
                      $cpmCPUTotal5sec,
                      $cpmCPUTotal1min,
                      $cpmCPUTotal5min],
                     \&out_cpu_totals);
$session->close ();
1;



Message Posted at:
http://www.groupstudy.com/form/read.php?f=7&i=71742&t=71536
--------------------------------------------------
FAQ, list archives, and subscription info: http://www.groupstudy.com/list/cisco.html
Report misconduct and Nondisclosure violations to [EMAIL PROTECTED]

Reply via email to