add debug log for partial received lines

This commit is contained in:
2024-09-30 13:29:07 +02:00
parent 8af91ec36a
commit 95c8c276ac

View File

@@ -446,7 +446,7 @@ function return_oid() {
# Main logic of the daemon. # Main logic of the daemon.
# #
function main() { function main() {
local cmd line oid req next local buf line cmd oid req next
local -a args local -a args
echo "waiting for all data gathering functions to return data" >&$LOG echo "waiting for all data gathering functions to return data" >&$LOG
@@ -458,29 +458,31 @@ function main() {
update_oid_cache update_oid_cache
done done
read -r -t 1 -u $STDIN buf read -r -t 1 -u $STDIN buf
local rc=$? rc=$?
if (( rc > 128 )); then if (( rc > 128 )); then
line+=$buf line+=$buf
echo "< $buf (partial line: '$line')" >&$DEBUGLOG
continue continue
elif (( rc == 0 )); then elif (( rc == 0 )); then
line+=$buf line+=$buf
echo "< $line" >&$DEBUGLOG
else else
exit 255 exit 255
fi fi
echo "< $line" >&$DEBUGLOG
if [ -z $cmd ]; then if [ -z $cmd ]; then
cmd=$line cmd=$line
args=() args=()
elif [ -z $line ]; then elif [ -z $line ]; then
cmd="" cmd=""
args=() args=()
line=""
snmp_echo NONE snmp_echo NONE
continue continue
else else
args+=("$line") args+=("$line")
fi fi
line="" line=""
case "${cmd,,}" in case "${cmd,,}" in
ping) ping)
cmd="" cmd=""