Check E1 Status Alert By Dial & Email


#!/bin/bash
#Create : by mustafa@intelix.co.id
#Date : 2012-08-10 06:00:00

PATH_LOG=”/home/ecentrix/log/e1″

LOG_FILE=”${PATH_LOG}/tmp_$(date +%Y%m%d-%H%M).log”

LOG_DETAIL=”${PATH_LOG}/e1_$(date +%Y%m%d).log”

mkdir -p “${PATH_LOG}”

msgLog(){
LOG_FORMAT=”$( date +’%H:%M:%S’)”
echo $LOG_FORMAT “$1” >> $LOG_FILE
echo $LOG_FORMAT “$1” >> $LOG_DETAIL
}

> $LOG_FILE
>> $LOG_DETAIL

SPANS=$(asterisk -rnx “pri show spans” | grep -a PRI | awk ‘{print $3;}’ | cut -d”/” -f1)
for i in $SPANS; do
STATUS_PRI=$(asterisk -rnx “pri show span $i” | grep -a Status | awk ‘{print $3;}’ | cut -d, -f1)
if [ “${STATUS_PRI}” != “Up” ]; then
msgLog “PRI span $i DOWN”
fi

STATUS_DAHDI=$(asterisk -rnx “dahdi show status” | grep “Span $i” | awk ‘{print $7}’)
if [ “${STATUS_DAHDI}” != “OK” ]; then
msgLog “DAHDI span $i ALARM”
fi
done

CL=$(egrep -i “DOWN|ALARM” ${LOG_FILE} | wc -l)
if [ “${CL}” -gt 0 ]; then

(sleep 1; echo -e “root\r”; sleep 1; echo -e “xmoses\r”; sleep 1; echo -e “line -release 0 1 2 3 4 5 6 7\r”; sleep 1; echo -e “exit\r”) | telnet 10.24.17.45

//call to 0812XXXX

//alert to email

fi

fi

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

shisdew

Listens until think alike

moses.spaceku@yahoo.com / voip ipbx

Hosted PBX, IP-PBX SOHO/ CALL CENTER, VOICE GATEWAY, VOICE CARD, COST EFECTIVE SOLUTIONS (LCR), GSM/CDMA GATEWAY

%d bloggers like this: