Xymon Mailing List Archive search

Sending data from script to an rrd

list Ralph Mitchell
Wed, 18 Oct 2006 14:21:20 -0500
Message-Id: <user-f5f9b47b0fdd@xymon.invalid>

On 10/18/06, Rob Munsch <user-f39e4aae1456@xymon.invalid> wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ralph Mitchell wrote:
On 10/18/06, Rob Munsch <user-f39e4aae1456@xymon.invalid> wrote:
When you add the --extra-script option in the [rrdstatus] block,
Well i'm stuck already.  What file is that block in?  I can't find it in
'server.cfg nor 'graph.cfg...
It's in server/etc/hobbitlaunch.cfg
yeah found that with a grep rrdstatus, heh oops.
So something like

echo "DS:cputemp:GAUGE:600:0:U"
echo "cputemp.rrd"

probably isn't far off after all?
That should do it, yes.  That's the format for the RRD creation, and
the name to create.  If you just want to push out one value, you'd
follow that with:

  echo "$temp"
I seem to still be doing something wrong...
I don't think hobbit_rrd will recreate the rrd if it already exists,
so you'd have to delete it sometime to get it rebuilt with the extra
variables.  Wave bye-bye to your old data...
"Sir, I have no data."

Ok, so i did this

[cputemp]
        TITLE CPU Temp
        YAXIS Degrees Fahrenheit
        DEF:avg=cputemp.rrd:cputemp:AVERAGE
        AREA:cputemp#00CC00:CPU Temp Average
        -u 1.0
        GPRINT:cputemp:LAST: \: %5.11f (cur)
        GPRINT:cputemp:MAX: \: %5.1lf (max)
        GPRINT:cputemp:MIN: \: %5.1lf (min)
        GPRINT:cputemp:AVERAGE: \: %5.1lf (avg)\n

and this

GRAPHS="la,disk,inode,qtree,memory,users,cputemp,.....8<...

as well, on the server.
but what i get is a text link called

Status unchanged in 1 hours, 41 minutes
Status message received from 10.10.10.12
hobbit graph cputemp

that leads to nothing.  Not even a "nan" graph :P

I think maybe by echo is in the wrong place...?  Should it be before or
after the $BB msg command?  Does it matter?

hobbit at currant:~/client/ext$ cat cputemp.sh
#!/bin/sh

umask 133

COLUMN=cputemp
COLOR=green
MSG="Current CPU Temperature: "
host=`hostname`

ipmitool sensor | grep Temp | awk -F\| '{print $1,$2,$3,$4}' >
$BBTMP/cputemp.$host

cpu_temp=`tail -n 4 $BBTMP/cputemp.$host |head -n 1 | awk '{print $2}'
|sed 's/\..*//g'`
# Converting to Fahrenheit.
temp=$((${cpu_temp}*9/5+32))

# Ok, we have the temp in degrees as an integer.
# Now to see if it's Bad, or even Very Bad.

if $temp > 130
then
        COLOR=red
        MSG="${MSG} $temp degrees Fahrenheit!

        Hothothot!
        "
else
        MSG="${MSG} $temp Degrees Fahrenheit

        Chillin' like a Villain.
        "
fi

echo "DS:cputemp:GAUGE:600:0:U"
echo "cputemp.rrd"
echo "$temp"

# Get this to the hobbit server
$BB $BBDISP "status $MACHINE.$COLUMN $COLOR `date`

${MSG}
"

exit 0
There should be *two* scripts...  The data collecting script that
produces the report and uses "$BB BBDISP....." to send the data to
Hobbit, and a separate script that echoes out the RRD creation bits
and pieces.  The first one would be launched by hobbit or cron or some
other means, and the second is executed by hobbit_rrd due to the
--extra-script flag in '[rrdstatus]'.  *That's* the one where the
"echo $temp" goes...

Ralph