diff --git a/snmpd-oid-daemon.sh b/snmpd-oid-daemon.sh index f72506f..15e1699 100755 --- a/snmpd-oid-daemon.sh +++ b/snmpd-oid-daemon.sh @@ -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 &$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