Fixing pid logging in df/sensors plugins
authorBrian Flowers <git-admn@bsflowers.net>
Tue, 20 Sep 2016 05:18:54 +0000 (01:18 -0400)
committerBrian Flowers <git-admn@bsflowers.net>
Tue, 20 Sep 2016 05:18:54 +0000 (01:18 -0400)
bdsm.d/df.generic
bdsm.d/sensors.generic

index a3a0af7..cec9da9 100755 (executable)
@@ -65,20 +65,15 @@ start()
       return 1
     fi
 
-    ssh -qn $HOSTNAME <<EOF
+    ssh -q $HOSTNAME <<EOF
     while [ 1 ]; do
       df=`df --output=pcent "$DRIVE" | tail -1 | sed 's/[^0-9]//g'`
       ts=`date '+%s'`
-      stdbuf -o0 echo "\$ts|$HOSTNAME|DISK-$LABEL-USED|\$df" >> $OUTPATH
+      stdbuf -o0 echo "\$ts|$HOSTNAME|DISK-$LABEL-USED|\$df"
       sleep $DELAY
-    done &
+    done >> $OUTPATH &
+    echo \$! >/home/bdsm/.df.pid
 EOF
-    ssh -q $HOSTNAME "ps aux | \
-                  grep bdsm | \
-                  grep df | \
-                  grep -v grep | \
-                  awk '{print \$2}' \
-                  > /home/bdsm/.df.pid &"
   else
     echo "Already Running"
   fi
index f50e663..6dd9ef1 100755 (executable)
@@ -61,7 +61,7 @@ start()
       return 1
     fi
 
-    ssh -qn $HOSTNAME <<EOF
+    ssh -q $HOSTNAME <<EOF
     while [ 1 ]; do
       ts=`date '+%s'`
       stdbuf -o0 sensors | \
@@ -83,14 +83,9 @@ start()
       } line=line+1
     }' | tr ':' '|'
     sleep $DELAY
-    done &
+    done >> $OUTPATH &
+    echo \$! > /home/bdsm/.sensors.pid
 EOF
-    ssh -q $HOSTNAME "ps aux | \
-                  grep bdsm | \
-                  grep sensors | \
-                  grep -v grep | \
-                  awk '{print \$2}' \
-                  > /home/bdsm/.sensors.pid &"
   else
     echo "Already Running"
   fi