File: cisco-cpus

package info (click to toggle)
libsnmp-session-perl 1.14~git20201002.0dedded-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,080 kB
  • sloc: perl: 11,603; ansic: 25; makefile: 13
file content (52 lines) | stat: -rwxr-xr-x 1,376 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/local/bin/perl -w
###
### cisco-cpus host [community]
###
### Use cpmCPUTotalTable from CISCO-PROCESS-MIB to read CPU
### utilization statistics from all CPUs in a Cisco router.
###
### Author:       Simon Leinen  <simon@switch.ch>
### 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;

### 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) = @_;

  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);
}

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