#!/bin/bash # -*- bash -*- : << =cut =head1 NAME 1wire - Plugin to capture readings from 1wire sensors on raspberry pi =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 1wire 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 SENSORS=() FILES=$(find -L /sys/bus/w1/devices/ -maxdepth 2 -name temperature) for f in $FILES do s=${f%/*} s=${s##*-} v=$(cat $f) SENSORS+=("${s} ${v}") done for ROW in "${SENSORS[@]}"; do ENTRY=( $ROW ) SENSOR=${ENTRY[0]} VALUE=${ENTRY[1]/#[0-9][0-9]/&.} # 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