Improved buffering between fifo queues and in file processor
authorBrian Flowers <git-admn@bsflowers.net>
Tue, 1 Aug 2017 16:51:52 +0000 (12:51 -0400)
committerBrian Flowers <git-admn@bsflowers.net>
Tue, 1 Aug 2017 16:51:52 +0000 (12:51 -0400)
bin/bdsm.sh
etc/bdsm/monitors/DS18B20.raspi
etc/bdsm/processors/file.processor

index ee7e473..847937b 100755 (executable)
@@ -200,7 +200,7 @@ start()
     info "Starting $type monitors on $host..."
     functions=`cat $config_path/.bdsm.conf.tmp | grep "$type:$host" | sed 's/.*{\(.*\)}.*/\1/'`
         
-    ssh -q $host "cat /home/bdsm/out.fifo" > /home/bdsm/in.fifo &
+    ssh -q $host "stdbuf -oL cat /home/bdsm/out.fifo" > /home/bdsm/in.fifo &
     echo $! > /home/bdsm/pids/$host.in
 
 
@@ -213,7 +213,7 @@ start()
       args="`echo $line | cut -d' ' -f2-`"
       if [ -f $config_path/monitors/$command.$type ]; then
         $config_path/monitors/$command.$type start $host $args
-      elif [ -f $config_path/monitors/$command.$type ]; then
+      elif [ -f $config_path/monitors/$command.generic ]; then
         $config_path/monitors/$command.generic start $host $args
       else
         error "Could not find plugin for $command on $type:$host!"
@@ -242,7 +242,7 @@ stop()
       args="`echo $line | cut -d' ' -f2-`"
       if [ -f $config_path/monitors/$command.$type ]; then
         $config_path/monitors/$command.$type stop $host $args
-      elif [ -f $config_path/monitors/$command.$type ]; then
+      elif [ -f $config_path/monitors/$command.generic ]; then
         $config_path/monitors/$command.generic stop $host $args
       else
         error "Could not find plugin for $command on $type:$host!"
@@ -281,7 +281,7 @@ status()
       prefix="$type:$host|$command|"
       if [ -f $config_path/monitors/$command.$type ]; then
         $config_path/monitors/$command.$type status $host | sed "s/^/$prefix/g"
-      elif [ -f $config_path/monitors/$command.$type ]; then
+      elif [ -f $config_path/monitors/$command.generic ]; then
         $config_path/monitors/$command.generic status $host | sed "s/^/$prefix/g"
       else
         error "Could not find plugin for $command on $type:$host!"
@@ -473,8 +473,8 @@ deploy()
     i=`expr $i + 1`
   done
 
-  mkfifo /home/bdsm/in.fifo
-  mkdir /home/bdsm/pids
+  mkfifo /home/bdsm/in.fifo 2>/dev/null
+  mkdir /home/bdsm/pids 2>/dev/null
 }
 
 # SCRIPT START
index 0147ff2..9be3805 100644 (file)
@@ -32,7 +32,6 @@ error()
 SCRIPT=$0
 HOSTNAME=$2
 DELAY=$3
-SENSOR-ID="${4}"
 OUTPATH=/home/bdsm/out.fifo
 
 # MAIN FUNCTIONS
@@ -44,7 +43,6 @@ help()
   echo "FUNCTION -- start/stop/status/help"
   echo "HOSTNAME -- the hostname to monitor"
   echo "::DELAY  -- seconds between measurements"
-  echo "::SENSOR-ID -- the serial number of the sensor to read"
   exit 0
 }
 
@@ -107,9 +105,9 @@ compatible()
 {
   compatible="`ssh -q -n $HOSTNAME 'cat /sys/bus/w1/devices/w1_bus_master1/w1_master_slaves | grep \"^28\" | wc -l' 2>/dev/null`"
   if [ "$compatible" -gt 0 ]; then
-    echo 0
-  else
     echo 1
+  else
+    echo 0
   fi
 }
 
index fe634bd..197d51b 100755 (executable)
@@ -41,7 +41,7 @@ help()
 
 start()
 {
-  cat /home/bdsm/in.fifo | grep '.*|.*|.*|.*' --line-buffered >> /home/bdsm/bdsm.out &
+  cat /home/bdsm/in.fifo | grep '[0-9]*|.*|.*|.*' --line-buffered >> /home/bdsm/bdsm.out &
   echo $! > /home/bdsm/pids/file.processor.pid
   
   # Check if it failed to write the pid...
@@ -54,7 +54,7 @@ start()
     error "File processor was unable to start."
     return 1
   fi  
-  nohhup logrotation &
+  nohup logrotation &
 }
 
 stop()