monitors:mpstat

mpstat

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

Monitor zones status under Solaris 10.

  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
  • Xymon only supports 1 data reader on the server. To make it as configurable as possible (we use multiple items to send stats too). Perl was used to help make it quicker. Inside the script has the graph definitions as well. You will have to add the information as documented below to the [rrddata] section to the hobbitlaunch.cfg file. Modify the hobbitlaunch.cfg file on the server under the rrddata section (add the –extra-tests and –extra-script segments):
    # "rrddata" updates RRD files with information that arrives as "data" messages.
    # If you want RRD graphs of your monitoring BB data, then you want to run this.
    
    [rrddata]
        ENVFILE /home/hobbit/server/etc/hobbitserver.cfg
        NEEDS hobbitd
        CMD hobbitd_channel --channel=data  
               --log=$BBSERVERLOGS/rrd-data.log hobbitd_rrd
               --extra-tests=mpstat,zonestat
               --extra-script=/home/hobbit/server/ext/rrd_data.pl
               --rrddir=$BBVAR/rrd

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

  • Add 'mpstat:mpstatusr|mpstatsys|mpstatwt|mpstatidl' to the bb-hosts entry.
    0.0.0.0   myserver    # "TRENDS:*,mpstat:mpstatusr|mpstatsys|mpstatwt|mpstatidl"
  • Update hobbitgraph.cfg with:

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
  • Add 'mpstat' to the GRAPHS and TEST2RRD entry in hobbitserver.cfg.

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`"


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;
  • No known bugs
  • 2006-11-26
    • Initial release
  • monitors/mpstat.txt
  • Last modified: 2011/09/01 14:42
  • by 127.0.0.1