diff --git a/openwisp-monitoring/files/monitoring.agent b/openwisp-monitoring/files/monitoring.agent index 78457a8..1fc9e7d 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,13 @@ send_data() { break fi # send data - response_code=$($CURL_COMMAND -H "Content-Type: application/json" -d "$data" "$url") + 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