Table of Contents

mpstat

Author Eric Meddaugh
Compatibility Xymon 4.2
Requirements Solaris 10
Download None
Last Update 2006-11-26

Description

Monitor zones status under Solaris 10.

Installation

Client Configuration

  1. Add script to client's ext folder
  2. Add the following to client hobbitlaunch.cfg
    [mpstat]
    	ENVFILE $HOBBITCLIENTHOME/etc/hobbitclient.cfg
    	CMD $HOBBITCLIENTHOME/ext/mpstat.sh 
    	LOGFILE $HOBBITCLIENTHOME/logs/mpstat.log
    	INTERVAL 5m

Server Configuration

<note important>This step is not needed if you have the zonestat monitor installed.</note>

Show Code ⇲

Hide Code ⇱

[mpstatusr]
        TITLE CPU usr Utilitization
        YAXIS % Used
        FNPATTERN mpstat.CPU(.*).rrd
        -u 100
        -r
        DEF:cpu@RRDIDX@=@RRDFN@:CPU:AVERAGE
        DEF:usr@RRDIDX@=@RRDFN@:usr:AVERAGE
        LINE1:usr@RRDIDX@#@COLOR@:CPU@RRDPARAM@
        GPRINT:usr@RRDIDX@:LAST: \: %5.1lf (cur)
        GPRINT:usr@RRDIDX@:MAX: \: %5.1lf (max)
        GPRINT:usr@RRDIDX@:MIN: \: %5.1lf (min)
        GPRINT:usr@RRDIDX@:AVERAGE: \: %5.1lf (avg)\n

[mpstatsys]
        TITLE CPU sys Utilitization
        YAXIS % Used
        FNPATTERN mpstat.CPU(.*).rrd
        -u 100
        -r
        DEF:cpu@RRDIDX@=@RRDFN@:CPU:AVERAGE
        DEF:sys@RRDIDX@=@RRDFN@:sys:AVERAGE
        LINE1:sys@RRDIDX@#@COLOR@:CPU@RRDPARAM@
        GPRINT:sys@RRDIDX@:LAST: \: %5.1lf (cur)
        GPRINT:sys@RRDIDX@:MAX: \: %5.1lf (max)
        GPRINT:sys@RRDIDX@:MIN: \: %5.1lf (min)
        GPRINT:sys@RRDIDX@:AVERAGE: \: %5.1lf (avg)\n

[mpstatwt]
        TITLE CPU wt Utilitization
        YAXIS % Used
        FNPATTERN mpstat.CPU(.*).rrd
        -u 100
        -r
        DEF:cpu@RRDIDX@=@RRDFN@:CPU:AVERAGE
        DEF:wt@RRDIDX@=@RRDFN@:wt:AVERAGE
        LINE1:wt@RRDIDX@#@COLOR@:CPU@RRDPARAM@
        GPRINT:wt@RRDIDX@:LAST: \: %5.1lf (cur)
        GPRINT:wt@RRDIDX@:MAX: \: %5.1lf (max)
        GPRINT:wt@RRDIDX@:MIN: \: %5.1lf (min)
        GPRINT:wt@RRDIDX@:AVERAGE: \: %5.1lf (avg)\n

[mpstatidl]
        TITLE CPU idl Utilitization
        YAXIS % Used
        FNPATTERN mpstat.CPU(.*).rrd
        -u 100
        -r
        DEF:num@RRDIDX@=@RRDFN@:CPU:AVERAGE
        DEF:idl@RRDIDX@=@RRDFN@:idl:AVERAGE
        LINE1:idl@RRDIDX@#@COLOR@:CPU@RRDPARAM@
        GPRINT:idl@RRDIDX@:LAST: \: %5.1lf (cur)
        GPRINT:idl@RRDIDX@:MAX: \: %5.1lf (max)
        GPRINT:idl@RRDIDX@:MIN: \: %5.1lf (min)
        GPRINT:idl@RRDIDX@:AVERAGE: \: %5.1lf (avg)\n

Source

mpstat.sh

Show Code ⇲

Hide Code ⇱

#!/bin/sh

ZONE="global"
if [ -x "/bin/zonename" ] ; then
   ZONE=`/bin/zonename`
fi

if [ "${ZONE}" != "global" ] ; then
   exit 0
fi

PROCCNT=`/usr/sbin/psrinfo | egrep -c since`
CPUS=`/usr/sbin/psrinfo | awk '{printf $1" "}'`

nohup sh -c "mpstat 300 2 1>$BBTMP/hobbit_mpstat.$MACHINEDOTS.$$ 2>&1; mv $BBTMP/hobbit_mpstat.$MACHINEDOTS.$$ $BBTMP/hobbit_mpstat.$MACHINEDOTS" </dev/null >/dev/null 2>&1 &
   sleep 5

