munin plugin: sensor names in config
[usb-wde1-tools.git] / munin / usb-wde1_
index 44443a81dc2d40c3788943eceb82dd70a1c2c346..f58cc9bff8f61b35bf3251df34951dfd41154539 100755 (executable)
@@ -28,11 +28,15 @@ usb-wde1 -  Munin plugin to report usb-wde1 temperature and humidity data
 
 =cut
 
+TYPE=`basename $0 | sed 's/^.*_//g'`
+
 if [ "$1" = "autoconf" ]; then
-    if [ -r "$logfile" ]; then
-        echo yes
-    else
+    if [ ! -r "$logfile" ]; then
         echo "no (Logfile \"$logfile\" does not exist)"
+    elif [ "$TYPE" != "temperature" -a "$TYPE" != "humidity" ]; then
+        echo "no (Type \"$TYPE\" not supported, try \"./usb-wde1_ suggest\")"
+    else
+        echo yes
     fi
     exit 0
 
@@ -42,9 +46,20 @@ elif [ "$1" = "suggest" ]; then
     exit 0
 fi
 
-
+###############
 #load variables
-TYPE=`basename $0 | sed 's/^.*_//g'`
+###############
+
+# Sensors to display
+if [ "$sensors" = "" ]; then
+    sensors="0 1 2 3 4 5 6 7"
+fi
+# Sensor names
+for i in $sensors; do
+    code="sensor$i=\${sensor$i:=Sensor $i}"
+    eval $code
+done
+# FIXME: Warning/critical values
 
 
 if [ "$1" = "config" ]; then
@@ -66,6 +81,10 @@ if [ "$1" = "config" ]; then
     echo 'graph_category sensors'
 
     #FIXME: warning/critical values
+    for i in $sensors; do
+        eval "name=\$sensor$i"
+        echo "sensor$i.label $name"
+    done
 
     exit 0
 fi
\ No newline at end of file