💾 Archived View for gemini.ctrl-c.club › ~nristen › gemlog › 20210819.gmi captured on 2022-04-29 at 12:23:44. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2021-12-03)

-=-=-=-=-=-=-

Nristen's (g)log
2021-08-19

Monit notifications through XMPP

For my personal equipment (servers, routers, etc) I currently use monit to monitor if devices go down or if ports stop responding. I like monit because it does not use very many system resources.

Monit by default sends alerts through email so the problem I had was I would only get outage notifications when I checked my email. I have gotten into the habit of checking my email accounts daily and as such, I have removed the notifications from my computer and phone... This results in a much more peaceful day with much less distrations to take away from my focus. Since I have my own XMPP server now, I thought it would be a perfect option for getting outage notifications to me.

I found a small command line package for send XMPP messages: sendxmpp which was available through the package manager on the raspberry pi I was using for this.

Monit Config:

check host pi-hole address 192.168.1.147
    if failed 
      port 80 protocol http 
      for 3 cycles
	then exec /usr/local/bin/monit-xmpp
	if failed
		port 53 protocol dns
		for 3 cycles
	then exec /usr/local/bin/monit-xmpp

My script at /usr/local/bin/monit-xmpp:

#!/bin/bash

echo -e "$MONIT_HOST\nService: $MONIT_SERVICE\nAlert: $MONIT_DESCRIPTION" | sendxmpp -f /root/.sendxmpprc -t myxmppaddress@xmppserver.net

A couple notes regarding the above bash script which runs the sendxmpp command.

So far this is working very well for me.

References

https://mmonit.com/monit/

https://sendxmpp.hostname.sk/

--------

Nristen (g)log index

Nristen Home