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