#!/bin/bash from="PIAF@pbx.local" email="yourname@somegoodhost.com" # Don't mess with stuff below here test=`asterisk -rx "sip show registry" | grep "Auth"` if [[ $test ]]; then test2=`echo -e "Trunk off line:\n$test"` echo $test2 | mail -r $from -s "SIP Trunk Failure" $email iptables-restart # echo -e "Trunk off line:\n$test" fi test=`asterisk -rx "iax2 show registry" | grep "Reje"` if [[ $test ]]; then test2=`echo -e "Trunk off line:\n$test"` echo $test2 | mail -r $from -s "IAX2 Trunk Failure" $email # echo -e "Trunk off line:\n$test" fi astversion=`asterisk -rx "core show version" | grep -m 2 ^ | tail -1 | cut -f 2 -d " "` if [ "${astversion:0:2}" != "11" ]; then test3=`asterisk -rx "jabber show connections"` else test3=`asterisk -rx "xmpp show connections"` fi test=`echo "$test3" | grep "Authen"` if [[ $test ]]; then test2=`echo -e "Trunk off line:\n$test"` echo $test2 | mail -r $from -s "Google Trunk Failure" $email # echo -e "Trunk off line:\n$test" fi test=`echo "$test3" | grep "Disconn"` if [[ $test ]]; then test2=`echo -e "Trunk off line:\n$test"` echo $test2 | mail -r $from -s "Google Trunk Failure" $email # echo -e "Trunk off line:\n$test" fi test=`echo "$test3" | grep "Reques"` if [[ $test ]]; then test2=`echo -e "Trunk off line:\n$test"` echo $test2 | mail -r $from -s "Google Trunk Failure" $email # echo -e "Trunk off line:\n$test" fi test=`echo "$test3" | grep "Waitin"` if [[ $test ]]; then test2=`echo -e "Trunk off line:\n$test"` echo $test2 | mail -r $from -s "Google Trunk Failure" $email # echo -e "Trunk off line:\n$test" fi # end of trunkcheck script