How to monitor Asterisk trunks with PRTG

Create shell script

touch trunk.sh

Add the content to the script

#!/bin/bash
serviceIsRunning=false
var1=$(/usr/sbin/asterisk -rx "sip show peers" |grep trunk_name |awk '{print $6}'| sed 2,2d)
var2=$(echo $data | awk '{print $2}')
if [ "$var1" == OK ]
then
serviceIsRunning=true
echo "0:200:running"
fi
if [ $serviceIsRunning == false ]
then
echo "2:404:UNREACHABLE"
fi

Save the script and make it executable

chmod +x trunk.sh

Try to run it

./trunk.sh

Go to the PRTG, and add the SSH Script sensor to the device

In the «Script» field choose trunk.sh and SAVE

! Make sure your PRTG Server has access to Asterisk Server, if not, add root username and password
to the credentials in the BASIC DEVICE SETTINGS

Screenshot from 2016-05-31 18-10-05

About the Author

Leave a Reply