Uptime

Frequent testing to ensure uptime

Monitor.chat allows for one message every 2 minutes from a given host. If you need to test that services are up once per minute, it can still be done. Here are some tips for doing it:

  • Create a script that runs from cron every minute, but only notifies you of failures.
  • If you have multiple servers, have one server check on another server to ensure that services are running.

Here is a script that will only report on a problem. It would be safe to run this every minute from cron.

#!/bin/bash
. /etc/profile
. /root/.profile

sleep $((1 + $RANDOM %15))

# CHECK ON MY WEBSITE. LISTENING ON 443?
if nc -zw1 mywebsite.com 443; then
   echo "Apache2 is listening."
else
   /usr/local/bin/monitor.chat.sh '<BOOM> THERE IS A PROBLEM WITH THE WEBSITE!' "all"
   echo "Apache2 is not listening!"
fi

# CHECK ON MY DATABASE. LISTENING ON 3306?
if nc -zw1 192.168.0.99 3306; then
   echo "Database is listening."
else
   /usr/local/bin/monitor.chat.sh '<BOOM> THERE IS A PROBLEM WITH THE DATABASE!' "all"
   echo "MariaDB is not listening!"
fi

# CHECK ON MY PROSODY. LISTENING ON 5222?
if nc -zw1 myxmppserver.com 5222; then
   echo "Prosody is listening."
else
   /usr/local/bin/monitor.chat.sh '<BOOM> THERE IS A PROBLEM WITH THE XMPP SERVER!' "all"
   echo "Prosody is not listening!"
fi

With this script, a message is sent only when there is a problem.

Last modified December 1, 2020