Setting alarms in DAHDI

hello,
This is an unusual request, I have seven servers running with Asterisk, no in the same place, I need to set up an alarm that sends me an email telling me that the command asterisk -rx “dahdi show status” y giving back a RED alarm.
this is the script I’ve made to do that:

ALERT=$(asterisk -rx “dahdi show status” | grep RED)
echo .$ALERT.
if [ “$ALERT” ]; then
echo .E1 is down. |mail -s E1 is down MYEMAIL@MYdomain.com
fi

ALERT=$(asterisk -rx “dahdi show status” |grep YELLOW)
echo .$ALERT.
if [ “$ALERT” ]; then
echo .Yellow alarm. |mail -s Warning MYEMAIL@MYdomain.com
fi
ALERT=$(asterisk -rx “dahdi show status” |grep ALARM |grep OK)
echo .$ALERT.
if [ “$ALERT”]; then
echo .E1 is OK . |mail -s it’s fine MYEMAIL@MYdomain.com
fi

but it doesen’t work,
can you help me?
excuse for my bad english, it’s not my native language.

regards,
lucas

If you are trying to know what channels are in RED alarm try with:

state=$(lsdahdi | awk ‘{ print "channel: "$1 " State: " $10 }’ | grep RED)
echo $state | mail -s red channels youremail.

Hi

If you are looking after servers in various locations you should look at nagios or similar. This can then keep an eye on the and raise alarms for you with email, sms, etc notitifications

ok, thanks, I will try both.
regards