]> arthur.barton.de Git - netdata.git/blobdiff - charts.d/hddtemp.chart.sh
Merge branch 'master' of https://github.com/paulfantom/netdata
[netdata.git] / charts.d / hddtemp.chart.sh
index 9677bef4bddf69ee263ff08afe20067d45fd7484..fea9f8018cb2e231cec4be326f9aefdff910a2f3 100755 (executable)
@@ -29,8 +29,8 @@ hddtemp_create() {
 
        echo "CHART hddtemp.temperature 'disks_temp' 'temperature' 'Celsius' 'Disks temperature' 'hddtemp.temp' line $((hddtemp_priority)) $hddtemp_update_every"
        for i in `seq 0 $((${#hddtemp_disks[@]}-1))`; do
-               #echo "DIMENSION ${hddtemp_disks[i]} ${disk_names[i]} absolute 1 1"
-               echo "DIMENSION ${hddtemp_disks[i]} '' absolute 1 1"
+#              echo "DIMENSION ${hddtemp_disks[i]} ${disk_names[i]} absolute 1 1"
+               echo "DIMENSION ${hddtemp_disks[$i]} '' absolute 1 1"
        done
        return 0
 }
@@ -40,13 +40,25 @@ hddtemp_last=0
 hddtemp_count=0
 hddtemp_update() {
 #        local all=( `nc $hddtemp_host $hddtemp_port | sed -e 's/||/\n/g;s/^|//' | cut -d '|' -f3` )
-       local all=( `nc $hddtemp_host $hddtemp_port | awk 'BEGIN { FS="|" };{i=4; while (i <= NF) {print $i+0;i+=5;};}'` )
+#      local all=( `nc $hddtemp_host $hddtemp_port | awk 'BEGIN { FS="|" };{i=4; while (i <= NF) {print $i+0;i+=5;};}'` )
+       OLD_IFS=$IFS
+       set -f
+       IFS="|" all=( $(nc $hddtemp_host $hddtemp_port 2>/dev/null) )
+       set +f
+       IFS=$OLD_IFS
+
+       # check if there is some data
+       if [ -z "${all[3]}" ]; then 
+               return 1
+       fi
 
        # write the result of the work.
        echo "BEGIN hddtemp.temperature $1"
        end=${#hddtemp_disks[@]}
        for ((i=0; i<end; i++)); do
-               echo "SET ${hddtemp_disks[$i]} = ${all[$i]}"
+               # temperature - this will turn SLP to zero
+                t=$(( ${all[ $((i * 5 + 3)) ]} ))
+               echo "SET ${hddtemp_disks[$i]} = $t"
        done
        echo "END"