Can you redirect monit alerts to MQTT?
The work-around with exec mosquitto_pub -h .. -u .. -P .. -t .. -m .. is cumbersome.
Can you redirect monit alerts to MQTT?
The work-around with exec mosquitto_pub -h .. -u .. -P .. -t .. -m .. is cumbersome.
Copyright © 2021 Jogjafile Inc.
I see two ways:
1. Helperscript
Where you include all the config to an executable file like
/opt/monit_helper/send-mqtt.shwith yourmosquitto_pubcommand in it.So you can use
exec /opt/monit_helper/send-mqtt.sh "my cool message"or/opt/monit_helper/send-mqtt.sh "my even cooler message" "my awesome topic"(topic falls back tomonitoringif not set manually).2. Use E-Mail (and/or fake it)
Since I was not happy with only the
execoption, but wanted all the info monit is sending by e-mail I wrote a fake SMTP-Server that can handle the e-mails sent by monit and runs whatever you want it to run.You'll find it at https://github.com/boppy/nitmo.fakesmtp - It basically is just a bash script. See the
.shfile, lines 14..45 for config ideas/examples.