diff options
author | paulfantom <paulfantom@gmail.com> | 2016-06-08 12:07:28 +0200 |
---|---|---|
committer | paulfantom <paulfantom@gmail.com> | 2016-06-08 12:29:07 +0200 |
commit | df6823eaa11025679c97ac6e70c789a8cdec7358 (patch) | |
tree | e24306505d0b498aec1cae3bee4bbf9987e5f344 /charts.d/sensors.chart.sh | |
parent | 66edcec61ae65303770126472798e01d3f467dc9 (diff) |
add an option to exclude some sensors
Diffstat (limited to 'charts.d/sensors.chart.sh')
-rwxr-xr-x | charts.d/sensors.chart.sh | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/charts.d/sensors.chart.sh b/charts.d/sensors.chart.sh index 19e9385866..0d534b9a7b 100755 --- a/charts.d/sensors.chart.sh +++ b/charts.d/sensors.chart.sh @@ -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,13 +49,17 @@ 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 @@ -75,6 +81,7 @@ sensors_check_temp_type() { v="$( cat $t )" v=$(( v + 1 - 1 )) [ $v -ne 0 ] && echo "$f" && continue + excluded= echo >&2 "$PROGRAM_NAME: sensors: $f is disabled" done |