monitors:memstat

Error loading plugin struct
ParseError: syntax error, unexpected 'fn' (T_STRING), expecting :: (T_PAAMAYIM_NEKUDOTAYIM)
More info is available in the error log.

This is an old revision of the document!


memstat.ksh

Author Vernon Everett
Compatibility Xymon, Solaris 10 (not tested on others)
Requirements Solaris 10, rrdtool 1.2.x or later
Download None
Last Update 2010-06-10 2013-01-03 2013-02-12

A simple graph to indicate what's using memory on Solaris 10. Can be set to alert.

Really cool for keeping an eye on the size of that ZFS cache and kernel memory usage.

The problem of the graphs not working for systems without ZFS has been resolved with SPLITNCV.

Client side

  • Copy memstat.ksh into xymon ~client/ext directory (usually in $XYMONCLIENTHOME/ext)
  • Copy getmemstat.ksh into xymon ~/client/ext directory, and change owner to root and set SUID.
chown root getmemstat.ksh
chmod 4755 getmemstat.ksh

This is because getmemstat runs mdb, and requires root access to do so.

Server side

Add this to xymonserver.cfg

TEST2RRD="blah,blah,blah,memstat=ncv"
GRAPHS="whatever was there, memstat::8"
SPLITNCV_memstat="*:GAUGE"

Add this to graphs.cfg [memstat]

FNPATTERN memstat,(.*).rrd
TITLE Kernel Memory Allocation
YAXIS %
-l 0
-u 100
DEF:p@RRDIDX@=@RRDFN@:lambda:AVERAGE
AREA:p@RRDIDX@#@COLOR@:@RRDPARAM@:@STACKIT@
GPRINT:p@RRDIDX@:LAST: \: %5.1lf (cur)
GPRINT:p@RRDIDX@:MAX: \: %5.1lf (max)
GPRINT:p@RRDIDX@:MIN: \: %5.1lf (min)
GPRINT:p@RRDIDX@:AVERAGE: \: %5.1lf (avg)\n

Show Code ⇲

Hide Code ⇱

#!/bin/ksh
TEMPFILE=$XYMONTMP/memstat.tmp
COLOUR=green
ALERT=0  # 1= alert on high usage
YELLOW=75
RED=90
date > $TEMPFILE
echo >> $TEMPFILE
$XYMONCLIENTHOME/ext/getmemstat.ksh > $TEMPFILE.data

cat $TEMPFILE.data  >> $TEMPFILE
if [ $ALERT -eq 1 ]
then
   cat $TEMPFILE.data | egrep "^Kernel|^Anon|^Exec" | cut -c52-56 | while read a
   do
      if [ $a -gt $YELLOW -a "$COLOUR" = "green" ]
      then
          COLOUR=yellow
      else
         [ $a -gt $RED ] && COLOUR=red
      fi
   done
fi
echo '<p><font size="1" color="black">' >> $TEMPFILE
cat $TEMPFILE.data | egrep -v -- "-----|Summary|^$|^Total|^Physical" \
                   | sed "s/^Free //g" \
                   | sed "s/[(|)|%]//g" \
                   | awk '{ print $1" : "$NF }' >> $TEMPFILE
echo '</font></p>' >> $TEMPFILE

rm $TEMPFILE.data
$XYMON $XYMSRV "status $MACHINE.memstat $COLOUR $(cat $TEMPFILE)"
rm $TEMPFILE

Show Code ⇲

Hide Code ⇱

#!/bin/ksh
echo "::memstat" | mdb -k
  • None known, but please let me know if you find any.
  • Play around with SPLIT_NCV to avoid the “Graph doesn't work without ZFS issue documented above”
  • Might have a look at another script to assist identifying the memory hogs.

* Special thanks to Henrik not just for writing Xymon, but also showing me how to create stack graphs with SPLITNCV data.

  • 2010-06-10
    • Initial release
  • 2013-01-03
    • The long-promised update to use SPLITNCV for graphing. This means we don't have to muck about adding extra fields to .rrd files for systems that are not using ZFS.
    • Updated variable names to be more Xymon
  • 2013-02-12
    • Changed the trends graph entry to memstat::8. Without it, in the trends column, the graph gets split into 2 graphs, which makes the visualisation of memory usage a little more difficult.
  • monitors/memstat.1360636807.txt.gz
  • Last modified: 2014/11/06 01:19
  • (external edit)