Re: [j-nsp] Temperature and CPU managment

From: Doug McPherson (dougm@ixen.com)
Date: Fri Mar 15 2002 - 11:09:14 EST


On or about Fri, Mar 15, 2002 at 11:57:07AM -0300, Ricardo G Patara wrote:

> Hi.
> I'm trying to configure my mrtg to get info about temperature, cpu and memory
> usage.
> I read the Juniper MIB, but didn't find the oid for this.
> Any help?
>
> Thanks

See if these perl snippets points you in the right direction.

NO WARRANTY EXPRESSED OR IMPLIED.

These code frags are taken from a larger body of cruft I wrote once,
and has some variables that may or may not make sense out of context.

In hindsight, some of them don't make sense *IN* context...

:^)

HTH,
/doug

<SNIP>

#
# Juniper Handler
#

if ($rtr_mfg eq "JUNIPER") {

#
# We need to dig out info from the Juniper chassis mib...
#
# For each row, the 1st 4 items concatenated with "." forms the unique index in the
# table for this object. I.e. to get midplane status, I would do an snpget of
# {$table_base} {column #} {cols 1-4, concatenated}
# .1.3.6.1.4.1.2636.3.1.13.1 . 6 . 1.1.1.0
#
# This yields the OID .1.3.6.1.4.1.2636.3.1.13.1.6.1.1.1.0
#
# Now get the table...

$juniperHWtable = ".1.3.6.1.4.1.2636.3.1.13";

if ($ver =~ /4.1/) {

      open (SNMP,"$snmptable -m JUNIPER-MIB $table_opts $opt_router $opt_community $juniperHWtable|") || die "ERROR: failed snmp query to
$opt_router. $!\n";

        } else {

        open (SNMP,"$snmptable -m JUNIPER-MIB $opt_router $opt_community $table_opts $juniperHWtable|") || die "ERROR: Can\'t open snmp query to
$opt_router. $!\n";

        };

while (<SNMP>) {
        chomp;
        ($ix,$l1ix,$l2ix,$l3ix,$Jdescr,$Jstate,$Jtemp,$JCPU,$JISR,$JDRAM,$Jbuffer,$Juptime,$JLastRestart) = split(/\|/);

# build OID list for objects we care about so we can diddle them into an MRTG config
        $stateOID{$Jdescr} = "$juniperHWtable.1.6.$ix.$l1ix.$l2ix.$l3ix";
        $tempOID{$Jdescr} = "$juniperHWtable.1.7.$ix.$l1ix.$l2ix.$l3ix";
        $cpuOID{$Jdescr} = "$juniperHWtable.1.8.$ix.$l1ix.$l2ix.$l3ix";
        $isrOID{$Jdescr} = "$juniperHWtable.1.9.$ix.$l1ix.$l2ix.$l3ix";
        $dramOID{$Jdescr} = "$juniperHWtable.1.10.$ix.$l1ix.$l2ix.$l3ix";
        $buffOID{$Jdescr} = "$juniperHWtable.1.11.$ix.$l1ix.$l2ix.$l3ix";
        $heapOID{$Jdescr} = "$juniperHWtable.1.13.$ix.$l1ix.$l2ix.$l3ix";

        if ($Jdescr =~ /^SSB 1/) { $SSB_1_DESCR = $Jdescr };
        if ($Jdescr =~ /^SSB 0/) { $SSB_0_DESCR = $Jdescr };

        if ($Jdescr =~ /power supply A/) {$PS_A_DESCR = $Jdescr};
        if ($Jdescr =~ /power supply B/) {$PS_B_DESCR = $Jdescr};

};

<SNIP>

ub MakeJuniperTemp {

#
# We want to create configs for the followig:
# 1) temp.re0 & temp.re1 (on same graph)
# 2) temp.ssb0 & temp.ccb1 (on same graph)
# 3) temp.psa & temp.psb (on same graph)
# 4-n) temp.fpc* (one graph per FPC)

print "################################################################################\n";
print "# Temperature collection config for $opt_router\n";
print "#\n";

&TempStanza('re',
                'Routing Engine Temperatures',
                $tempOID{'Routing Engine 0'},
                $tempOID{'Routing Engine 1'},
                'Routing Engine 0',
                'Routing Engine 1');

&TempStanza('ssb',
                'SSB Temperatures',
                $tempOID{$SSB_0_DESCR},
                $tempOID{$SSB_1_DESCR},
                $SSB_0_DESCR,
                $SSB_1_DESCR);

&TempStanza('ps',
                'Power Supply Temperatures',
                $tempOID{$PS_A_DESCR},
                $tempOID{$PS_B_DESCR},
                $PS_A_DESCR,
                $PS_B_DESCR);

#
# We don't know how many FPCs we'll have or where, so we have to
# roll thru the list and make a unique 'tag' for each.
#

my $tagcount=1;
foreach $key (sort keys %stateOID) {
        if ($key =~/FPC/i) {
                $tag = "FPC".$tagcount;
                $tag =~ tr/A-Z/a-z/;
                &TempStanza($tag,
                        "$key Temperature",
                        $tempOID{$key},
                        $tempOID{$key},
                        $key,
                        $key);
                        };
                $tagcount++;
        };

print "################################################################################\n";
print "\n";

<SNIP>

sub MakeJuniperCPU {

#
# We want the following graphs:
# 1) cpu.ssb0 & cpu.ssb1 (on same graph)
# 2-n) cpu.fpc* (one graph per FPC)
#

print "################################################################################\n";
print "# CPU collection config for $opt_router\n";
print "#\n";

&CPUStanza('ssb',
                'SSB CPU Utilization',
                $cpuOID{$SSB_0_DESCR},
                $cpuOID{$SSB_1_DESCR},
                $SSB_0_DESCR,
                $SSB_1_DESCR);

#
# We don't know how many FPCs we'll have or where, so we have to
# roll thru the list and make a unique 'tag' for each.
#

my $tagcount=1;
foreach $key (sort keys %stateOID) {
        if ($key =~/FPC/i) {
                $tag = "FPC".$tagcount;
                $tag =~ tr/A-Z/a-z/;
                &CPUStanza($tag,
                        "$key CPU Utilization",
                        $cpuOID{$key},
                        $cpuOID{$key},
                        $key,
                        $key);
                        };
                $tagcount++;
        };

print "################################################################################\n";
print "\n";

return;
};
#
##############################################################################################

<SNIP>

##############################################################################################
#
sub CPUStanza {
local ($tag,$title2,$oid1,$oid2,$desc1,$desc2) = @_;

print <<END_CPU_STANZA;
#-------------------------------------------------
# $opt_router CPU usage. $title2
#-------------------------------------------------
Directory[CPU.$tag.$opt_router]: $dir
Target[CPU.$tag.$opt_router]:$oid1&$oid2:$opt_community\@$opt_router
Title[CPU.$tag.$opt_router]:$title2, $opt_router
YLegend[CPU.$tag.$opt_router]: CPU Usage
ShortLegend[CPU.$tag.$opt_router]: percent
MaxBytes[CPU.$tag.$opt_router]: 100
AbsMax[CPU.$tag.$opt_router]: 100
Unscaled[CPU.$tag.$opt_router]: dwmy
WithPeak[CPU.$tag.$opt_router]: dwmy
Options[CPU.$tag.$opt_router]: gauge, absolute, growright, nopercent
Legend1[CPU.$tag.$opt_router]: $desc1 CPU Usage
Legend2[CPU.$tag.$opt_router]: $desc2 CPU Usage
Legend3[CPU.$tag.$opt_router]: Max. 5min $cpu1_desc CPU Usage
Legend4[CPU.$tag.$opt_router]: Max. 5min $cpu2_desc CPU Usage
LegendI[CPU.$tag.$opt_router]: $desc1 :
LegendO[CPU.$tag.$opt_router]: $desc2 :
Timezone[CPU.$tag.$opt_router]: GMT
PageTop[CPU.$tag.$opt_router]: <META HTTP-EQUIV="Pragma" CONTENT="no-cache"><H1>$title2, $opt_router</H1>

END_CPU_STANZA

return;
};
#
##############################################################################################

-
  Quidquid latine dictum sit, altum viditur.
  (Whatever is said in Latin sounds profound.)



This archive was generated by hypermail 2b29 : Mon Aug 05 2002 - 10:42:40 EDT