: "@(#)shar.sh 1.8" #! /bin/sh # # This is a shell archive. # Remove everything above this line and run sh on the resulting file. # If this archive is complete, you will see this message at the end: # "All files extracted" # # Created: Thursday February 17 12:02:28 GMT 2000 by informix # # Files archived in this archive: # avg_ping # dbping # readme # #-------------------- if [ -f avg_ping -a "$1" != "-c" ] then echo shar: avg_ping already exists else echo 'x - avg_ping (420 characters)' sed -e 's/^X//' >avg_ping <<'SHAR-EOF' X# dbping : shell script that uses dbaccess to time database response X# Written by : Obnoxio The Clown X# Date : 15 February 2000 X X# note to myself: I really must comment this one day... X Xcat $1 | sed 's/[a-z]/ /g' | awk 'BEGIN { min = 999 } X{ num = $1*60+$2; s += num ; if (num > max) max = num ; if (num < min) min = num } XEND { print "Response time (min/avg/max) (", min, "/", s/NR, "/", max, ") seconds" }' X SHAR-EOF if [ `wc -c dbping <<'SHAR-EOF' X# dbping : shell script that uses dbaccess to time database response X# Written by : Obnoxio The Clown X# Date : 15 February 2000 X X# set up interrupt handling X Xtrap "echo ; avg_ping /tmp/$$ ; exit" 1 2 3 9 X X# set up defaults X XSERVERNAME=$INFORMIXSERVER XDATABASENAME=sysmaster XITERATIONS=0 XSLEEPTIME=5 XVERBOSEMODE=no X X# check arguments X# X# which server and database X# defaults are database sysmaster for default INFORMIXSERVER X# -i X# -d X# X# how many iterations? X# default is 1, just to see if server is alive X# -r is infinite loop X# -n X# X# wait between iterations X# default is 5 seconds X# -s X# X# other flags X# -v for verbose mode (not default) X# -h|-? for help message X Xwhile [ $# -gt 0 ] Xdo X if [ $# -eq 0 ] X then X break X fi X X case $1 in X -d) X shift X DATABASENAME=$1 X shift X ;; X -i) X shift X SERVERNAME=$1 X shift X ;; X -r) X shift X ITERATIONS=-99 X ;; X -n) X shift X ITERATIONS=$1 X shift X ;; X -s) X shift X SLEEPTIME=$1 X shift X ;; X -v) X shift X VERBOSEMODE=yes X ;; X *) X echo " XUsage: X$0 [-i ] [-d ] [-r|-n ] [-s ] [-v] [-h|-?] X XDefaults are: database sysmaster, instance $INFORMIXSERVER, 1 iteration X('instance is alive|not alive'), 5 seconds between iterations. X X-r : infinite loop X-v : verbose more X-h|-? : this message X X" X exit X ;; X esac Xdone X X# create the "averages" file X X> /tmp/$$ X X# do the test X Xwhile : Xdo X X # check if the server is up X onstat - | grep On-Line > /dev/null X X if [ $? -eq 0 ] X then X if [ "x$VERBOSEMODE" = "xyes" ] X then X echo "$DATABASENAME@$SERVERNAME : \c" X fi X X PINGTIME=`( (time dbaccess $DATABASENAME@$SERVERNAME -e ) 2>&1 ) | grep real | awk '{print $2}'` X if [ $ITERATIONS -eq 0 ] X then X echo "The server is alive" X else X echo "Response time is $PINGTIME seconds" X echo $PINGTIME >> /tmp/$$ X fi X else X if [ "x$VERBOSEMODE" = "xyes" ] X then X echo "$DATABASENAME@$SERVERNAME : \c" X fi X X echo "The server is down" X fi X X ITERATIONS=`expr $ITERATIONS - 1` X if [ $ITERATIONS -le 0 ] X then X if [ $ITERATIONS -gt -99 ] X then X break X fi X fi X X if [ $SLEEPTIME -gt 0 ] X then X sleep $SLEEPTIME X fi X Xdone X X# get average response time X Xif [ $ITERATIONS -ne -1 ] Xthen X avg_ping /tmp/$$ Xfi X X# yibbada-yibbada : that's all folks! X SHAR-EOF if [ `wc -c readme <<'SHAR-EOF' Xdbping: simple timing to see if your database connection is up. Xwritten by: Obnoxio The Clown X XMake sure dbping and avg_ping are in your PATH, and that should be it. No Xwarranties or nothing. If you find a bug (unlikely, but still...), email me at Xobnoxio@hotmail.com and I'll see if I'll deign to fix it. It's a shell script, Xso if you really care, you can work it out for yourself. :-) X XOh, I only tested it on Solaris 2.6 X XUsage: Xdbping [-i ] [-d ] [-r|-n ] [-s ] [-v] [-h|-?] X XDefaults are: database sysmaster, instance $INFORMIXSERVER, 1 iteration X('instance is alive|not alive'), 5 seconds between iterations. X X-r : infinite loop X-v : verbose more X-h|-? : this message X SHAR-EOF if [ `wc -c