Tex,
I don't think you could do this with a custom HTTP probe. The process requires several HTTP requests along with some rather obtuse calculations, and a timed sleep of at least 700ms. I've attached a copy of the script in its cmd-probe form.
-mel
On Jan 5, 2005, at 2:15 PM, Mel Beckman wrote:
OK, I discovered two problems. First, some background. My script queries an HTTP-based temperature sensor using the Lynx utility and returns the result as a printed number as the sole output of the script. It runs fine on the desktop.
Ideally, I'd like to be able to graph the temperature returned as well, but I realise that IM doesn't appear to support that for non-SNMP probes. I'd think it would be easy to do using pseudo-MIB variables, however, so I'm hoping that something is in the works along those lines.
-mel
You could write a custom TCP probe instead. Then you would not have to jump through the command-line hoops and it would allow you to graph the values.
Use the built-in HTTP probe as a basis. I can give you some help.
-Tex Clayton Dartware, LLC http://www.dartware.com
#!/bin/bash
#
# HA7Net-GetTemp
#
# Usage:
# HA7Net-GetTemp IP-address deviceID
#
# Returns: Temperature in degrees F via STDOUT
#
# (c) Copyright 2005 Mel Beckman
#
IPADDRESS=$1
DEVICE=$2
URLFRONT="http://"$IPADDRESS
URLEND="'"
#
# Reset the bus
#
CMD="lynx -source http://$IPADDRESS/1Wire/ResetBus.html"
ERROR=`$CMD | sed -n -e 's/.*<INPUT.*NAME="Completed_\(.*\)".*VALUE="\(.*\)".*./\2/p'`
#
# Address the device
#
CMD="lynx -source http://$IPADDRESS/1Wire/AddressDevice.html?Address=$DEVICE"
ERROR=`$CMD | sed -n -e 's/.*<INPUT.*NAME="Completed_\(.*\)".*VALUE="\(.*\)".*./\2/p'`
#
# Send Convert Temp Command
#
CMD="lynx -source http://$IPADDRESS/1Wire/WriteBlock.html?Address=0800000015548A28&Data=44"
ERROR=`$CMD | sed -n -e 's/.*<INPUT.*NAME="Completed_\(.*\)".*VALUE="\(.*\)".*./\2/p'`
#
# wait
#
sleep 1
#
# Read the temp out
#
CMD="lynx -source http://$IPADDRESS/1Wire/WriteBlock.html?Address=0800000015548A28&Data=BEFFFFFFFFFFFFFFFFFF"
READBACK=`$CMD | sed -n -e 's/.*<INPUT.*NAME="ResultData_\(.*\)".*VALUE="\(.*\)".*./\2/p'`
#
# Convert temp
#
# Extract whole degrees
CELSIUSHEX=${READBACK:4:2}${READBACK:2:1}
# Extract fraction
CELSIUSFRACTHEX=${READBACK:3:1}
#
CELSIUSDEC=`echo "ibase=16; $CELSIUSHEX" | bc`
#
# If high-order ones, then temp is minus C, convert 12-bit two's complement
#
SIGN=1
CELSIUSFIX=0
if [ $CELSIUSDEC -ge 256 ]
then
CELSIUSFIX=3968
SIGN=-1
fi
#
CELSIUSFRACTDEC=`echo "ibase=16; $CELSIUSFRACTHEX" | bc`
#
# Combine integer and fraction, depending on whether 2's complement math is needed
#
if [ $SIGN -lt 0 ]
then
CELSIUSTEMP=`echo "scale=4; ((128 - ($CELSIUSDEC - $CELSIUSFIX)) - 0.0625 * $CELSIUSFRACTDEC) * $SIGN" | bc -l`
else
CELSIUSTEMP=`echo "scale=4; $CELSIUSDEC + 0.0625 * $CELSIUSFRACTDEC" | bc -l`
fi
FTEMP=`echo "scale=4; $CELSIUSTEMP * 9/5 + 32" | bc -l`
echo $FTEMP
#
# Someday add alarm logic here
#
exit 0
____________________________________________________________________
List archives: http://www.mail-archive.com/intermapper-talk%40list.dartware.com/
To unsubscribe: send email to: [EMAIL PROTECTED]
