dnl just change the quotes, we need single quotes in this script -- ksb changequote(,)dnl #!/usr/bin/env ksh # $Id: oraclestats.host,v 1.10 2008/12/02 22:06:15 ksb Exp $ # # This script outputs selected oracle stats via rrdup->peg. # # Authors # Allen Herndon (dah) # Stephen Gunn (csg) # Barton Joseph (bj) # Erik Greenwald (erik) # Kevin Braunsdorf <@ksb.npcguild.org> (ksb) PATH=$HOME/bin:/usr/local/bin:$PATH progname=`basename $0` usage="$progname: usage [-ax] [-N node] [-p delay] [-s login] [dbs] $progname: -h $progname: -V" slide='P=$1; shift; set _ -`expr _"$P" : _'\''-.\(.*\)'\''` ${1+"$@"}; shift' param='if [ $# -lt 2 ]; then echo "$progname: missing value for $1" 1>&2 ; exit 64; fi' AFLAG=false PFLAG=0 HOST=$(hostname 2>/dev/null || uname -n 2>/dev/null) ifdef(FORCE_LOCAL_DOMAIN,HOST=${HOST%%.*}"FORCE_LOCAL_DOMAIN" ,HOST=${HOST%%.fedex.com} HOST=${HOST%%.sac} )dnl  HOST=host/$HOST # get the options from the command line (+ any variables) while [ $# -gt 0 ] do case "$1" in -a) AFLAG=true shift ;; -a*) AFLAG=true eval "$slide" ;; -N) HOST=$2 if ! expr _"$HOST" : '.*/.*' >/dev.null ; then HOST=host/$HOST fi shift; shift ;; -N*) HOST=`expr _"$1" : _'-.\(.*\)'` if ! expr _"$HOST" : '.*/.*' >/dev.null ; then HOST=host/$HOST fi shift ;; -p) PFLAG=$2 shift; shift ;; -p*) PFLAG=`expr _"$1" : _'-.\(.*\)'` shift ;; -s) SFLAG=$2 shift; shift ;; -s*) SFLAG=`expr _"$1" : _'-.\(.*\)'` shift ;; -x) XFLAG=-x shift ;; -x*) XFLAG=-x eval "$slide" ;; --) shift break ;; -h|-h*) cat <&2 exit 64 ;; *) # or process and continue for intermixed options & args break ;; esac done # Some sanity check, it takes about a second to run the sqlplus command if [ $PFLAG -gt 0 -a $PFLAG -lt $# ] ; then PFLAG=$((1+2*$#)) fi # If we can not update ".oraenv" in /opt allow it to be in our home directory RETVAL=0 while true ; do CLOCK=0 if [ 0 -ne $PFLAG ] ; then CLOCK=$((RANDOM%(PFLAG-$#))) sleep $CLOCK fi for DB do if [ -r /opt/oracle/$DB/.oraenv ]; then . /opt/oracle/$DB/.oraenv elif [ -r $HOME/$DB.oraenv ] ; then . $HOME/$DB.oraenv else echo "$progname: $DB: database not found" 1>&2 RETVAL=66 continue fi T=$((RANDOM%2)) CLOCK=$((CLOCK+T)) sleep $T if [ -n "$SFLAG" ] ; then LOGIN="$SFLAG" elif [ -n "$OSTAT_LOGIN" ] ; then LOGIN="$OSTAT_LOGIN" else LOGIN="monitor/peg" fi $AFLAG && LOGIN="$LOGIN@$DB" sqlplus -s "$LOGIN" <