return to PRS Technologies website


connect_type_log.sh
################################################################################ #!/usr/bin/ksh ################################################################################ # # Module: connect_type_log.sh # Author: Peter R. Schmidt # Description: Count and log by type of connection # # Arguments # # Argment: -v Interactive - display to screen - no e-mail # # Change Log # # Date Name Description................. # 09/19/01 Peter R. Schmidt Start Program # ################################################################################ FG=false for ARG do case "$ARG" in -v) FG=true;; esac done . /elite/custom/run.elite EMAIL_LIST="sysadmin" LOGDIR=/elite/work/logs LOGFILE=$LOGDIR/connect_type.log if [ ! -d $LOGDIR ]; then echo "Error: connect_type_log.sh: Directory: $LOGDIR does not exist!" exit 1 fi #------------------------------------------------------------------------------- SHM=`onstat -c | egrep -i NETTYPE | grep -i ipcshm | awk ' { split ($2,a,",") limit=a[2] * a[3] print limit } '` TCP=`onstat -c | egrep -i NETTYPE | egrep -i "soctcp|tlitcp" | awk ' { split ($2,a,",") limit=a[2] * a[3] print limit } '` #------------------------------------------------------------------------------- if [ "x$SHM" = "x" ]; then echo "Error: connect_type_log.sh: unable to compute SHM limit" exit 1 fi if [ "x$TCP" = "x" ]; then echo "Error: connect_type_log.sh: unable to compute TCP limit" exit 1 fi #------------------------------------------------------------------------------- UDATE=`date +%m/%d/%y` UTIME=`date +%H:%M:%S` onstat -g ntu | egrep "ipcshm|soctcp|tlitcp" | awk ' { NETSCB=$1 CTYPE=$2 THREAD=$3 NAME=$4 SID=$5 FD=$6 POLL=$7 READS=$8 WRITES=$9 QNRM=$10 QEXP=$11 ## printf "Debug: CTYPE=%s\n",CTYPE if (CTYPE == "ipcshm") { cnt_shm++ } else { if (CTYPE == "soctcp" || CTYPE == "tlitcp" ) { cnt_tcp++ } else { cnt_oth++ } } cnt_tot++ } END { msg1="" msg2="" msg3="" if (cnt_shm > shm_limit) { msg1="WARNING: shm connection limit exceeded" } if (cnt_tcp > tcp_limit) { msg2="WARNING: tcp connection limit exceeded" } msg3=msg1 " " msg2 printf "%s %s total: %d, shm %d (limit %d), tcp=%d (limit %d), other=%d %s\n", udate,utime,cnt_tot,cnt_shm,shm_limit,cnt_tcp,tcp_limit,cnt_oth,msg3 } ' shm_limit=$SHM tcp_limit=$TCP udate=$UDATE utime=$UTIME >> $LOGFILE if [ $FG = true ]; then tail -1 $LOGFILE else CNT_WARNING=`tail -1 $LOGFILE | grep -c WARNING` if [ $CNT_WARNING != 0 ]; then tail -1 $LOGFILE | mailx -s "Warning: Informix connection limit exceeded" $EMAIL_LIST fi fi ################################################################################