blob: 3c75c72d43378cdca9baf144cbd76620cc7c6088 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
#!/bin/sh
# -*- sh -*-
: << =cut
=head1 NAME
usb-wde1 - Munin plugin to report usb-wde1 temperature and humidity data
=head1 CONFIGURATION
The plugin offers two modes: temperature and humidity graphing.
Symlink usb-wde1_ as "usb-wde1_temperature" and/or "usb-wde1_humidity".
=head2 EXAMPLE CONFIGURATION
[usb-wde1_*]
env.logfile /var/spool/usb-wde1/usb-wde1-last
env.host_name House
env.sensors 0 1 7
env.sensor0 Living room
env.sensor1 Kitchen
env.sensor7 Outside
Warning/critical values for all sensors:
env.warning 10
env.critical 5
Warning/critical values for single sensors:
env.sensor7_warning 40
env.sensor7_critical 50
=head1 AUTHOR
Christian Weiske <cweiske@cweiske.de>
=head1 LICENSE
AGPL
http://www.gnu.org/licenses/agpl.html
=head1 MAGIC MARKERS
#%# family=manual
#%# capabilities=autoconf suggest
=cut
. ${MUNIN_LIBDIR:=/usr/share/munin}/plugins/plugin.sh
TYPE=`basename $0 | sed 's/^.*_//g'`
if [ "$1" = "autoconf" ]; then
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
elif [ "$1" = "suggest" ]; then
echo temperature
echo humidity
exit 0
fi
###############
#load variables
###############
# 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
if [ "$1" = "config" ]; then
if [ "x$host_name" != "x" ]; then
echo "host_name $host_name"
fi
if [ "$TYPE" = "temperature" ]; then
echo 'graph_title Temperature'
#echo 'graph_args --base 1000 --lower-limit -30 --upper-limit 60'
echo 'graph_args --base 1000'
echo 'graph_vlabel Temperature'
echo 'graph_info Shows the temperature of different thermometers'
else
echo 'graph_title Humidity'
#echo 'graph_args --base 1000 --lower-limit 0 --upper-limit 100'
echo 'graph_args --base 1000'
echo 'graph_vlabel Humidity'
echo 'graph_info Shows the air humidity of different thermometers (in %)'
fi
echo 'graph_scale no'
echo 'graph_category sensors'
for i in $sensors; do
eval "name=\$sensor$i"
echo "sensor$i.label $name"
print_warning "sensor$i"
print_critical "sensor$i"
done
exit 0
fi
#Beispielausgabe USB-WDE1:
# $1;1;;13,8;22,7;22,6;17,8;22,2;21,2;22,9;;59;35;38;49;38;40;35;;;;;;;0
# Doku des Formats in 92030_USB_WDE1_V1.0_UM.pdf bei elv.de verfügbar
# Format ist "Logview openformat"
# http://www.logview.info/cms/d_formatbeschreibung.phtml
#split by semicolons
OLDIFS="$IFS"
IFS=";"
read -r sign state timestamp\
t0 t1 t2 t3 t4 t5 t6 t7\
h0 h1 h2 h3 h4 h5 h6 h7\
tc hc ws ns rain checksum\
< "$logfile"
IFS=$OLDIFS
if [ "$sign" != '$1' ]; then
echo Log line does not begin with \$1
exit 2
fi
curdate=`date +%s`
if [ "$timestamp" -lt `expr $curdate - 600` ]; then
#timestamp is too old, data are too old
exit
fi
if [ "$TYPE" = "temperature" ]; then
varprefix=t
else
varprefix=h
fi
for i in $sensors; do
eval "value=\$$varprefix$i"
value=`echo $value|sed s/,/./`
echo "sensor$i.value $value"
done
|