[hobbit] Help with a custom test script

Henrik Stoerner henrik at hswn.dk
Mon Aug 27 07:42:20 CEST 2007


On Sun, Aug 26, 2007 at 03:39:21PM -0700, Q wrote:
>  I am new to writing custom scripts and looking for advice on how to 
> write a test to monitor the status of a machine in our render farm. Each 
> machine is broken down into a number of CPU cores. We have a command 
> that displays the status of each core in the format per line of  
> "<machine name>_<core number> in|out <partition name>" (i.e. testbox_0 
> in testpartition). So here is the part I an trying to work out. A 
> machine with 4 cores will produce 4 lines each with it's own status. I 
> would like to to include all cores in one test. I would like to produce 
> a YELLOW status if any core is labeled as out and RED if they are all 
> listed as out. I would also like to make rrd graphs that shows the in 
> and out time for each core. Any help would be greatly appreciated.

This doesn't do the graph, but it will give you the status you want:

  #!/bin/sh

  # Change this command to the one you use to collect the data
  getthestatus >$BBTMP/corestat.$$

  OUTCOUNT=`grep -c " out " $BBTMP/corestat.$$`
  if test "$OUTCOUNT" = "4"
  then
     COLOR=red
  elif test "$OUTCOUNT" -gt 0
  then
     COLOR=yellow
  else
     COLOR=green
  fi

  # Note: This command spans multiple lines
  $BB $BBDISP "status $MACHINE.cores $COLOR `date`

  $OUTCOUNT cores out

  `cat $BBTMP/corestat.$$
  "

  rm $BBTMP/corestat.$$
  exit 0


Regards,
Henrik




More information about the Xymon mailing list