]> arthur.barton.de Git - netdata.git/commitdiff
add an option to exclude some sensors
authorpaulfantom <paulfantom@gmail.com>
Wed, 8 Jun 2016 10:07:28 +0000 (12:07 +0200)
committerpaulfantom <paulfantom@gmail.com>
Wed, 8 Jun 2016 10:29:07 +0000 (12:29 +0200)
charts.d/sensors.chart.sh

index 19e9385866244dcc5f485696744a81123f5eabcf..0d534b9a7ba5b415f2803e852ea07600625aaf25 100755 (executable)
@@ -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