2008-04-15 21:04:55 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# snmp plugin for Wiesemann und Thies WebThermometer
|
|
|
|
# (C) Michael Renner <michael.renner@gmx.de>
|
|
|
|
# 10.07.2007
|
|
|
|
# Version 0.2
|
|
|
|
|
|
|
|
# to find out which values your device use type
|
|
|
|
# snmpwalk -v1 -c public <IP> 1.3.6.1.4.1.5040
|
|
|
|
|
|
|
|
COMMUNITY="public"
|
|
|
|
MIB=/usr/share/snmp/mibs/an2graph_mib_125.mib
|
|
|
|
graph_period="second"
|
|
|
|
SNMPCLIENT=`basename $0 | sed 's/^snmp_//g' | cut -d "_" -f1`
|
|
|
|
SNMPGET="/usr/bin/snmpget -m $MIB -v1 -c $COMMUNITY $SNMPCLIENT"
|
|
|
|
BROADCAST="255.255.255.255"
|
|
|
|
|
|
|
|
if [ "$1" = "autoconf" ]; then
|
|
|
|
echo yes
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$1" = "suggest" ]; then
|
|
|
|
# This part does not work well
|
|
|
|
# the pinf command must support broadcasts
|
|
|
|
# echo | nc -u -w 1 192.168.5.0 8513
|
|
|
|
#
|
|
|
|
# 1.) find all network devices
|
|
|
|
# 2.) find out if it reacts to a UDP package at port 8513
|
|
|
|
# 3.) find out if it is a W & T WebGraph
|
|
|
|
IPS=`ping -b -c2 $BROADCAST | grep icmp 2> /dev/null | sed s/.*from//g | cut -f1 -d":"`
|
|
|
|
for IP in $IPS ; do
|
|
|
|
unset RETURN
|
|
|
|
RETURN=`echo "-" | nc -u -w 1 $IP 8513`
|
|
|
|
RETURN=foo
|
|
|
|
if [ "$RETURN" ] ; then
|
|
|
|
/usr/bin/snmpget -m $MIB -v1 -c $COMMUNITY $IP WebGraph-2xThermometer-MIB::wtWebioAn2GraphSensors.0 > /dev/null 2>&1
|
|
|
|
RC=$?
|
|
|
|
RC=0
|
|
|
|
if [ ! "$RC" != "0" ] ; then
|
|
|
|
FILE=`basename $0`
|
|
|
|
DIR=`dirname $0`
|
2014-10-05 15:49:54 +02:00
|
|
|
HOST_NAME=`host $IP | sed s/.*pointer//\ `
|
|
|
|
HOST_NAME=`echo $HOST_NAME | sed -e 's/\.$//'`
|
2008-04-15 21:04:55 +02:00
|
|
|
LINKDIR="/etc/munin/plugins/"
|
2014-10-05 15:49:54 +02:00
|
|
|
LINKFILE=`echo $FILE | sed s/__/_$HOST_NAME_/`
|
|
|
|
echo file $FILE dir $DIR hostname $HOST_NAME linkdir $LINKDIR linkfile $LINKFILE
|
2008-04-15 21:04:55 +02:00
|
|
|
#echo "ln -s $DIR/$FILE $LINKNAME"
|
|
|
|
fi
|
|
|
|
|
|
|
|
unset SNMPCLIENT
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
exit
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$1" = "config" ]; then
|
|
|
|
|
|
|
|
# some fix values
|
|
|
|
echo "host_name $SNMPCLIENT"
|
2018-03-28 04:29:25 +02:00
|
|
|
echo 'graph_category sensors'
|
2008-04-15 21:04:55 +02:00
|
|
|
echo 'graph_args --base 1000 -l 0'
|
|
|
|
|
|
|
|
# some variables, fetched from the device
|
|
|
|
GRAPH_TITLE=`$SNMPGET WebGraph-2xThermometer-MIB::wtWebioAn2GraphDeviceName.0 | sed s/.*STRING:// | sed s/\"//g`
|
|
|
|
GRAPH_INFO=`$SNMPGET WebGraph-2xThermometer-MIB::wtWebioAn2GraphDeviceText.0 | sed s/.*STRING:// | sed s/\"//g`
|
|
|
|
GRAPH_VLABEL=`$SNMPGET WebGraph-2xThermometer-MIB::wtWebioAn2GraphDeviceLocation.0 | sed s/.*STRING:// | sed s/\"//g`
|
|
|
|
SENSOR_1_LABEL=`$SNMPGET WebGraph-2xThermometer-MIB::wtWebioAn2GraphPortName.1 | sed s/.*STRING:// | sed s/\"//g`
|
|
|
|
SENSOR_2_LABEL=`$SNMPGET WebGraph-2xThermometer-MIB::wtWebioAn2GraphPortName.2 | sed s/.*STRING:// | sed s/\"//g`
|
|
|
|
SENSOR_1_CRITICAL=`$SNMPGET WebGraph-2xThermometer-MIB::wtWebioAn2GraphAlarmMax.1 | sed s/.*STRING:// | sed s/\"//g`
|
|
|
|
SENSOR_2_CRITICAL=`$SNMPGET WebGraph-2xThermometer-MIB::wtWebioAn2GraphAlarmMax.2 | sed s/.*STRING:// | sed s/\"//g`
|
|
|
|
|
|
|
|
# echo the result to munin
|
2018-08-02 02:03:42 +02:00
|
|
|
echo "graph_title $GRAPH_TITLE"
|
2008-04-15 21:04:55 +02:00
|
|
|
echo "graph_info $GRAPH_INFO"
|
|
|
|
echo "graph_vlabel $GRAPH_VLABEL"
|
|
|
|
echo "Sensor_1.label $SENSOR_1_LABEL"
|
|
|
|
echo "Sensor_2.label $SENSOR_2_LABEL"
|
|
|
|
echo "Sensor_1.critical $SENSOR_1_CRITICAL"
|
|
|
|
echo "Sensor_2.critical $SENSOR_2_CRITICAL"
|
|
|
|
echo 'Sensor_1.min 0'
|
|
|
|
echo 'Sensor_2.min 0'
|
|
|
|
echo 'Sensor_1.graph yes'
|
|
|
|
echo 'Sensor_2.graph yes'
|
|
|
|
else
|
|
|
|
|
|
|
|
Sensor_1=`$SNMPGET WebGraph-2xThermometer-MIB::wtWebioAn2GraphTempValue.1 | sed s/.*STRING:// | sed s/\"//g | sed s/,/./`
|
|
|
|
Sensor_2=`$SNMPGET WebGraph-2xThermometer-MIB::wtWebioAn2GraphTempValue.2 | sed s/.*STRING:// | sed s/\"//g | sed s/,/./`
|
|
|
|
echo Sensor_1.value $Sensor_1
|
|
|
|
echo Sensor_2.value $Sensor_2
|
|
|
|
fi
|