if [ -f "$BBTMP/hobbit_mpstat.$MACHINEDOTS" ] ; then
   cat $BBTMP/hobbit_mpstat.$MACHINEDOTS | tail -${PROCCNT} > $BBTMP/hobbit_mpstat.$MACHINEDOTS.work

   echo "CPUs: ${CPUS}" > $BBTMP/hobbit_mpstat.$MACHINEDOTS.send
   while read CPU MINF MJF XCAL INTR INTHR CSW ICSW MIGR SMTX SRW SYSCL USR SYS WT IDL ; do

      echo "CPU${CPU}usr: ${USR}" >> $BBTMP/hobbit_mpstat.$MACHINEDOTS.send
      echo "CPU${CPU}sys: ${SYS}" >> $BBTMP/hobbit_mpstat.$MACHINEDOTS.send
      echo "CPU${CPU}wt: ${WT}" >> $BBTMP/hobbit_mpstat.$MACHINEDOTS.send
      echo "CPU${CPU}idl: ${IDL}" >> $BBTMP/hobbit_mpstat.$MACHINEDOTS.send
   done < $BBTMP/hobbit_mpstat.$MACHINEDOTS.work

      $BB $BBDISP "data $MACHINE.mpstat

`$CAT $BBTMP/hobbit_mpstat.$MACHINEDOTS.send`
"
   /bin/rm -f $BBTMP/hobbit_mpstat.$MACHINEDOTS.send
   /bin/rm -f $BBTMP/hobbit_mpstat.$MACHINEDOTS.work
   /bin/rm $BBTMP/hobbit_mpstat.$MACHINEDOTS
fi


##$BB $BBDISP "status $MACHINE.$TEST $COLOR `$DATE` $ERRMESS `$CAT $BBTMP/$MACHINE.$TEST`"


rrd_data.pl

Show Code ⇲

Hide Code ⇱

#!/usr/local/bin/perl
 
use strict;
 
# Input parameters: Hostname, testname (column), and messagefile
my $hostname=$ARGV[0];
my $testname=$ARGV[1];
my $fname=$ARGV[2];
 
my ( $line,@line);
my ( @loop,$key,%buffer,$tmp );
 
open(IN,"$fname");
while(chomp($line=<IN>)) {
   @line=split(':',$line);
   $line[1] = join(' ',split(' ',$line[1]));
   $buffer{$line[0]}=$line[1];
}
close(IN);
 
if ( $testname eq "mpstat" ) {
##
## Reads in the mpstat.sh from client
##
   if ( defined($buffer{"CPUs"}) ) {
 
      @loop=split(' ',$buffer{"CPUs"});
      print "DS:CPU:GAUGE:600:0:32\n";
 
      print "DS:usr:GAUGE:600:0:100\n";
      print "DS:sys:GAUGE:600:0:100\n";
      print "DS:wt:GAUGE:600:0:100\n";
      print "DS:idl:GAUGE:600:0:100\n";
 
      foreach $key ( @loop ) {
         undef(@line);
         push(@line,$buffer{"${key}"});
         push(@line,$buffer{"CPU${key}usr"});
         push(@line,$buffer{"CPU${key}sys"});
         push(@line,$buffer{"CPU${key}wt"});
         push(@line,$buffer{"CPU${key}idl"});
 
         print "mpstat.CPU${key}.rrd\n";
         $line=join(':',@line);
         print "$line\n";
      }
 
   }
} elsif ( $testname eq "zonestat" ) {
##
## Reads in the zonestat.sh from client
##
   if ( defined($buffer{"ZONEs"}) ) {
      @loop=split(' ',$buffer{"ZONEs"});
 
      print "DS:nproc:GAUGE:600:0:U\n";
      print "DS:size:GAUGE:600:0:U\n";
      print "DS:rss:GAUGE:600:0:U\n";
      print "DS:memory:GAUGE:600:0:U\n";
      print "DS:cpu:GAUGE:600:0:U\n";
 
      foreach $key ( @loop ) {
         undef(@line);
         push(@line,$buffer{"${key}nproc"});
         push(@line,$buffer{"${key}size"});
         push(@line,$buffer{"${key}rss"});
         push(@line,$buffer{"${key}memory"});
         push(@line,$buffer{"${key}cpu"});
 
         $tmp = (split('/',$key))[1];
         print "zonestat.${key}.rrd\n";
         $line=join(':',@line);
         print "$line\n";
      }
 
   }
}
 
exit 0;

Known Bugs and Issues

To Do

Credits

Changelog