]> arthur.barton.de Git - netdata.git/blobdiff - charts.d/hddtemp.chart.sh
Merge pull request #687 from ktsaou/master
[netdata.git] / charts.d / hddtemp.chart.sh
index 704ab9d02b37ae7cccf2934a33149d032f1586fd..41c3e2478092a7df949fe8cb0c8ca353e0abe00b 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+# no need for shebang - this file is loaded from charts.d.plugin
 
 # if this chart is called X.chart.sh, then all functions and global variables
 # must start with X_
@@ -41,9 +41,16 @@ 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;};}'` )
+       OLD_IFS=$IFS
        set -f
-       IFS="|" all=( $(nc $hddtemp_host $hddtemp_port) )
+       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"