Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[change] Stop sending data on repeated 404 responses #105 #130

Merged
merged 1 commit into from
May 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions openwisp-monitoring/files/monitoring.agent
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,20 @@ send_data() {
[ "$VERBOSE_MODE" -eq "1" ] && logger -s "Data not sent successfully. Retrying in $timeout seconds." \
-p daemon.warn
failures=$((failures + 1))
if [ "$response_code" = "404" ]; then
# If we get a HTTP 404 response, it could mean that the device has been deleted from OpenWISP
# Controller. We check if openwisp-config agent is running to determine if the device has been
# deleted. If openwisp-config agent is not running, the monitoring agent will also exit.
if ! pgrep -x "openwisp_config" >/dev/null; then
logger -s "Giving up and shutting down: the device may have been deleted from OpenWISP Controller" \
-t openwisp-monitoring \
-p daemon.err
# get process id of the process collecting data
pid=$(pgrep -f "openwisp-monitoring.*--mode collect")
kill -SIGKILL "$pid"
exit 2
fi
fi
sleep "$timeout"
fi
done
Expand Down
Loading