]> arthur.barton.de Git - netdata.git/commitdiff
fallback if /proc/uptime is not there or cannot be read
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Mon, 12 Sep 2016 20:54:53 +0000 (23:54 +0300)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Mon, 12 Sep 2016 20:54:53 +0000 (23:54 +0300)
plugins.d/loopsleepms.sh.inc

index 2a81152ea8af3fd0513ed0807c0e8c9321136c67..3112d033574b552dcbe992a22ccc4f353a1184c4 100644 (file)
@@ -32,6 +32,15 @@ current_time_ms_from_uptime() {
     local up rest arr n
 
     read up rest </proc/uptime
+    if [ $? -ne 0 ]
+        then
+        echo >&2 "$0: Cannot read /proc/uptime - falling back to current_time_ms_from_date()."
+        current_time_ms="current_time_ms_from_date"
+        current_time_ms_from_date
+        current_time_ms_accuracy=1
+        return
+    fi
+
     arr=(${up//./ })
 
     if [ ${#arr[1]} -lt 1 ]