[hobbit] rrdtool from private scripts

Ralph Mitchell ralphmitchell at gmail.com
Wed Oct 18 18:53:01 CEST 2006


On 10/18/06, Ralph Mitchell <ralphmitchell at gmail.com> wrote:
> On 10/18/06, joel at carnat.net <joel at carnat.net> wrote:
>
> >  Hi,
> >
> > I wrote a script to get alert about CPU loads on a windows server using
> > SNMP (no I don't want to / can't install the hobbit client on the server
> > ;). The status is returned OK (green before 50%, orange from 50 to 75 and
> > red over 75).
> >
> > The thing is, there is no graph done (yet).
> > I would like a graph that would show the load average variation.
> >
> > (how) can the script be used to fill a RRD database ?
> > Should the load average value be returned in a special variable ?
> >
>
>
> I'm doing something similar - SNMP queries against a Compaq system to produce a report like this:
>
>    CPU	1 min	5 min	30 min	60min
> &green  0	14%	9%	9%	9%
> &green  1	11%	7%	9%	9%
>
>
> I changed the [rrdstatus] entry in server/etc/hobbitlaunch.cfg to include the --extra-script & --extra-tests entries as described in the hobbit_rrd man page.
>
> If it gets through the mail system, my collection script is attached.  It's not rocket science, but it seems to get the job done.
>
> That pokes the data into an RRD, then it's just a question of setting up the graph config to show what you want to see.
>
> Ralph Mitchell

The script was blocked, so here it is:

Ralph Mitchell


#!/bin/sh
# Input parameters: Hostname, testname (column), and messagefile
#
# Messagefile contains this:
# Thu Jan 12 06:33:28 CST 2006 compaq_cpu
#
# This checkout shows CPU utilization as a percentage of the
# theoretical maximum over 1min, 5min, 30min & 60min periods.
#
#
#
#        CPU    1 min   5 min   30 min  60min
# &green  0     7%      7%      6%      7%
# &green  1     7%      9%      8%      10%
#
#
TMPLOG="/tmp/$1.$2.out"
echo "$1, $2, $3" > $TMPLOG
cat $3 >> $TMPLOG

HOSTNAME="$1"
TESTNAME="$2"
FNAME="$3"

# Check the test name so that this script can service multiple
# data collection needs
if [ "$TESTNAME" = "cpqcpu" ]
then
  # The RRD dataset definitions
  echo "DS:1min:GAUGE:600:0:100"
  echo "DS:5min:GAUGE:600:0:100"
  echo "DS:30min:GAUGE:600:0:100"
  echo "DS:60min:GAUGE:600:0:100"

  # Analyze the message we got
  cat $FNAME | while read line
  do
    if [ "$line" ]; then
      line=`echo $line | sed -e 's/&//g' -e 's/%//g'`
      set $line
      case $1 in
        green)
          echo "cpqcpu.$2.rrd"
          echo "$3:$4:$5:$6"
          echo "cpqcpu.$2.rrd" >> $TMPLOG
          echo "$3:$4:$5:$6" >> $TMPLOG
          ;;
        yellow)
          echo "cpqcpu.$2.rrd"
          echo "$3:$4:$5:$6"
          echo "cpqcpu.$2.rrd" >> $TMPLOG
          echo "$3:$4:$5:$6" >> $TMPLOG
          ;;
        red)
          echo "cpqcpu.$2.rrd"
          echo "$3:$4:$5:$6"
          echo "cpqcpu.$2.rrd" >> $TMPLOG
          echo "$3:$4:$5:$6" >> $TMPLOG
          ;;
        *)
          ;;
      esac
    fi
  done
fi
exit 0



More information about the Xymon mailing list