In this tutorial Im going to show you how to monitor the uptime of a FreePBX server using Uptime Kuma. Uptime Kuma is an easy-to-use self-hosted monitoring tool. This lets you recieve notifications whenever a server goes offline so you can keep a close eye on your FreePBX servers.
We will need a few things before we get started:
- A FreePBX server (any version will work)
- A hosted version of Uptime Kuma (I use a service called PikaPods that is extremally affordable).
That’s it, now lets get started!
Add A New Monitor In Uptime Kuma
Lets head to Uptime Kuma first and add our FreePBX monitor.
In the “Add New Monitor” settings fill in the following:
Monitor Type : Push
Friendly Name : Whatever name you like for this server.
Push URL : Copy and paste this for later. We will need this for FreePBX settings.
Heartbeat Interval : 120 ( I found 120 seconds to be the best time for FreePBX to not give false positives).
*Don’t push “SAVE” just yet.
FreePBX Settings
Time to set the FreePBX settings. We will use an SSH program to log into our FreePBX server. You can use Putty or I prefer a program called Termius.
We need to create a file called uptimekumacheck.sh. To do this use the following command:
nano /root/uptimekumacheck.sh
With the Nano editor open we need to add the following code:
curl -s 'http://WEBaddressHERE'
Replace “http://WEBaddressHERE” with the web address we copied from Uptime Kuma labeled “Push URL”. Your code should look something like this:
curl -s 'https://status.fusionit.net/api/push/vrz9qCOEjX?status=up&msg=OK&ping='
Now save the file by pressing ctrl + O and then exit by pressing ctrl + X
Next we want to tell CRON to run the script we just created. Do this with the following:
nano /etc/ crontab
In the Nano editor paste the following:
* * * * * root /root/uptimekumacheck.sh > /dev/null 2>&1
Again, save and exit by using ctrl + O to save and ctrl + X to exit.
Lastly we need to give the file uptimekumacheck.sh the correct permissions to run. To do this run the following command:
chmod 755 ~/uptimekumacheck.sh
*Now don’t forget to go back to Uptime Kuma and hit “SAVE” for your new monitor.
That’s it! Give it a few minutes and you should see your FreePBX server is up!