Asterisk Registry Monitor
#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
export DISPLAY=:0.0
declare -a trunks=('17772651651' 'SMD829235398' '0282091985' '17772709540');
for i in ${trunks[@]}; do
reg_status=`asterisk -x " sip show registry" | grep -i ${i} | awk '{print $5}'`
if [ "${reg_status}" != "Registered" ]; then
alert=`echo "Server ${i} is not registered since $(date)" | mail -s "red alert for server ${i} not registered" ambiorixg12@gmail.com `
echo ${i} is ${reg_status} $(date) >> /root/noreg.log
else
echo ${i} is ${reg_status} $(date) >> /root/reg.log
alert=`echo "Server ${i} is registered since $(date)" | mail -s "green alert for server ${i} registered " ambiorixg12@gmail.com `
fi
done
exit 0
Lineas cronjob
El primer cron corre el scrip cada 3 minutes el segundo borra el log diario 5 minutos despues de la media noche
*/3 * * * * /root/monitor.sh
5 0 * * * /bin/echo > /root/reg.log
0 comentarios:
Publicar un comentario
Suscribirse a Enviar comentarios [Atom]
<< Inicio