From 34777303b5630b00f11987b68c621e4aa2b26f8f Mon Sep 17 00:00:00 2001 From: Brian Flowers Date: Tue, 1 Aug 2017 12:51:52 -0400 Subject: [PATCH] Improved buffering between fifo queues and in file processor --- bin/bdsm.sh | 12 ++++++------ etc/bdsm/monitors/DS18B20.raspi | 6 ++---- etc/bdsm/processors/file.processor | 4 ++-- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/bin/bdsm.sh b/bin/bdsm.sh index ee7e473..847937b 100755 --- a/bin/bdsm.sh +++ b/bin/bdsm.sh @@ -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 diff --git a/etc/bdsm/monitors/DS18B20.raspi b/etc/bdsm/monitors/DS18B20.raspi index 0147ff2..9be3805 100644 --- a/etc/bdsm/monitors/DS18B20.raspi +++ b/etc/bdsm/monitors/DS18B20.raspi @@ -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 } diff --git a/etc/bdsm/processors/file.processor b/etc/bdsm/processors/file.processor index fe634bd..197d51b 100755 --- a/etc/bdsm/processors/file.processor +++ b/etc/bdsm/processors/file.processor @@ -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() -- 1.8.3.1