Monitoring DAHDI channels on an Asterisk system with Xymon
With the severe thunderstorms and tornado warnings we have been recently subjected to, we inevitably end up having problems with the POTS lines connected to our Asterisk system. The problems have been due to either a physical issue between our office and the CO which the phone company has to repair, or a simple issue of forgetting to plug the POTS lines back into the analog card once the storms had passed.
The up side to this is that we have a very quiet morning with no ringing phones the day after a major storm, however the reality is that we may be missing important phone calls from our clients!
Here you will find the most current versions of our:
- Instructions on monitoring and alerting on the status of POTS lines in an Analog FXO/FXS card in an Asterisk VoIP system
- xymon_asterisk_dahdi.sh - The Xymon script file
We have also written several other scripts that you may find useful. You may find them HERE
Detecting alarms on DAHDI channels on our FXS/FXO Analog card
The Asterisk system logs "RED alarms" to the log files when a configured line is disconnected:
[Jun 1 10:10:45] WARNING chan_dahdi.c: Detected alarm on channel 4: Red Alarm
And an "Alarm cleared" once the line is plugged back in:
[Jun 1 10:10:46] NOTICE chan_dahdi.c: Alarm cleared on channel 4
These two conditions are easily grepped for in the log file, but the log file is very noisy on an active system with several VoIP phones and 4 POTS lines so I looked for other methods of accurately detecting these conditions.
The first method that looked promising, was to use the Asterisk command:
"dahdi show channel x"
in a script like so:
asterisk -rx "dahdi show channel 1"
which would return the following information:
Channel: 1 File Descriptor: 16 Span: 1 Extension: Dialing: no Context: from-zaptel Caller ID: Calling TON: 0 Caller ID name: Mailbox: none Destroy: 0 InAlarm: 0 Signalling Type: FXS Kewlstart Radio: 0 Owner:
Real: Callwait: Threeway: Confno: -1 Propagated Conference: -1 Real in conference: 0 DSP: no Busy Detection: no TDD: no Relax DTMF: no Dialing/CallwaitCAS: 0/0 Default law: ulaw Fax Handled: no Pulse phone: no DND: no Echo Cancellation: 1 taps (unless TDM bridged) currently OFF Wait for dialtone: 0ms Actual Confinfo: Num/0, Mode/0x0000 Actual Confmute: No Hookstate (FXS only): Offhook
The only item in that out output that I was interested in is the InAlarm: line which shows 0 for No Alarm, and 1 when the POTS line is unplugged, or no voltage from the CO is detected.
This method is simple enough, but would require the script to be manually configured ahead of time with the correct number of channels to monitor on the card because the
"dahdi show channel" command requires the channel number as the last parameter and does not print out the status of all channels when no parameter is given. Not a big deal, but worth mentioning.
While asking about the best way to determine the status of the POTS lines on an analog card in freenode's #asterisk channel, and mentioning the method above that I had just found, igcewieling provided me with a much better answer:
Which provides an output that includes the status of all the channels on card 1 at the same time, and is easily parsed:
Span 1: WCTDM/0 "Wildcard TDM410P Board 1" (MASTER) 1 WCTDM/0/0 FXSKS (In use) 2 WCTDM/0/1 FXSKS (In use) (SWEC: MG2) 3 WCTDM/0/2 FXSKS (In use) 4 WCTDM/0/3 FXSKS (In use) RED(SWEC: MG2)
Channel 4 on this card is unplugged and the output shows a RED alarm on it.
If a system has multiple cards in it, a simple loop through each directory under /proc/dahdi is all that is required in the script to obtain the status of all analog channels in the system.
This is what the Xymon status page would look like for the DAHDI test using the script below: