76 lines
1.4 KiB
Bash
Executable File
76 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
# -*- sh -*-
|
|
|
|
: << =cut
|
|
|
|
=head1 NAME
|
|
|
|
433mhz - Plugin to capture readings from wireless sensors via serial
|
|
|
|
=head1 NOTES
|
|
|
|
=head1 AUTHOR
|
|
|
|
Contributed by Florian Klemenz
|
|
|
|
=head1 LICENSE
|
|
|
|
GPLv2
|
|
|
|
=head1 MAGIC MARKERS
|
|
|
|
#%# family=auto
|
|
#%# capabilities=autoconf
|
|
|
|
=cut
|
|
|
|
. $MUNIN_LIBDIR/plugins/plugin.sh
|
|
|
|
if [ "$1" = "autoconf" ]; then
|
|
echo yes
|
|
exit 0
|
|
fi
|
|
|
|
if [ "$1" = "config" ]; then
|
|
|
|
echo 'graph_title Wireless temperature sensor readings'
|
|
echo 'graph_args --base 1 -l 0 '
|
|
echo 'graph_scale no'
|
|
echo 'graph_vlabel °C'
|
|
echo 'graph_category temperature'
|
|
echo 'temp.label Vorratskammer'
|
|
echo 'temp.draw LINE'
|
|
print_warning temp
|
|
print_critical temp
|
|
exit 0
|
|
fi
|
|
|
|
|
|
CMD="for f in $(find -L /sys/bus/w1/devices/ -maxdepth 2 -name temperature); do s=${f%/*}; s=${s##*-}; v=$(cat $f); echo "${s} ${v}"; done"
|
|
|
|
IFS=$'\n'
|
|
SENSORS=( $(eval $CMD) )
|
|
|
|
echo $SENSORS
|
|
|
|
IFS=' '
|
|
for ROW in "${SENSORS[@]}"; do
|
|
ENTRY=( $ROW )
|
|
SENSOR=${ENTRY[0]}
|
|
VALUE=${ENTRY[1]}
|
|
|
|
# Overrides SENSOR - Example: env.sensor_0_0 Batterie
|
|
ENV_SENSOR_VAR_NAME="alias_${SENSOR}"
|
|
ENV_SENSOR_NAME=${!ENV_SENSOR_VAR_NAME}
|
|
|
|
if [ -n "${ENV_SENSOR_NAME}" ]; then
|
|
echo "${ENV_SENSOR_NAME}.value ${VALUE}"
|
|
else
|
|
echo "${SENSOR}.value ${VALUE}"
|
|
fi
|
|
done
|
|
|
|
|
|
#echo "Vorratskammer.value $TEMP"
|
|
|