#!/bin/bash # # NAME # ---- # - xymon_asterisk_dahdi.sh # # DESCRIPTION # ----------- # - Script to monitor Digium Asterisk Hardware Device Interface (DAHDI) # channels on a DIGIUM TDM410P 4-port FXS/FXO analog card in an # Asterisk system. It will probably work with other analog cards in # an asterisk system which use the DAHDI drivers. # # - The most current version of this script may be # found at http://www.revpol.com/xymon_asterisk_dahdi_script # # - Instructions to integrate the output of this script to be monitored # and graphed by a Xymon server may also be found at the above URL # # - If you find this script useful, I'd love to know. Send me an email, # or leave a comment on that script page! # # William A. Arlofski # Reverse Polarity, LLC # 860-824-2433 Office # http://www.revpol.com/ # # HISTORY # ------- # - 20130531 - HBD - Initial version release. This script currently makes no # attempt to monitor more than one card in a system. This is due # to the fact that we only have a 4-channel analog Digium card # currently in production to test with. # ############################################################################### # # Copyright (C) 2013 William A. Arlofski - waa-at-revpol-dot-com # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # or visit http://www.gnu.org/licenses/gpl.txt # ############################################################################### # # Set some variables # ------------------ # # Name of Xymon test # ------------------ COLUMN="DAHDI" # Add an administrative message to the top of the report page # Not necessary, but can be a quick way to know what server # is monitoring the DAHDI channels, and perhaps provide some # instructional information # ----------------------------------------------------------- ADMINMSG="This report generated by ${MACHINEDOTS}
${MACHINEDOTS} resides in the main server room
Contact John Doe x1234 with questions
" # Optional Footer message # ----------------------- FOOTER="
Asterisk DAHDI channel test results reported with xymon_asterisk_dahdi_script.sh
Created by: Reverse Polarity, LLC
" # Color to set the test to when a channel is down (red or yellow) # --------------------------------------------------------------- TESTCOL="red" ############################################################################### # -------------------------------------------------- # Nothing should need to be modified below this line # -------------------------------------------------- ############################################################################### # # ---------------------------- # Set required Xymon variables # ---------------------------- COLOR="green" MSG="" data=`cat /proc/dahdi/1` chandata=`echo "${data}" | sed -e 's/\t//' -e 's/ \+//' | grep ^[1-4]` card=`echo "${data}" | grep ^Span` # Wrapping iin the script here is ugly to provide # reasonable output on the test's status page # ----------------------------------------------- IFS=$'\n' for channel in ${chandata}; do curcolor="green" chnum=`echo ${channel} | cut -d' ' -f1` chinfo=`echo ${channel} | cut -d' ' -f1-3` status=`echo ${channel} | grep -i "red" 2>&1` if [ ! -z ${status} ]; then curcolor=${TESTCOL} COLOR=${TESTCOL} fi MSG="${MSG} &${curcolor} Channel:${chinfo} " done unset IFS # Prepend the administrative message to the report # add the card information, the channel statuses # and finally the footer # ------------------------------------------------ MSG="${ADMINMSG}
&${COLOR} ${card} ${MSG}
${FOOTER}" # Send final report to Xymon Server # --------------------------------- $BB $BBDISP "status $MACHINE.$COLUMN $COLOR `date` ${MSG} "