Are the .sh files in /etc/mender-monitor/monitor.d intended to be used in production or are they references for what you should base something else on?
When a service is okay or recovers, the message on the website still indicates an error:
When $rc is 0, it still shows:
monitor_send_alert OK "Service ${SERVICE_NAME} not running" "The main process is not present" "${SERVICE_NAME}" "running" "service"
I’m tempted to overlay this script with something that makes it sound happier like “Service running.” “Everything is running”. It doesn’t appear that the OK has anything to do with any previous issues so “resolving” a previous error isn’t the intended display, right?
It would also be a little helpful if something about what failed for systemd could be reported. The log version can send logs from around the trigger word. It seems like systemd should have an option to report something from journalctl. I modified the script for this and it seems to work. Any issues with doing this? Did I overlook configuration that does this? I only found: Configuration | Mender documentation
status_out=$(journalctl -u "$SERVICE_NAME" -n 100 --no-pager --output=cat | sed ':a;N;$!ba;s/\n/ /g' | sed 's/"/\\"/g')
monitor_send_alert \
CRITICAL \
"Service ${SERVICE_NAME} not running" \
"$status_out" \
"${SERVICE_NAME}" \
"not-running" \
"service"
;;