Using Xymon to monitor the ink and toner levels in printers

Kevin McAllister kevin at shadowsoft.com
Fri Mar 12 00:08:37 CET 2010


Hello,

The scripts that I have for gathering this doesn't seem to be getting 
any data at all. I am new to this any help would be appreciated. I am 
running Centos 5.3 x86_64.  I have put a copy of the scripts in the email.

#!/bin/sh


#ink

#

#BIG BROTHER - monitor HP printer ink levels

#


HOSTIP=$1; export HOSTIP

HOST=$2; export HOST

VHOST=$3; export VHOST


InkTmp=$BBTMP/ink.$$; export InkTmp

COLOR="blue"; export COLOR

echo $COLOR > ${InkTmp}-color


URL="http://${HOSTIP}/SSI/device_status_info.htm"

echo "URL: $URL" > ${InkTmp}-2

echo "" >> ${InkTmp}-2


/usr/bin/curl -w "$SS_LOGCURL" -m 120 -H "Host: $VHOST" -G $URL > 
$InkTmp 2>> ${InkTmp}-2


#bit a monkeybusiness with COLOR here because the variable doesn't 
propagate back from the sub-shells


if test $? -eq 0

then

echo "" >> ${InkTmp}-2

COLOR="green"; export COLOR

$GREP CARTRIDGE $InkTmp | $SED -r 's/<[^>]*>| //g' | $SED 's/ 
CARTRIDGE/ _CARTRIDGE: /' | tee -a ${InkTmp}-2 | $SED 's/%//' | while 
read x

do

if test $COLOR != "red"

then

set $x

if test $2 -le 10

then

COLOR="yellow"

fi

fi

echo $COLOR > ${InkTmp}-color

done

fi


#

#THE FIRST LINE IS STATUS INFORMATION .....STRUCTURE IMPORTANT!

#THE REST IS FREE-FORM - WHATEVER YOU'D LIKE TO SEND ....

#

LINE="status ${HOST}.${TEST} `cat ${InkTmp}-color` `date`

<code>`cat ${InkTmp}-2`</code>"


$RM -f $InkTmp ${InkTmp}-2 ${InkTmp}-color


#NOW USE THE BB COMMAND TO SEND THE DATA ACROSS

$BB $BBDISP "$LINE" #SEND IT TO BBDISPLAY

++++++++++++++++++++++++++++++++++++++++++++++++++

#!/bin/sh


#toner

#

#BIG BROTHER - monitor HP printer ink levels

#


HOSTIP=$1; export HOSTIP

HOST=$2; export HOST

VHOST=$3; export VHOST


InkTmp=$BBTMP/toner.$$; export InkTmp

COLOR="blue"; export COLOR

echo $COLOR > ${InkTmp}-color


URL="http://${HOSTIP}/hp/device/this.LCDispatcher?nav=hp.DeviceStatus"

echo "URL: $URL" > ${InkTmp}-2

echo "" >> ${InkTmp}-2


/usr/bin/curl -w "$SS_LOGCURL" -m 120 -H "Host: $VHOST" -G $URL > 
$InkTmp 2>> ${InkTmp}-2


#bit a monkeybusiness with COLOR here because the variable doesn't 
propagate back from the sub-shells


if test $? -eq 0

then

echo "" >> ${InkTmp}-2

COLOR="green"; export COLOR

$GREP CARTRIDGE $InkTmp | $SED -r 's/<[^>]*>| //g' | $SED 's/ 
CARTRIDGE/ _CARTRIDGE: /' | tee -a ${InkTmp}-2 | $SED 's/%//' | while 
read x

do

if test $COLOR != "red"

then

set $x

if test $2 -le 10

then

COLOR="yellow"

fi

fi

echo $COLOR > ${InkTmp}-color

done

fi


#

#THE FIRST LINE IS STATUS INFORMATION .....STRUCTURE IMPORTANT!

#THE REST IS FREE-FORM - WHATEVER YOU'D LIKE TO SEND ....

#


LINE="status ${HOST}.${TEST} `cat ${InkTmp}-color` `date` <code> `cat 
${InkTmp}-2`</code>"


$RM -f $InkTmp ${InkTmp}-2 ${InkTmp}-color


#NOW USE THE BB COMMAND TO SEND THE DATA ACROSS

$BB $BBDISP "$LINE" #SEND IT TO BBDISPLAY








More information about the Xymon mailing list