How to monitor MikoPBX if you don’t have Zabbix

MikoPBX is an incredibly stable and minimal implementation of Asterisk. None of the bloatware you’ll get with FreePBX and all the other variants, rather just a solid and secure Asterisk server that just works.

MikoPBX is very secure so you can’t just load SNMP if you want to monitor it.

Thankfully the developers of MikoPBX supplies an easy to follow Zabbix file. But what to do if you don’t have Zabbix? With some clever (ChatGPT) scripting and using the information gleaned from the Zabbix implementation, we can get quite far. Without further adieu, here is the script:


# Prepare data for PRTG in this format [4]
echo "[`asterisk -rx "core show hints" | grep "State:Unavailable" | wc -l`]" > offline_count.txt

# Prepare a file that will contain a list of all the offline extensions
# To make this script work, you'll need a extensions.txt file in this format:
# 201,Joe_Bloggs
# 202,Pete_Smith

asterisk -rx "core show hints" | grep "State:Unavailable" | awk -F@ '{print $1}' | sort -n > offline_extensions.txt

# Assuming offline_extensions.txt contains the sorted extension numbers without @internal-hints
# And extensions.txt contains the extension,name pairs

echo "$(date '+%Y-%m-%d %H:%M:%S')" > offline
echo "===================" >> offline
while IFS= read -r line; do
# Use grep to find the line in extensions.txt and then cut to extract the name
name=$(grep "^$line," extensions.txt | cut -d',' -f2)
if [ ! -z "$name" ]; then
echo "$line,$name"
echo "$line,Name not found"
done < offline_extensions.txt >> offline

# Since MikoPBX doesn't have an FTP client, you have to 
# create a new dynamic mount point which connects to a public FTP server
#/usr/bin/curlftpfs -o allow_other -o [email protected]:secret, /storage/usbdisk1/mikopbx/custom_modules/zabbix/scripts/files/
# Note: secret must be your FTP secret and the files directory must be empty when you run this command the first time

# Next, even though it appears you are creating files in the storage directory, they are actually
# written by the CRON to the /root directory!
cp /root/offline* /storage/usbdisk1/mikopbx/custom_modules/zabbix/scripts/files

Remember to add the CRON to System / system file customization


You’ll end up with something like this:

The file offline_count.txt can easily be linked to PRTG for further monitoring using an HTTP Content Integer sensor.


See also

Share this article

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top