#!/bin/ksh ############################################################################# # # NAME: tcc.auto - A 3com Total Control multiple status verification tool. # # AUTHOR: Chuck Geigner, IO Network Solutions, Inc. # PURPOSE: Utility calls expect scripts to return the session info on all # TCC units specified. Output data is then read in and evaluated # to determine whether or not any modems in any pool are either # down or malfunctioning. Error report sent if any check fails. # NOTE: This script calls proprietary expect scripts not detailed and # will not work without those scripts (pontiac1.exp, etc.) # Even though not included, each one polls a Total Control Chassis # for modem status. With little effort you could write your own. # Also, the IP's of our equipment have been removed for added # security. You will need to add them back to suit you. -ctg # ############################################################################# ADMINLIST="someadmin@example.com" # <----- change this to alert recipients INSTALLDIR="/execute/from/" # <----- change this to dir where progs are if [ $# -eq 1 ]; then if [ $1 = "-i" ]; then INTERACT=1 fi elif [ $# -gt 1 ]; then echo "Too many args given: $# :Exiting.";exit else INTERACT=0 fi ########################################################################### # # MODULE: _modemchecker # PURPOSE: Check TCC output for failed ports, report findings # INPUTS: TCC Data ($DATAFILE), No. of modems ($MODEMS), POP being # evaluated ($POP) # PROCESSING: Check for inactive/inactive, active/inactive, or stalled # OUTPUT: modem ID of failed modem(s) (FILE), error indicator. # ########################################################################### _modemchecker() { set -A ACTIVE `cut -c 6 $DATAFILE` set -A READY `cut -c 8 $DATAFILE` set -A ONOFF `cut -c 12-14 $DATAFILE` COUNT=0 while [ $COUNT -lt $MODEMS ]; do MODEMNUM=`expr $COUNT + 1` if [ ${ACTIVE[$COUNT]} = "I" ]; then ERRORCT=1 echo "$POP modem S$MODEMNUM inactive/inactive." >> /tmp/errorreport printf "S$MODEMNUM " >> /tmp/resetlist elif [ ${READY[$COUNT]} = "I" ]; then if [ $ERRORCT -eq 0 ]; then ERRORCT=1 printf "S$MODEMNUM " >> /tmp/resetlist fi echo "$POP modem S$MODEMNUM active/inactive." >> /tmp/errorreport elif [ ${READY[$COUNT]} = "A" -a $ERRORCT -eq 0 ]; then if [ $ERRORCT -eq 0 ]; then ERRORCT=1 printf "S$MODEMNUM " >> /tmp/resetlist fi echo "$POP modem S$MODEMNUM in limbo (AAP)" >> /tmp/errorreport fi COUNT=`expr $COUNT + 1` done if [ $ERRORCT -eq 1 ]; then $INSTALLDIR/tccreset.exp $IP `cat /tmp/resetlist` fi } ########################################################################### # # MODULE: _evalmodemdata # PURPOSE: _modemchecker's gatekeeper # INPUTS: TCC Data ($DATAFILE), POP being evaluated ($POP) # PROCESSING: Determines whether data exists for _modemchecker to process # OUTPUT: Executes _modemchecker or outputs "no data" # ########################################################################### _evalmodemdata() { if [ -s $DATAFILE ]; then _modemchecker else echo "$POP returned no data or was unreachable." >> /tmp/errorreport fi if [ $INTERACT -eq 1 ]; then echo $POP >> $DATAFILE cat $DATAFILE rm -f $DATAFILE fi } ERRORCT=0 POP="PONTIAC1" IP="" DATAFILE="/tmp/tcc1.tmp" $INSTALLDIR/pontiac1.exp | grep '^S' | grep -v S0 > $DATAFILE MODEMS=96 _evalmodemdata ERRORCT=0 POP="PONTIAC2" IP="" DATAFILE="/tmp/tcc.auto2.tmp" $INSTALLDIR/pontiac2.exp | grep '^S' > /tmp/tcc2.tmp grep '^S[1-9] ' /tmp/tcc2.tmp > $DATAFILE grep '^S1[0-9]' /tmp/tcc2.tmp >> $DATAFILE grep '^S2[0-4]' /tmp/tcc2.tmp >> $DATAFILE MODEMS=24 _evalmodemdata ERRORCT=0 POP="CHATSWORTH" IP="" DATAFILE="/tmp/tcc.auto3.tmp" $INSTALLDIR/chatsworth.exp | grep '^S' | grep -v S0 > /tmp/tcc3.tmp grep '^S[1-9] ' /tmp/tcc3.tmp > $DATAFILE grep '^S1[0-9]' /tmp/tcc3.tmp >> $DATAFILE grep '^S20' /tmp/tcc3.tmp >> $DATAFILE MODEMS=20 _evalmodemdata ERRORCT=0 POP="ODELL" #IP="" DATAFILE="/tmp/tcc4.tmp" $INSTALLDIR/odell.exp | grep '^S' |grep -v S0 > $DATAFILE MODEMS=16 # do not do _modemchecker on odell - different format used # to do: figure out diagnostic flags for this dialup access hub. echo $POP >> $DATAFILE ERRORCT=0 POP="FAIRBURY" IP="" DATAFILE="/tmp/tcc5.tmp" $INSTALLDIR/fairbury.exp | grep '^S' |grep -v S0 > $DATAFILE MODEMS=16 _evalmodemdata if [ -f /tmp/errorreport ]; then mail -s "TCC Error Report" $ADMINLIST < /tmp/errorreport rm -f /tmp/errorreport fi rm -f /tmp/tcc*.tmp rm -f /tmp/resetlist