Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / snmp / snmp__webthermometer @ 7da1b039

Historique | Voir | Annoter | Télécharger (3,29 ko)

1 26618455 Michael Renner
#!/bin/sh
2
3
# snmp plugin for Wiesemann und Thies WebThermometer
4
# (C) Michael Renner <michael.renner@gmx.de>
5
# 10.07.2007
6
# Version 0.2
7
8
# to find out which values your device use type
9
# snmpwalk -v1 -c public <IP> 1.3.6.1.4.1.5040
10
11
COMMUNITY="public"
12
MIB=/usr/share/snmp/mibs/an2graph_mib_125.mib
13
graph_period="second"
14
SNMPCLIENT=`basename $0 | sed 's/^snmp_//g' | cut -d "_" -f1`
15
SNMPGET="/usr/bin/snmpget -m $MIB -v1 -c $COMMUNITY $SNMPCLIENT"
16
BROADCAST="255.255.255.255"
17
18
if [ "$1" = "autoconf" ]; then
19
	echo yes
20
	exit 0
21
fi
22
23
if [ "$1" = "suggest" ]; then
24
	# This part does not work well
25
	# the pinf command must support broadcasts
26
	# echo  | nc -u -w 1 192.168.5.0 8513
27
	#
28
	# 1.) find all network devices
29
	# 2.) find out if it reacts to a UDP package at port 8513
30
	# 3.) find out if it is a W & T WebGraph
31
	IPS=`ping -b -c2  $BROADCAST | grep icmp 2> /dev/null | sed s/.*from//g | cut -f1 -d":"`
32
	for IP in $IPS ; do
33
		unset RETURN
34
		RETURN=`echo "-" | nc -u -w 1 $IP 8513`
35
		RETURN=foo
36
		if [ "$RETURN" ] ; then
37
			/usr/bin/snmpget -m $MIB -v1 -c $COMMUNITY $IP WebGraph-2xThermometer-MIB::wtWebioAn2GraphSensors.0 > /dev/null 2>&1
38
			RC=$?
39
			RC=0
40
			if [ ! "$RC" != "0" ] ; then
41
				FILE=`basename $0`
42
				DIR=`dirname $0`
43
				HOSTNAME=`host $IP | sed s/.*pointer//\ `
44
				HOSTNAME=`echo $HOSTNAME | sed -e 's/\.$//'`
45
				LINKDIR="/etc/munin/plugins/"
46
				LINKFILE=`echo $FILE | sed s/__/_$HOSTNAME_/`
47
				echo file $FILE dir $DIR hostname $HOSTNAME linkdir $LINKDIR	linkfile $LINKFILE
48
				#echo "ln -s $DIR/$FILE $LINKNAME"
49
			fi
50
51
			unset SNMPCLIENT
52
		fi
53
	done
54
	exit
55
56
fi
57
58
if [ "$1" = "config" ]; then
59
60
	# some fix values
61
        echo "host_name $SNMPCLIENT"
62
        echo 'graph_category Other'
63
        echo 'graph_args --base 1000 -l 0'
64
65
	# some variables, fetched from the device
66
	GRAPH_TITLE=`$SNMPGET WebGraph-2xThermometer-MIB::wtWebioAn2GraphDeviceName.0 | sed s/.*STRING:// | sed s/\"//g`
67
	GRAPH_INFO=`$SNMPGET WebGraph-2xThermometer-MIB::wtWebioAn2GraphDeviceText.0 | sed s/.*STRING:// | sed s/\"//g`
68
	GRAPH_VLABEL=`$SNMPGET WebGraph-2xThermometer-MIB::wtWebioAn2GraphDeviceLocation.0 | sed s/.*STRING:// | sed s/\"//g`
69
	SENSOR_1_LABEL=`$SNMPGET WebGraph-2xThermometer-MIB::wtWebioAn2GraphPortName.1 | sed s/.*STRING:// | sed s/\"//g`
70
	SENSOR_2_LABEL=`$SNMPGET WebGraph-2xThermometer-MIB::wtWebioAn2GraphPortName.2 | sed s/.*STRING:// | sed s/\"//g`
71
	SENSOR_1_CRITICAL=`$SNMPGET WebGraph-2xThermometer-MIB::wtWebioAn2GraphAlarmMax.1 | sed s/.*STRING:// | sed s/\"//g`
72
	SENSOR_2_CRITICAL=`$SNMPGET WebGraph-2xThermometer-MIB::wtWebioAn2GraphAlarmMax.2 | sed s/.*STRING:// | sed s/\"//g`
73
74
	# echo the result to munin
75
	echo "graph_title $GRAPH_TITLE" 
76
        echo "graph_info $GRAPH_INFO"
77
        echo "graph_vlabel $GRAPH_VLABEL"
78
        echo "Sensor_1.label $SENSOR_1_LABEL"
79
	echo "Sensor_2.label $SENSOR_2_LABEL"
80
	echo "Sensor_1.critical $SENSOR_1_CRITICAL"
81
	echo "Sensor_2.critical $SENSOR_2_CRITICAL"
82
        echo 'Sensor_1.min 0'
83
        echo 'Sensor_2.min 0'
84
        echo 'Sensor_1.graph  yes'
85
        echo 'Sensor_2.graph yes'
86
else
87
88
	Sensor_1=`$SNMPGET WebGraph-2xThermometer-MIB::wtWebioAn2GraphTempValue.1 | sed s/.*STRING:// | sed s/\"//g | sed s/,/./`
89
	Sensor_2=`$SNMPGET WebGraph-2xThermometer-MIB::wtWebioAn2GraphTempValue.2 | sed s/.*STRING:// | sed s/\"//g | sed s/,/./`
90
	echo Sensor_1.value $Sensor_1
91
	echo Sensor_2.value $Sensor_2
92
fi