Monitoring SIP trunks

You can’t “telnet” a UDP port, if you use UDP5060 or UDP4569. As suggested, you can script something to run every n times and you can use nmap, e.g.

nmap -sU -p5060 and if the output is good, do something, if not, do something else, like throw it into syslog, email…

Alternatively, instead of running nmap, you could “ask” asterisk the status of the port everyone once in a while, e.g.

asterisk -rx "sip show peer " | grep Status

That should show something like this below;
Status : OK (6 ms)

Example bash script:- quick and dirty one :slight_smile:

#!/bin/bash
peername=MYTELCO
runtest=/usr/sbin/asterisk -rx "sip show peer $peername" | grep Status | grep OK

if [[ “$?” -ne “0” ]]; then
echo "Not good, do something"
else
echo "Good, do nothing"
fi

Hope this helps

1 Like