1
24.1 Legacy Series / Re: Monit posting alerts to pushover with curl
« on: April 27, 2024, 06:15:50 pm »
I mostly figured this out last night and I think I found a UI bug in 23.7.10_1
When using the opnsense monit Web UI - it doesn't quote the path used in the exec statement.
Every example of exec in the Monit Manual says the path should be quoted, but the UI complains if this is attempted.
https://mmonit.com/monit/documentation/monit.html
/usr/local/etc/monitrc is overwritten by save/apply in webUI.
This will break exec statement- So make a new configuration file
/usr/local/etc/monit.opensense.d/000-customconfig.conf
Pretty sure you can put this straight in the custom config with quotes instead of using a script.
Here's the curl:
/usr/local/etc/monitpush.sh
---
addendum;
Heres the config checker
configctl monit check
The smart thing to do is run this as non-root
from manual:
When using the opnsense monit Web UI - it doesn't quote the path used in the exec statement.
Every example of exec in the Monit Manual says the path should be quoted, but the UI complains if this is attempted.
https://mmonit.com/monit/documentation/monit.html
/usr/local/etc/monitrc is overwritten by save/apply in webUI.
This will break exec statement- So make a new configuration file
/usr/local/etc/monit.opensense.d/000-customconfig.conf
Code: [Select]
check host myserver.domain.com address 8.8.8.8
if failed ping count 3 then exec "/usr/local/etc/monitpush.sh"
if failed port 443 protocol https and certificate valid > 30 days then exec "/usr/local/etc/monitpush.sh"
Pretty sure you can put this straight in the custom config with quotes instead of using a script.
Here's the curl:
/usr/local/etc/monitpush.sh
Code: [Select]
#!/bin/sh
/usr/local/bin/curl -s \
-F "token=TOKEN" \
-F "user=USERKEY" \
--form-string "title=$MONIT_HOST - $MONIT_EVENT" \
--form-string "message=$MONIT_DATE - $MONIT_DESCRIPTION" \
https://api.pushover.net/1/messages.json
---
addendum;
Heres the config checker
configctl monit check
The smart thing to do is run this as non-root
from manual:
Code: [Select]
if failed <test> then exec "/usr/local/bin/sms.sh"
as uid "nobody" and gid "nobody"
repeat every 5 cycles