Skip to content

How to monitor Asterisk trunks with PRTG

Last updated on May 14, 2020

A trunk is a single physical connection that can carry multiple VLANs. Each frame that crosses the trunk has a VLAN identifier attached to it, so it can be identified and kept within the correct VLAN.

Trunks can be used between two switches, between a switch and a router or between a switch and a computer that supports trunking. When connecting to a router or computer, each VLAN appears as a separate virtual interface.

When using trunks, it is important to consider that all the VLANs carried over the trunk share the same bandwidth. If the trunk is running over a 100Mbps interface, for example, the combined bandwidth of all the VLANs crossing that trunk is limited to 100Mbps.

Create shell script

touch /var/prtg/scripts/trunk.sh

Add the content to the script

#!/bin/bash
serviceIsRunning=false
status=$(/usr/sbin/asterisk -rx "sip show peers" |grep trunk_name |awk '{print $6}')
if [ "$status" == OK ]
then
serviceIsRunning=true
echo "0:200:$status"
fi
if [ $serviceIsRunning == false ]
then
echo "2:404:$status"
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

Normal response will be “200 OK”
If it is down, you will get “404 Unreachable” error

! 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

And here’s the result:

Published inAsteriskLinuxScriptShell

Be First to Comment

Leave a Reply