summaryrefslogtreecommitdiffstats
path: root/charts.d/sensors.chart.sh
diff options
context:
space:
mode:
authorLennart Weller <lhw@ring0.de>2016-09-05 08:27:26 +0000
committerLennart Weller <lhw@ring0.de>2016-09-05 08:27:26 +0000
commit58d9525d7fcacffe52eff7282b7a888dd0dcc1d0 (patch)
tree251a805eb38d4d75b2a7f44c2cc22e7ea4849513 /charts.d/sensors.chart.sh
parentFixes for service startup and extra config files (diff)
parentImported Upstream version 1.3.0+dfsg (diff)
downloadnetdata-58d9525d7fcacffe52eff7282b7a888dd0dcc1d0.tar.xz
netdata-58d9525d7fcacffe52eff7282b7a888dd0dcc1d0.zip
Merge tag 'upstream/1.3.0+dfsg'
Upstream version 1.3.0+dfsg
Diffstat (limited to 'charts.d/sensors.chart.sh')
-rwxr-xr-xcharts.d/sensors.chart.sh15
1 files changed, 11 insertions, 4 deletions
diff --git a/charts.d/sensors.chart.sh b/charts.d/sensors.chart.sh
index 19e93858..9652f896 100755
--- a/charts.d/sensors.chart.sh
+++ b/charts.d/sensors.chart.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+# no need for shebang - this file is loaded from charts.d.plugin
# sensors docs
# https://www.kernel.org/doc/Documentation/hwmon/sysfs-interface
@@ -23,6 +23,8 @@ sensors_update_every=
sensors_priority=90000
+declare -A sensors_excluded=()
+
sensors_find_all_files() {
find $1 -maxdepth $sensors_sys_depth -name \*_input -o -name temp 2>/dev/null
}
@@ -47,15 +49,20 @@ sensors_check() {
sensors_check_files() {
# we only need sensors that report a non-zero value
+ # also remove not needed sensors
- local f= v=
+ local f= v= excluded=
for f in $*
do
[ ! -f "$f" ] && continue
+ for ex in ${sensors_excluded[@]}; do
+ [[ $f =~ .*$ex$ ]] && excluded='1' && break
+ done
- v="$( cat $f )"
+ [ "$excluded" != "1" ] && v="$( cat $f )" || v=0
v=$(( v + 1 - 1 ))
[ $v -ne 0 ] && echo "$f" && continue
+ excluded=
echo >&2 "$PROGRAM_NAME: sensors: $f gives zero values"
done
@@ -206,7 +213,7 @@ sensors_create() {
fi
echo "DIMENSION $fid '$labelname' $algorithm $multiplier $divisor"
- echo >>$TMP_DIR/sensors.sh "printf \"SET $fid = \"; cat $file "
+ echo >>$TMP_DIR/sensors.sh "echo \"SET $fid = \"\$(< $file )"
done
echo >>$TMP_DIR/sensors.sh "echo END"