send data and ENDOFDATA to main depending on rc and data availability
This commit is contained in:
@@ -219,7 +219,6 @@ function submit_oids() {
|
||||
echo -n "UPDATE "
|
||||
declare -p oids | strip_declaration
|
||||
fi
|
||||
echo ENDOFDATA
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -575,21 +574,15 @@ while :; do
|
||||
((next_update+=delay))
|
||||
timetable[$func]=$next_update
|
||||
$first_run && echo "starting $func (refresh every $delay seconds)" >&$LOG
|
||||
echo "gathering: executing $func"
|
||||
data=$($func)
|
||||
echo "gathering: executing $func" >&$DEBUGLOG
|
||||
data=$($func </dev/null)
|
||||
rc=$?
|
||||
echo "gathering: $func exited (rc=$rc), schedule next refresh at $(date -d @$next_update)" >&$DEBUGLOG
|
||||
# pipe gathered data to main
|
||||
while read -r line; do
|
||||
echo "gathering: received: $line"
|
||||
last_line=$line
|
||||
done <<< "$data"
|
||||
if [ "$last_line" != "ENDOFDATA" ]; then
|
||||
echo "gathering: $func did not return ENDOFDATA, skipping data" >&2
|
||||
continue
|
||||
if (( rc == 0 )) && [ -n "$data" ]; then
|
||||
echo "gathering: sending data to main" >&$DEBUGLOG
|
||||
echo "$data" 1>&$DATAIN
|
||||
echo "ENDOFDATA" >&$DATAIN
|
||||
fi
|
||||
echo "gathering: sending data update to main"
|
||||
echo "$data" >&$DATAIN
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
Reference in New Issue
Block a user