Knowledge Base

Checking registered SIP peers

We got a call recently from a customer who uses skype trunks for some international incoming numbers. We have found that these lose registration on a regular basis, We could let them be set try and register indefinitely but this can have performance effects on the server.

This is not our only customer with this problem, We have also of late noticed a similar problem with Voip-unlimited where registration times out every day at 8pm, we have noted this on ours and other dealers servers.

So what to do?

Well we have written a quick script to check registration details and reload if not correct.


HITS=`asterisk -r -x “sip show registry” | grep Registered |grep $1| wc -l`

if [ $HITS != $2 ]; then

echo “Incorrect number of $1 trunks are registered, we wanted $2  ”

echo “We will now reload asterisk ”

asterisk -r -x “reload”

exit 0


echo “$HITS $1 trunks are registered, we wanted $2  ALL OK”

exit 0



the syntax for running the script is hostname 2

with hostname being part of the string you get when doing a sip show registry.

and the number is the number of registered trunks you expect with that name.

if all is well:”2 sipgate trunks are registered, we wanted 2 :-) ALL OK”and nothing happens

if not correct number then:

“Incorrect number of sipgate trunks are registered, we wanted 2

“We will now reload asterisk”

we only relaod the sip channel driver as this is enough to sort the problem normally