mirror of
https://github.com/shakemid/pcsensor-temper.git
synced 2025-01-21 09:08:17 +01:00
69 lines
975 B
Bash
Executable file
69 lines
975 B
Bash
Executable file
#!/bin/bash
|
|
# -*- sh -*-
|
|
|
|
# Munin plugin for TEMPer
|
|
|
|
. "${MUNIN_LIBDIR}/plugins/plugin.sh"
|
|
|
|
set -o nounset
|
|
|
|
pcsensor=${pcsensor:-/usr/local/bin/pcsensor}
|
|
pcsensor_cmd="${pcsensor} -m -c"
|
|
|
|
# need calibration
|
|
# example:
|
|
# env.cdef temperature,1.0287,*,0.85,-
|
|
cdef=${cdef:-temperature}
|
|
|
|
retry=${retry:-1}
|
|
|
|
autoconf() {
|
|
echo 'no'
|
|
}
|
|
|
|
config() {
|
|
cat <<EOF
|
|
graph_title Temperature
|
|
graph_category sensors
|
|
graph_scale no
|
|
graph_vlabel Temp C
|
|
graph_args --base 1000
|
|
temperature.label temperature
|
|
temperature.cdef ${cdef}
|
|
EOF
|
|
}
|
|
|
|
fetch() {
|
|
local value i
|
|
|
|
i=0
|
|
while [ "$i" -le "$retry" ];
|
|
do
|
|
value=$( $pcsensor_cmd | sed -n '1p' )
|
|
|
|
if [ -n "$value" ];then
|
|
break
|
|
fi
|
|
|
|
i=$(( i + 1 ))
|
|
sleep 5
|
|
done
|
|
|
|
echo "temperature.value ${value}"
|
|
}
|
|
|
|
# Main
|
|
case ${1:-} in
|
|
autoconf)
|
|
autoconf
|
|
;;
|
|
config)
|
|
config
|
|
[ "${MUNIN_CAP_DIRTYCONFIG:-}" = "1" ] && fetch
|
|
;;
|
|
*)
|
|
fetch
|
|
;;
|
|
esac
|
|
|
|
exit 0
|