From f7d26f821ed7c5324d0842968b24bfaff44ad782 Mon Sep 17 00:00:00 2001 From: Daniel Santos Date: Tue, 27 May 2025 02:23:11 -0500 Subject: [PATCH 1/2] Fix cmd line too long --- openwisp-monitoring/files/monitoring.agent | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/openwisp-monitoring/files/monitoring.agent b/openwisp-monitoring/files/monitoring.agent index bb52765..5d311eb 100755 --- a/openwisp-monitoring/files/monitoring.agent +++ b/openwisp-monitoring/files/monitoring.agent @@ -151,9 +151,7 @@ send_data() { fi filename="$TMP_DIR/$filename" # check if the data file exist - if [ -f "$filename" ]; then - data=$(cat "$filename") - else + if ! [ -f "$filename" ]; then [ "$VERBOSE_MODE" -eq "1" ] && logger -s "data file $filename not found." \ -p daemon.info continue @@ -176,7 +174,7 @@ send_data() { break fi # send data - response_code=$($CURL_COMMAND -H "Content-Type: application/json" -d "$data" "$url") + response_code=$($CURL_COMMAND -H "Content-Type: application/json" -d "@$filename" "$url") if [ "$response_code" = "200" ]; then success=$((success + 1)) if [ "$VERBOSE_MODE" -eq "1" ]; then From d2a37c8298d252f31e358a85df187579ccfd241c Mon Sep 17 00:00:00 2001 From: Daniel Santos Date: Tue, 27 May 2025 17:46:09 -0500 Subject: [PATCH 2/2] Dump curl data and command line in verbose_mode --- openwisp-monitoring/files/monitoring.agent | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/openwisp-monitoring/files/monitoring.agent b/openwisp-monitoring/files/monitoring.agent index 5d311eb..4c0718e 100755 --- a/openwisp-monitoring/files/monitoring.agent +++ b/openwisp-monitoring/files/monitoring.agent @@ -174,7 +174,13 @@ send_data() { break fi # send data + if [ "$VERBOSE_MODE" -eq "1" ]; then + printf "data=" + cat "$filename" + set -x + fi response_code=$($CURL_COMMAND -H "Content-Type: application/json" -d "@$filename" "$url") + set +x if [ "$response_code" = "200" ]; then success=$((success + 1)) if [ "$VERBOSE_MODE" -eq "1" ]; then