#!/bin/ksh ################################################################################ # Authors : Joseph Shkolnik # Srini M.L # Version : 1.0 # Date : May 25, '98 # Description : # # This is a DBA script for informix. This is Menu driven and developed on # SUN OS and NOT tested on any other platforms. This contains significant # utilities which helps an Informix DBA to easily monitor an informix instance. # # The Author(s) claim no responsibility for any misuse of this script directly # or indirectly. There is no official support for this utility from Informix or # any other company. # # Any suggestions/comments/complaints can be directly mailed to the author(s). # # Hope you find this useful. Good luck! ################################################################################ TMP="/tmp/tmp_dba.$$" awk="nawk" tf="$0" # This file #---------------------------------- # Main DBA Menu printing function #---------------------------------- PRT_MENU(){ if [ $# -gt 1 ]; then cols=$2 else cols=2 fi $awk "(match(\$0,/#M$1#.*#.*/)>0){ split(substr(\$0,RSTART,RLENGTH),a,\"#\") printf(\"%s) %s\n\",a[3],a[4]) }" $tf | pr -t -l 18 -${cols} -w 80 } #------------------------ # To print the outputs #------------------------ EX() { clear; echo "Please wait..." (echo "*******************************************************************************"; eval $1 | egrep -v "INFORMIX") | egrep -v '^[ ]*$' | pg -csnp "($1) Page %d >" } #---------------------------------- # If the entered option is wrong #---------------------------------- WRONG() { echo "$1 : Wrong Option. Press Try Again...\c";read xx } #----------------------- # Main DBA Menu Heading #----------------------- MENU_INTRO(){ date="`date`" HOSTNAME="`hostname`" if [ $# -gt 1 ]; then cols=$2 else cols=2 fi clear now=`date +%A,%B-%d-%Y@%H:%M:%S` echo " -: INFORMIX DBA MENU :- " echo "********************************************************************************" echo "$now" echo "--------------------------------" echo "HOST=`hostname` LOGNAME=`logname` PWD=`pwd`" echo "********************************************************************************" PRT_MENU $1 ${cols} echo "********************************************************************************" echo echo "Please Enter your option : \c";read fnn } #------------------------------- # Sub-Menu for Misc.Operations #------------------------------- MENU_D(){ glob="${glob}D" while : do MENU_INTRO D 2 case $fnn in #------------------------------- # Return to the previous menu #------------------------------- q) break ;;#MD# q#Return to Previous Menu #------------------------------- # Run ipcs #------------------------------- 1) EX 'ipcs 2>&1';;#MD# 1#ipcs #------------------------------- # Run ipcrm - Note : this is bit out of the way and only applicable # to SUN. But this should be run as root. Any other ideas???? #------------------------------- 2) #MD# 2#Interactive ipcrm(for root) user=`id | sed "s/^[^(]*(//g;s/).*$//g"` do_type(){ type="$1";nl=0 echo "Starting \"ipcs -${type}\". You are ${user}. Please wait..." ipcs -${type} | nawk "(\$0~\"^${type}\"){ k=split(substr(\$0,2),a) if(k>4){s=\"\" for(i=1;i<=k;i++){ if(i==2){m=substr(a[i],1,2)}else{m=a[i]};s=s \" \" m} print s } } " | while read L do set ${L}; nf=$# n1=`expr $# - 3`;n2=`expr $# - 2`;n3=`expr $# - 1`;n4=`expr $# - 0` t1="echo \${$n1} \${$n2} \${$n3} \${$n4}" t2="`eval ${t1}" nl=`expr ${nl} + 1` thing="$1" C="ipcrm -${type} ${thing}" COM[${nl}]="${C}" MSG[${nl}]="${t2}" done i=1 while [ ${i} -le ${nl} ]; do n=`printf "%d/%d)" ${i} ${nl}` C="${COM[${i}]}" QUE="${C}" printf "%6s|%-32s|%-16s|%s" "${n}" " ${MSG[${i}]}" " ${QUE}" " (y/n/q)?:" read yesno if [ "${yesno}." = "q." ]; then return ; fi if [ "${yesno}." = "y." ]; then ${C} # Real execution.... RC=$?;echo "Done: RC=${RC}" fi i=`expr ${i} + 1` done } echo "\nPlan: 1) ipcrm -m; 2) ipcrm -s ..." do_type "m" do_type "s" echo "Press Enter...";read ;; 3) #MD# 3#System messages f="/var/adm/messages";clear if [ -s ${f} ]; then EX "tail -r ${f} | tr \"[\t]\" \"[ ]\" | sed \"s/ [ ]*/ /g\"" else ls -l ${f} 2>&1; echo "Press Enter...";read fi ;; 4) EX 'ls -lat /tmp 2>&1' ;;#MD# 4#Temp File List 5) #MD# 5#OS I/O Stat clear;trap ";" 2 int=5; num=9999 iostat -x ${int} ${num} | nawk " BEGIN{n=0 frmt=\"Dk(%03ld/%ld) It(%s %s) Av(%s %s) \" frmt=frmt \"Ma(%s %s) Tl(%s %s)\" csh=3600 cKG=1024*1024 cc=(csh/cKG) printf(\"%s %s\n\",\"# IO disks read&write transfer\", \"rate in Gbytes/hour\") printf(\"# Up to ${num} intervals by ${int} seconds.\n\") printf(\"# Dk(Active_disks/Total_disks)\n\") printf(\"# It(Read_speed Write_speed)\n\") printf(\"# Av(Avg_read_speed Avg_write_speed)\n\") printf(\"# Ma(Max_read_speed Max_write_speed)\n\") printf(\"# Tl(Total_read Total_written)\n\") printf(\"# Press Ctrl+C to stop...\n\") } ((NF==10)&&((Krs=\$4)~/^[0-9]/)&&((Kws=\$5)~/^[0-9]/)){ disk=\$1 if(disk==disk_first){n++ if(n>1){ sum_sKrs+=sKrs sum_sKws+=sKws } # sKrs - read Kbytes per 1 second per this disk # sum_sKrs - read Kbytes per 1 second per all disks # KrTot - read Kbytes from starting ios per all disks max_sKrs=max(max_sKrs,sKrs) max_sKws=max(max_sKws,sKws) KrTot+=(sKrs*${int}) KwTot+=(sKws*${int}) prt_stat() sKrs=0;sKws=0;nact=0;ntot=0 } if(disk_first==\"\"){disk_first=disk} sKrs+=Krs;sKws+=Kws if((sKrs>0)||(sKws>0)){nact++};ntot++ } function prt_stat(){ ave_sKrs=sum_sKrs/max(1,n-1) ave_sKws=sum_sKws/max(1,n-1) if(sKrs>ave_sKrs){ir=\"r\"} else{ir=\" \"} if(sKws>ave_sKws){iw=\"w\"} else{iw=\" \"} c=sprintf(frmt, nact,ntot, ft(sKrs*cc,4), ft(sKws*cc,4), ft(ave_sKrs*cc,4), ft(ave_sKws*cc,4), ft(max_sKrs*cc,4), ft(max_sKws*cc,4), ft(KrTot/cKG,5), ft(KwTot/cKG,5)) c=c ir iw printf(\"#%03ld:%s\n\",n,c) } function ft(v,k){return(substr(sprintf(\"%.4f\",v),1,k))} function max(x,y){return(x>y?x:y)} function min(x,y){return(x0){ gsub(/ [ ]*/,\" \",\$0);print \$0;exit(1)}}" RC=$?;if [ $RC -gt 0 ]; then echo "# Queue is not empty???"; fi int=5 netstat -i -I x ${int} | nawk " (\$1~/[0-9][0-9]*/){Ipkts=\$6;Ierrs=\$7;Opkts=\$8;Oerrs=\$9;Collis=\$10 msg=\"\" n++;np=int(n/22)+1 if(np!=npp){s=\"\" s=s \" Ipkts Ierrs Opkts Oerrs Collis\" s=s \" rI,% rO,% rC,% Comments\" print s npp=np } tI=0.25;if(Ipkts==0){rI=0}else{rI=Ierrs*100/Ipkts} if((rI>tI)||(Ierrs>100)){eI=\"*\";n++ printf(\"# Big Network problem outside of box? rI=%.2f%% > %.2f%%:\n\",rI,tI) }else{eI=\" \"} tO=0.25;if(Opkts==0){rO=0}else{rO=Oerrs*100/Opkts} if((rO>tO)||(Oerrs>100)){eO=\"*\";n++ printf(\"# Local problem(adapt./connect./interf.)? rO=%.2f%% > %.2f%%:\n\",rO,tO) }else{eO=\" \"} tC=10;if(Opkts==0){rC=0}else{rC=Collis*100/Opkts} if(rC>tC){eC=\"*\";n++ printf(\"# Network over utilized? rC=%.2f%% > %.2f%%:\n\",rC,tC) }else{eC=\" \"} if(Ipkts==0){msg=msg \" No_IN\"} if(Opkts==0){msg=msg \" No_OUT\"} printf(\"%9ld %7ld %9ld %7ld %8ld %4.1f%s %4.1f%s %4.1f%s %s\n\", Ipkts,Ierrs,Opkts,Oerrs,Collis,rI,eI,rO,eO,rC,eC,msg) } " ;;#MD# 6#Netstat (5sec Interval) 7) EX 'df -ak | sort -k 6,6';;#MD# 7#Disk Usage(df -k) #------------------------------------------------------------------------- # This script checks the ONCONFIG informix parameter values and gives a # recommendation of suitable values. #------------------------------------------------------------------------- 8) #MD# 8#Check Informix Params clear ;echo "Please wait..." GETPARM(){ #grep $1 $INFORMIXDIR/etc/$ONCONFIG | nawk '($1=="$1"){print $2}' cat $INFORMIXDIR/etc/$ONCONFIG | nawk "(\$1==\"$1\"){print \$2}" } nlines=`mpstat | wc -l` nDisks=`iostat -x | wc -l`;nDisks=`expr ${nDisks} - 2` nDbDisks=`expr ${nDisks} - 2` # Suggestion: DB uses total_disks-2 nCPUs=`expr ${nlines} - 1` SINGLE_CPU_VP=`GETPARM SINGLE_CPU_VP` MULTIPROCESSOR=`GETPARM MULTIPROCESSOR` NUMCPUVPS=`GETPARM NUMCPUVPS` AFF_SPROC=`GETPARM AFF_SPROC` AFF_NPROCS=`GETPARM AFF_NPROCS` SHMVIRTSIZE=`GETPARM SHMVIRTSIZE` SHMADD=`GETPARM SHMADD` CLEANERS=`GETPARM CLEANERS` BUFFERS=`GETPARM BUFFERS` LRUS=`GETPARM LRUS` NUMAIOVPS=`GETPARM NUMAIOVPS` PHYSBUFF=`GETPARM PHYSBUFF` LOGBUFF=`GETPARM LOGBUFF` RA_PAGES=`GETPARM RA_PAGES` RA_THRESHOLD=`GETPARM RA_THRESHOLD` if [ $nCPUs -eq 1 ]; then rMULTIPROCESSOR=0 rNUMCPUVPS=1 rAFF_SPROC=0 rAFF_NPROCS=0 else rMULTIPROCESSOR=1 rNUMCPUVPS=`expr $nCPUs - 1` rAFF_SPROC=1 rAFF_NPROCS=${rNUMCPUVPS} fi if [ $rNUMCPUVPS -eq 1 ]; then rSINGLE_CPU_VP=1 else rSINGLE_CPU_VP=0 fi rSHMVIRTSIZE=`onstat -g seg | nawk "\ ((\\$4~/[0-9][0-9]*/)&&(\\$6==\"V\")){s+=\\$4}\ END{print max(8000,int(s/1024))}\ function max(x,y){return(x>y?x:y)}"` rSHMADD=`nawk "BEGIN{print max(int(0.1*${rSHMVIRTSIZE}),16000);exit} function max(x,y){return(x>y?x:y)}"` rCLEANERS=`nawk "BEGIN{nD=${nDbDisks} if(nD<20){Cr=nD}else{if(nD<100){Cr=1+int(nD/2)}else{Cr=1+int(nD/4)}} print Cr;exit}"` rLRUS=`nawk "BEGIN{ print min(128,int(${BUFFERS}/1000));exit}\ function min(x,y){return(x0)&&(NR==(n+2))){print int(2*\\$NF/0.75);exit}"` rLOGBUFF=`onstat -l | nawk "(\\$0~/^Logical Logging/){n=NR} ((n>0)&&(NR==(n+2))){print int(2*\\$NF/0.75);exit}"` nawk "BEGIN{ onstat_p(seq,v) sumRA=val(\"idx-RA\")+val(\"da-RA\")+val(\"ixda-RA\") RA_pgsused=val(\"RA-pgsused\") r=RA_pgsused/sumRA rRA_PAGES=${RA_PAGES} if(r<0.8){rRA_PAGES-=2} rRA_THRESHOLD=rRA_PAGES-4 printf(\"No of CPUs : ${nCPUs}, No of Disks : ${nDisks} \n\") printf(\"--------------------------------------------------------------\n\") printf(\"%-20s %16s %16s\n\", \"Parameter\",\"ONCONFIG Value\",\"Recommended\") printf(\"--------------------------------------------------------------\n\") prt1(\"MULTIPROCESSOR\",${MULTIPROCESSOR},${rMULTIPROCESSOR},\" \") prt1(\"NUMCPUVPS\",${NUMCPUVPS},${rNUMCPUVPS},\"+\") prt1(\"AFF_SPROC\",${AFF_SPROC},${rAFF_SPROC},\" \") prt1(\"AFF_NPROCS\",${AFF_NPROCS},${rAFF_NPROCS},\" \") prt1(\"SHMVIRTSIZE\",${SHMVIRTSIZE},${rSHMVIRTSIZE},\"+\") prt1(\"SHMADD\",${SHMADD},${rSHMADD},\"+\") prt1(\"CLEANERS\",${CLEANERS},${rCLEANERS},\"+\") prt1(\"LRUS\",${LRUS},${rLRUS},\"+\") prt1(\"NUMAIOVPS\",${NUMAIOVPS},${rNUMAIOVPS},\" \") prt1(\"PHYSBUFF\",${PHYSBUFF},${rPHYSBUFF},\"-\") prt1(\"LOGBUFF\",${LOGBUFF},${rLOGBUFF},\"-\") prt1(\"RA_PAGES\",${RA_PAGES},rRA_PAGES,\"- \" r) prt1(\"RA_THRESHOLD\",${RA_THRESHOLD},rRA_THRESHOLD,\"-\") exit} function val(s){if(s in v){return(v[s])}else{return(\"\")}} function prt1(s1,n1,n2,A ,I){if(n1!=n2){I=\"*\"}else{I=\" \"} printf(\"%-20s %16ld %16ld %s %s\n\",s1,n1,n2,A,I)} function onstat_p(seq,v , p0,c0,pNR,cNR,pNF,cNF,c0,pf,cf,i,k,n,v0,N,n1){ while(\"onstat -p\" | getline){ p0=c0;pNR=cNR;pNF=cNF;c0=\$0;cNR++;cNF=NF if((cNR==(pNR+1))&&(cNR>1)&&(\$1~/^[0-9][0-9]*/)){ split(p0,pf);split(c0,cf) for(i=1;i<=pNF;i++){n=pf[i];v0=cf[i];N[n]++; if(N[n]==1){n1=n}else{n1=n N[n]} k++;seq[0]=k;seq[k]=n1;v[n1]=v0 } } } return(seq[0]) } " | pg -csnp "(ONCONFIG & Recommended Parametrs:)Page %d>" ;; 9) #MD# 9#Some more Info echo " USE FOLLOWING COMMANDS TO GET MORE INFO ABOUT OS modinfo - display information about loaded kernel modules rpcinfo - report RPC information psrinfo - print processor information pkginfo - display software package information " | pg -cnsp " Page %d>" ;; #------------------------------- # Wrong Input #------------------------------- *) WRONG $fnn;; esac done glob="`echo "${glob}" | sed "s/.$//g"`" } #------------------------------------ # Sub-Menu for Onstat operations #------------------------------------ MENU_C(){ glob="${glob}C" while : do MENU_INTRO C 4 case $fnn in q) break ;;#MC# q#Return to Previous Menu #----------------------------------------------------------------------------- # Some onstat commands (only significant ) and other useful scripts/commands #----------------------------------------------------------------------------- 1) EX 'onstat -b';;#MC# 1#Buffers 2) EX "cat $INFORMIXDIR/etc/$ONCONFIG 2>&1";;#MC# 2#ONCONFIG 3) EX 'onstat -d';;#MC# 3#DBspace/Chunks 4) EX 'onstat -k';;#MC# 4#Locks 5) EX 'onstat -l';;#MC# 5#Logs 6) EX 'onstat -m';;#MC# 6#Message Log 7) EX 'onstat -p';;#MC# 7#Profile 8) EX 'onstat -t';;#MC# 8#TBLspaces 9) EX 'onstat -u| sort -k 10,10n -r | sort -k 9,9n -r' ;;#MC# 9#User Threads 10) EX 'onstat -x';;#MC# 10#Transactions 11) EX 'onstat -z';;#MC# 11#Onstat -z 12) EX 'onstat -D';;#MC# 12#DBspace/Chunk stats 13) EX 'onstat -F';;#MC# 13#Page Flushers 13a) onstat -F | head -7 | egrep -v INFORMIX | pg -cnsp "onstat -F(Short) ";;#MC#13a#Short Pg Flushers 14) EX 'onstat -R';;#MC# 14#LRU queues 14a) onstat -R | tail -3 | pg -cnsp "onstat -R(Short) " ;;#MC#14a#Short LRU queues 15) EX 'onstat -g ath';;#MC# 15#All Th. 16) EX 'onstat -g wai';;#MC# 16#Waiting Th. 17) EX 'onstat -g act';;#MC# 17#Active Th. 18) EX 'onstat -g rea';;#MC# 18#Ready Th. 19) EX 'onstat -g sle';;#MC# 19#Sleeping Th. 20) EX 'onstat -g sch';;#MC# 20#VP Schd Stat 21) EX 'onstat -g glo';;#MC# 21#MT Global Info 22) EX 'onstat -g seg';;#MC# 22#Mem Segs 23) EX 'onstat -g iov';;#MC# 23#VP I/O Stat 24) onstat -g iof | sort -k 6n | egrep -v "INFORMIX" | egrep -v "path" | egrep -v "AIO" | pg -cnsp "Chunk I/O Page %d>";;#MC# 24#Chunk I/O 25) EX 'onstat -g ioq';;#MC# 25#Queue I/O 26) EX 'onstat -g iog';;#MC# 26#AIO GL Info 27) EX 'onstat -g nss';;#MC# 27#Net SHM Stat 28) EX 'onstat -g nsd';;#MC# 28#Net SHM Data 29) EX 'onstat -g wst';;#MC# 29#Th. wait stat 30) EX 'onstat -g mgm';;#MC# 30#M G M 31) EX 'onstat -g lap';;#MC# 31#Light Appends 32) #MC# 32#Sessions EX 'onstat -g ses' echo "****************************************" echo "Enter Session ID: \c";read sid EX 'onstat -g ses $sid' ;; 33) #MC# 33#Ses/SQL EX 'onstat -g sql' echo "****************************************" echo "Enter Session ID: \c";read sid EX 'onstat -g sql $sid' ;; 34) #MC# 34#Oncheck -cc EX 'oncheck -cc' ;; 35) #MC# 35#Oncheck -cr EX 'oncheck -cr' ;; 36) #MC# 36#Oncheck -pr EX 'oncheck -pr' ;; 37) #MC# 37#Oncheck -pc EX 'oncheck -pc' ;; #------------------------------------------------------ # This gives sessions memory usage in ascending order #------------------------------------------------------ 38) #MC# 38#Big MEM Ses onstat -g ses | sort -r -k 8n | egrep -v "session" | \ egrep -v "INFORMIX" | pg -csnp " %d >" ;; #-------------------------------------- # This gives Raw device I/O statistics #-------------------------------------- 39) #MC# 39#R.Dev I/O Stat clear upt=`onstat - | nawk "(\\$1==\"INFORMIX-OnLine\"){ split(\\$0,a,\"--\");print a[3];exit}"` onstat -g iof | nawk "((NF==6)&&(\$4~/^[0-9][0-9]*$/)){ t[\$2]+=\$3;r[\$2]+=\$4;w[\$2]+=\$5;u[\$2]+=\$6} END{ for(s in t){ printf(\" %7s %8ld %8ld %8ld %8ld\n\",s,t[s],r[s],w[s], u[s])}} " | sort -r -k 2 | pg -csnp \ " Raw Dev TotalOPs DskRds DskWrts %ops " ;; 40) EX 'onstat -g dic';;#MC# 40#Dict.Cache 41) EX 'onstat -g rbm';;#MC# 41#Res Seg Blk Map 42) EX 'onstat -g nbm';;#MC# 42#Non-Res Seg Blk Map 43) EX 'onstat -g iob';;#MC# 43#Big Buf Usage 44) EX 'onstat -g ppf';;#MC# 44#Partition Prof 45) EX 'onstat -g tpf';;#MC# 45#Thread Prof 46) EX 'onstat -g ntd';;#MC# 46#Net Disp Info #-------------------------------------------------------------------- # The following four options are un-documented onstat commands. #-------------------------------------------------------------------- 47) EX 'onstat -g dis';;#MC# 47#Serv Display 48) EX 'onstat -g prc';;#MC# 48#S Proc Cache 49) EX 'onstat -g dsc';;#MC# 49#Distrib Cache 50) EX 'onstat -g lsc';;#MC# 50#Light Scan Info *) WRONG $fnn;; esac done glob="`echo "${glob}" | sed "s/.$//g"`" } #-------------- # Main Menu #-------------- MENU_A(){ glob="${glob}A" while : do # Main menu MENU_INTRO A case $fnn in q) break;;#MA# q#Quit DBA #----------------------- # Uses Sub-Menu MENU_C #----------------------- 1) MENU_C ;;#MA# 1#Onstat Commands #----------------------- # Uses Sub-Menu MENU_D #----------------------- 2) MENU_D ;;#MA# 2#Misc. Operations: #----------------------- # This diagnostic run is only for SUN OS. We can think of adding for other # platforms also. Suggestions please. #----------------------- 3)#MA# 3#Diagnostics (SUN OS only) clear;echo "Please wait..." rm ${TMP} 2>/dev/null K=1024;M=1048576 nCPU=`mpstat | wc -l`;nCPU=`expr ${nCPU} - 1` nDisks=`iostat -x | wc -l`;nDisks=`expr ${nDisks} - 2` echo "* Real `prtconf | grep Memory `,\c" >>${TMP} echo " ${nCPU} CPUs, ${nDisks} Disks." >>${TMP} swap -s | nawk "BEGIN{k=(1/1024)}{ used_M=s(\$2)*k;free_M=(s(\$6)+s(\$11))*k total_M=used_M+free_M used_pct=(used_M*100/total_M);free_pct=100-used_pct printf(\"* Swap space|total: %ld Mb = used: %ld Mb(%.1f%%) + free: %ld Mb(%.1f%%)\n\",total_M,used_M,used_pct,free_M,free_pct) } function s(x){return(substr(x,1,length(x)-1))}" >>${TMP} ps -ef -o comm | nawk " {s=\"other\" if(\$0~\"oninit\"){s=\"oninit\"} else{ if(\$0~\"dw\"){s=\"dw\"} else{ if(\$0~\"QUAL\"){s=\"QUAL\"} } } n[s]++ s=\"ALL\" n[s]++ } END{ printf(\"*\") for(w in n){ printf(\" %s=%ld \",w,n[w]) } printf(\"\n\") }" >>${TMP} echo "uptime:Time up, jobs in run queue over the last 1,5,15 minutes:" >>${TMP} uptime >>${TMP} 2>&1 nvold=`ps -ef | grep -v grep | grep -c vold` if [ ${nvold} -lt 1 ] then echo "*** WARNING: vold is not running(${nvold})!" >>${TMP};fi echo "# The largest recent CPU consumers:--------------------" >>${TMP} ps -ef -o pcpu,time,etime,pid,nice,vsz,comm \ | sort | tail -5 >>${TMP} whence onstat >/dev/null 2>&1;RC=$? if [ ${RC} -ne 0 ]; then echo "*** ERROR: onstat is not accessible!" >>${TMP};fi if ! test $HOME then echo "*** ERROR: HOME($HOME) not set!" >>${TMP};fi if ! test $INFORMIXDIR then echo "*** ERROR: INFORMIXDIR not set!" >>${TMP};fi if ! test $ONCONFIG then echo "*** ERROR: ONCONFIG not set!" >>${TMP};fi if ! test $INFORMIXSQLHOSTS then echo "*** ERROR: INFORMIXSQLHOSTS not set!" >>${TMP};fi i="$INFORMIXDIR/bin" nP=`echo "$PATH" | egrep -c "^$i:|:$i:|^$i[ ]*$|:$i[ ]*$"` if [ ${nP} -ne 1 ] then echo "*** ERROR: INFORMIXDIR/bin is not in PATH" >>${TMP};fi inf_dwn1=255 # Down inf_dwn2=-1 # Down (60_USAP2) inf_init=0 # Initialization inf_quie=1 # Quiescent inf_fast=2 # Fast Recovery inf_arch=3 # Archive backup inf_shut=4 # Shutting Down inf_onli=5 # Online inf_abor=6 # System Aborting onstat - >/dev/null 2>&1 state=$? case $state in 255|-1) inf_mode="'Down'" ;; 0) inf_mode="'Initialization'" ;; 1) inf_mode="'Quiescent'" ;; 2) inf_mode="'Fast Recovery'" ;; 3) inf_mode="'Archive backup'" ;; 4) inf_mode="'Shutting Down'" ;; 5) inf_mode="'Online'" ;; 6) inf_mode="'System aborting'" ;; *) inf_mode="unknown" ;; esac if [ ${state} -eq 5 ] ; then onstat - | sed "s/ Version//g" >>${TMP} a1='(($5=="-")&&($6!=0)){n++}END{print n}' nthread=`onstat -u | nawk "${a1}"` onstat -g seg | nawk " (\$NF==\"Kbytes\"){its=\$(NF-1)} ((NF==8)&&(\$1!=\"Total:\")&&(\$4~/[0-9][0-9]*/)){ n++;ts+=\$4;fts+=\$4*(\$8/(\$7+\$8))} END{printf(\"# -g seg | size(%ld segs)=%.2fM (%.2f+%.2f). free=%ldM\n\", n,ts/${M},its/${K},((ts/${M})-(its/${K})),fts/${M})}" >>${TMP} onstat -g ses | nawk " BEGIN{k=(1/(1024*1024))} ((NF==8)&&(\$8~/[0-9][0-9]*/)){n++;tm+=\$7;um+=\$8} END{printf(\"# -g ses | %ld ses, ${nthread} threads. Mem: total-%.2f Mb, used-%.2f Mb\n\", n,tm*k,um*k)}" >>${TMP} bsa=`onstat -b | nawk '($10=="size"){print $3,($3*$8/(1024*1024))}'` echo "# -g b | buffers ${bsa} Mbytes total" >>${TMP} onstat -g sts | nawk "((NF>6)&&(\$1~\"^[0-9][0-9]*$\")){n++;s+=\$2} END{printf(\"# -g sts | %ld threads, %.2f Mb stack size total\n\", n,s/(1024*1024))}" >>${TMP} onstat -l 2>>${TMP} | nawk " ((NF==8)&&(\$2~/[0-9][0-9]*/)&&(\$3!~/[0-9][0-9]*/)){ s3=\$3;if((s3~\"^U-B\")||(s3~\"F------\")){nf++};nl++ } END{pct=(nl==0)?0:(100*nf/nl) printf(\"Informix has %ld of %ld (or %.0f%%) free logs\n\",nf,nl,pct) }" >>${TMP} onstat -d | nawk "(\$1==\"Chunks\"){ch=1} ((ch==1)&&(NF==8)&&(\$6~/[0-9][0-9]*/)){ if(substr(\$7,2,1)!=\"O\"){ printf(\"*** Check Chunk:\n%s\n\",\$0);nok=1 } nc[\$7]++ } END{printf(\"Chunks:\") for(s in nc){ printf(\" %ld %s\",nc[s],s) } if(nok!=1){printf(\" ********************* All Chunks are OK.\")} printf(\"\n\") }" >>${TMP} else echo "\n******* Informix Server in $inf_mode mode" >>${TMP} fi env | egrep '^INFORMIX|ONCONFIG' | grep -v BASE >>${TMP} clear egrep -v "^[ ]*$" ${TMP} | pg -csnp "(Diagnostic:)Page %d>" rm ${TMP} 2>/dev/null ;; #----------------------- # DBaccess #----------------------- 4) dbaccess ;;#MA# 4#DBaccess #----------------------- # OnMonitor #----------------------- 5) onmonitor;;#MA# 5#Onmonitor #---------------------- # SAPDBA #---------------------- 6) /sapmnt/${SAPSYSTEMNAME}/exe/sapdba;;#MA# 6#SAPDBA #---------------------------------------------------------- # Some Infomrix commands....using shell scripts/dbaccess #---------------------------------------------------------- # This gives the number of buffers each table is using!!! Interesting isn't it? 7) #MA# 7#Informix Buffer Usage clear;echo "Please wait..." echo " database sysmaster; select c.dbsname,c.tabname tab ,count(*) cnt ,'#' from sysbufhdr a ,sysptnext b ,systabnames c where a.pagenum >= b.pe_phys and a.pagenum < b.pe_phys+b.pe_size and c.partnum = b.pe_partnum group by c.dbsname ,c.tabname ; " | dbaccess - 2>/dev/null | nawk " (\$NF==\"#\"){nt++;nb+=\$3;printf(\"%6ld %s\n\",\$3,\$1 \":\" \$2)} END{printf(\"%6ld Total Used Buffers for %ld tables\n\",nb,nt)} " | sort -k 1,1n -r | pg -sncp "(${HOSTNAME} at ${date}) %d>" ;; #---------------------------------------------------------------------- # This prints the informix online.log file in the reverse order and an option to # move around the file, searching, etc. #---------------------------------------------------------------------- 8) clear echo "Please wait\c" mp=`grep MSGPATH $INFORMIXDIR/etc/$ONCONFIG | nawk '{print $2}'` nl=`cat ${mp} | wc -l ` echo " reading ${nl} lines..." nawk "BEGIN{s1=\" \";sp=s1 s1;sp=sp sp sp sp} (\$0~\"^[ ]*$\"){next} (\$0~/[ ]*[A-Z][a-z][a-z] [ ]*[A-Z][a-z][a-z] [ ]*[0-9][0-9]* /){ dt=sprintf(\"%s %s %02ld\",\$1,\$2,\$3);ndt=NR } { if(\$1~\"^[0-9][0-9]:[0-9][0-9]:[0-9][0-9]$\"){sec1=sec2 split(\$1,a,\":\");sec2=a[3]+60*(a[2]+60*a[1]) if(sec1==0){sec1=sec2} gap=sec2-sec1; while(gap<0){gap+=(60*60*24)} tt=\$1 } else{\$0=tt \" \" \$0} if((ndt!=NR)&&(\$0!~/^[ ]*\$/)){s=\$0 s2=sprintf(\"|%s|%4ld\",dt,gap) ls2=length(s2) s=substr(s,1,8) \"|\" substr(s,11) gsub(\"\t[\t]*\",\" \",s); gsub(\" [ ]*\",\" \",s); gsub(/[ ]*$/,\"\",s); r=(length(s)+length(s2))%80 if(r>0){s=s substr(sp,1,80-r)} s=s s2 printf(\"%ld #%s\n\",NR,s) } } " ${mp} | sort -k 1nr |\ nawk "{print substr(\$0,1+index(\$0,\"#\"))}" |\ egrep -v "^[ ]*$" | pg -csnp " ${mp} Page %d>" ;;#MA# 8#Informix Log File #-------------------------------- # Frees shared memory #-------------------------------- 9) EX '(onstat -;onmode -F;onstat -)|grep -v "^[ ]*$" ' ;;#MA# 9#Free Unused Shared Memory 10) clear;echo "Please wait..." dbaccess sysmaster <<-EOF 2>/dev/null | egrep -v '^[ ]*$' | \ pg -sncp " (`hostname`:Informix Waits) Page %d>" select round(sum(numwaits/1000),0) numwaits_K ,round(sum(cumtime/1000),0) cumtime_K ,round(max(maxtime/1000),0) maxtime_K ,reason[1,26] from sysseswts where reason <> 'condition' and cumtime > 0 group by 4 order by 2 desc; EOF ;;#MA# 10#Informix Waits #---------------------------------- # This gives i/o operations for each user thread with Sid and description of # the user process. #---------------------------------- 11) #MA# 11#User Threads IOs MA0(){ t=5 clear; trap ";" 2 onstat -ur ${t} -g sql | nawk "BEGIN{ni=0 P[1,\"B\"]=\"w_buffer\" P[1,\"C\"]=\"w_CHKP\" P[1,\"G\"]=\"w_WR_logbuff\" P[1,\"L\"]=\"W_lock\" P[1,\"S\"]=\"w_mutex\" P[1,\"T\"]=\"w_trans\" P[1,\"Y\"]=\"w_cond\" P[1,\"X\"]=\"w_rollback\" P[2,\"*\"]=\"trans._act._during_I/O_failure\" P[3,\"A\"]=\"dbspace_backup\" P[3,\"B\"]=\"begin\" P[3,\"P\"]=\"prep.commit\" P[3,\"X\"]=\"prep.commit\" P[3,\"C\"]=\"commit\" P[3,\"R\"]=\"rollback\" P[3,\"H\"]=\"heur._roll_back\" P[4,\"P\"]=\"PRIM\" P[5,\"R\"]=\"reading\" P[5,\"X\"]=\"commit\" P[7,\"B\"]=\"btree cleaner\" P[7,\"C\"]=\"w_term.cleanup\" P[7,\"D\"]=\"daemon\" P[7,\"F\"]=\"page-cleaner\" P[7,\"M\"]=\"On-Monitor\" P[7,\"\"]=\"\" } (\$1==\"INFORMIX-OnLine\"){prt();ni++ k=split(\$0,tf,\"--\") for(i=1;i<=k;i++){gsub(\" [ ]*\",\"\",tf[i])} for(s in ut){delete ut[s] } for(s in stmt){delete stmt[s] } for(s in sid){ delete sid[s];delete flagUT[s]} } ((\$1==\"Userthreads\")&&(NF==1)){state=\"ut\"} ((\$1==\"Sess\")&&(\$2==\"SQL\")){state=\"sql\"} (NF==0){state=0} ((state==\"ut\")&&(NF==10)&&(\$2~\"-\")&&(\$3~\"^[0-9][0-9]*$\")){ # userthread UT=\$1; nreadsP[UT]=nreads[UT];nwritesP[UT]=nwrites[UT] sid[UT]=\$3;flagUT[UT]=\$2 nreads[UT]=\$9;nwrites[UT]=\$10 nreadsD[UT]=nreads[UT]-nreadsP[UT] nwritesD[UT]=nwrites[UT]-nwritesP[UT] } ((state==\"sql\")&&(\$1~\"^[0-9][0-9]*\")){stmt[\$1]=substr(\$0,7,14) gsub(\" [ ]*\",\"\",stmt[\$1])} function prt(i ,nl){nl=0 for(UT in nreads){ if(nreadsD[UT]+nwritesD[UT]>0){ d=descr(flagUT[UT]) if(stmt[sid[UT]]!=\"\"){d=stmt[sid[UT]] \",\" d};nl++ pl=sprintf(\"%-8s %5ld %6ld %6ld %s\", UT,sid[UT],int(nreadsD[UT]/${t}),int(nwritesD[UT]/${t}),d) apl[nl]=pl;sf[nl]=nreadsD[UT]+nwritesD[UT] } } sort(nl,sf,ind) for(i=1;i<=nl;i++){print apl[ind[i]]} printf(\"***********************************************************\n\") printf(\"UserThrd Sid Reads Writes Description\n\") printf(\"***********************************************************\n\") #printf(\" -%s-#%ld*${t}=%lds|${HOSTNAME}|%ldL\n\", #tf[2],ni,ni*${t},nl) } function sort(n,sf,ind ,j,k,i){ for(j=1;j<=n;j++){ind[j]=j} for(k=n;k>=2;k--){ for(j=2;j<=k;j++){ if(sf[ind[j-1]]-sf[ind[j]]>0){i=ind[j];ind[j]=ind[j-1];ind[j-1]=i} } } } function descr(flags ,i,o,c){o=\"\" for(i=1;i<=length(flags);i++){c=substr(flags,i,1) if((c!=\"-\")&&(P[i,c]!=\"\")){o=o \",\" P[i,c]} } return(substr(o,2)) }" } MA0 ;; #---------------------------------------------------------------------------- # Long Transactions - Displays transactions spanning more than one logical # log #---------------------------------------------------------------------------- 12) #MA# 12#Long Transactions MA1(){ t=5 clear; trap ";" 2 onstat -luxr ${t} | nawk " BEGIN{x=\"Logs Sid \" x=x \"Locks Reads Writes (%ld free logs out of %ld)\n\" } ((NF==2)&&(\$1==\"Logical\")){nlogB=0;nlogT=0} (\$1==\"INFORMIX-OnLine\"){ni++ if(ntr>0){prt();ntr=0 for(s in ut){delete ut[s];delete flagTR[s]; delete locks[s];delete logN[s] } for(s in sid){ delete sid[s];delete flagUT[s] delete nreads[s];delete nwrites[s]} }else{s=\$0;gsub(\"Version \",\"\",s) gsub(\"-- \",\"\",s);} } ((NF==7)&&(\$2~\"-\")&&(\$5~\"^[0-9][0-9]*$\")){ #transactions log1=\$5 if(log1>0){ntr++;ut[ntr]=\$3;flagTR[ntr]=\$2;locks[ntr]=\$4; logN[ntr]=log1} } ((NF==10)&&(\$2~\"-\")&&(\$3~\"^[0-9][0-9]*$\")){ # userthread UT=\$1;sid[UT]=\$3;flagUT[UT]=\$2;nreads[UT]=\$9;nwrites[UT]=\$10 } ((NF==8)&&(\$3~\"-\")&&(\$4~\"^[0-9][0-9]*$\")){ #logs nlogT++;fl=\$3;uniqid=\$4 if((fl~\"^U-B\")||(fl~\"F------\")){nlogB++} if(substr(fl,5,1)==\"C\"){idC=\$4} } END{ prt() } function prt(i){ printf(\"**************************************\n\") printf(x,nlogB,nlogT) printf(\"**************************************\n\") for(i=1;i<=ntr;i++){ if((idC-logN[i])>0){ printf(\"%3ld %5ld %5ld %8ld %8ld\n\", (idC-logN[i]), sid[ut[i]],locks[i],nreads[ut[i]],nwrites[ut[i]])} } }" } MA1 ;; 13) #MA# 13#Table Locks clear;echo "Please wait..." onstat -k | nawk " BEGIN{A=\"0123456789abcdef\"; print \"database sysmaster;set isolation to dirty read;\"} ((NF==8)&&(\$6~\"^[0-9a-f]*$\")){tabnum=\$6 t=\$5; gsub(\"^HDR\",\"\",t); gsub(\"^\\\+\",\"\",t) n[tabnum]++;type[tabnum]=t } END{ for(tabnum in n){ printf(\" select dbsname,tabname,'%s','%8ld','##'\", type[tabnum],n[tabnum]) printf(\" from sysmaster:systabnames\") printf(\" where partnum = %ld ;\n\",hex_dec(tabnum)) } } function hex_dec(s ,r,s1,s2,i){ r=0;s1=s while(s1!=\"\"){ r*=16 s2=substr(s1,1,1) s1=substr(s1,2) i=index(A,s2) if(i==0){print \"ERROR:\"s,NR,\$0} r+=(i-1) } return(r) } " | dbaccess - 2>&1 | sort -k 2,2 | nawk " ((\$NF==\"##\")&&(NF==5)){ n++;dbs[n]=\$1;tab[n]=\$2;type[n]=\$3;nl[n]=\$4 ntype[type[n]]++;nlock[type[n]]+=nl[n] } END{ for(t in ntype){ if(t!=\"S\"){ printf(\"**** %ld [%s] locks on table(s):\n\",nlock[t],t,ntype[t]) for(i=1;i<=n;i++){dt=tab[i] if(dbs[i]!=\"${INFORMIX_DBID}\"){dt=dbs[i] \":\" dt} if(type[i]==t){printf(\" %14s(%3ld)\n\",dt,nl[i])} } printf(\"\n\n\") } } } " | pg -csnp " Table locks Page %d>" ;; 14) #MA# 14#Dbspaces sizes clear;PS=2 # Size of Informix page, Kbytes onstat -d | nawk " BEGIN{tI=\"INFORMIX-OnLine\"} (\$1==\"Dbspaces\"){st=1}(\$1==\"Chunks\"){st=2} ((st==1)&&(NF>7)&&(\$2~/[0-9][0-9]*/)){ dbs[\$2]=\$NF if(\$NF~\"^psap\" ){type[\$NF]=\"D \"} if(\$NF~\"^rootdbs\" ){type[\$NF]=\"D \"} if(\$NF~\"^logdbs\" ){type[\$NF]=\"W \"} if(\$NF~\"^physdbs\"){type[\$NF]=\"W \"} if(\$NF~\"^tmpdbs\" ){type[\$NF]=\"W \"} } ((st==2)&&(NF>7)&&(\$3~/[0-9][0-9]*/)){ #size[dbs[\$3]]+=\$5*${PS};free[dbs[\$3]]+=\$6*${PS} if(\$(NF-1)~\"^M\"){M[dbs[\$3]]=1;sizeM+=\$5*${PS} } else{ size[dbs[\$3]]+=\$5*${PS};free[dbs[\$3]]+=\$6*${PS} } } (\$1==tI){s=\$0;gsub(\"-- \",\"\",s);gsub(tI,\"\",s); print s} END{TT=\"XZ\" for(dv in size){ if(M[dv]==1){YNM=\"M\"}else{YNM=\"-\"} printf(\"%s %-16s %9ld %9ld %9ld %5.1f %s\n\",type[dv],dv, size[dv],free[dv],(size[dv]-free[dv]),(100*free[dv]/size[dv]), YNM) sizeT[type[dv]]+=size[dv] freeT[type[dv]]+=free[dv] sizeT[TT]+=size[dv] freeT[TT]+=free[dv] } for(s in type){te[type[s]]=1};te[TT]=1 for(s in te){ if(sizeT[s]==0){q=0}{q=1/sizeT[s]} printf(\"%s %-16s %9ld %9ld %9ld %5.1f ****************\n\", substr(s,1,1) \"Z\" ,\"TOTAL by \" s, sizeT[s],freeT[s],(sizeT[s]-freeT[s]),(100*freeT[s]*q)) } printf(\"%s %-16s %9ld M\n\", \"YZ\" ,\"TOTAL Mirror\" ,sizeM) printf(\"**** ${HOSTNAME} at ${date} ****\n\") }" | sort | pg -csnp \ " dbspace Alloc,Kb Free,Kb Used,Kb %free Page %d>" ;; 15) #MA# 15#TBLspaces sizes echo "Please wait..." dbaccess ${INFORMIX_DBID} <<-EOF 2>/dev/null | \ egrep -v "^[ ]*\$" | sort | uniq | pg -sncp "(TBLspaces)%d>" select DBINFO('DBSPACE', b.partnum) dbspace ,sum(2*b.nptotal) allocated ,sum(2*b.npused) used_data ,round(100-(100*sum(2*b.npused)/sum(2*b.nptotal)),1) free_pct from sysmaster:sysptnhdr b group by 1 order by 1 ; select '~TOTAL ' dbspace ,sum(2*b.nptotal) allocated ,sum(2*b.npused) used_data ,round(100-(100*sum(2*b.npused)/sum(2*b.nptotal)),1) free_pct from sysmaster:sysptnhdr b group by 1 ; EOF ;; #------------------------------------------------------------------------- # This option gives info about who is locking what and the related table, # SQL and other related information. #------------------------------------------------------------------------- 16) #MA# 16#Who Locks Whom? clear;echo "Please wait...";EX="#EXIT" (onstat -usk;echo "${EX}") >lock.log;cat lock.log | nawk "BEGIN{ FR=\" FROM [^ ]* \" sql1=\"Current SQL statement :\" sql2=\"Last parsed SQL statement :\" t=\"INFORMIX-OnLine Version \" nkw=split(\"INTO FROM SELECT VALUES ORDER GROUP FOR SET WHERE INSERT DELETE\",kw) } {s=\$0;s1=\$1} (s~t){state=\"\";T=s gsub(t,\"\",T);gsub(\"-- \",\"\",T) split(T,a);T=substr(T,index(T,a[2])) for(s in Ut){delete Ut[s]} for(s in Lo){delete Lo[s]} for(s in La){delete La[s]} } ((s1~\"^Userthreads\")&&(NF==1)){state=\"Ut\"} (s~\"^Latches with\"){state=\"La\"} ((s1~\"^Locks\")&&(NF==1)){state=\"Lo\"} ((state==\"Ut\")&&(NF==10)&&(\$2~\"-\")){Ut[s1]=s;nut++} ((state==\"La\")&&(NF==5)&&(\$3~\"^[0-9][0-9]*$\")){La[s1]=s;nla++} ((state==\"Lo\")&&(NF>7)&&(\$3~\"^[0-9a-f][0-9a-f]*$\")){Lo[s1]=s;nlo++} (s==\"${EX}\"){exit} END{printf(\" Total UserThreads=%5ld, Total Locks=%5ld, Total Latches=%5ld\n\",nut,nlo,nla) for(ut1 in Ut){split(Ut[ut1],a) if((a[7]!=0)||(a[2]~\"L\")){wait_addr=a[6];sid=a[3] sid2=sid_lock_owner(wait_addr) if(sid2==\"\"){ sid2=sid_latch_owner(wait_addr) if(sid2!=\"\"){ printf(\" Session %s waits latch of session %s\n\",sid,sid2)} }else{ np++ printf(\"\n################ Session %s: \n\",sid) prtSQL(sid) printf(\"################ waits lock %s[%s] owned by session %s:\n\", wait_addr,type_lock(wait_addr),sid2) prtSQL(sid2) } } } if(np==0){print \"No lock waits\"} } function sid_ut(ut ,ut2,c){ for(ut2 in Ut){split(Ut[ut2],c);if(c[1]==ut){return(c[3])}} return(\"\") } function sid_latch_owner(addr ,la,b){ for(la in La){split(La[la],b);if(b[2]==addr){return(b[5])}} return(\"\") } function type_lock(addr, lo,b){ for(lo in Lo){split(Lo[lo],b);if(b[1]==addr){return(b[5])}} return(\"\") } function sid_lock_owner(addr, lo,b){ for(lo in Lo){ split(Lo[lo],b); if(b[1]==addr){return(sid_ut(b[3]))} } return(\"\") } function prtSQL(sid ,state,s,s0,com){s0=\"\" com=\"onstat -g ses \" sid while( com | getline ){s=\$0 if(s~sql2){state=\"\";s0=toupper(s0) gsub(\"^[ ]*\",\"\",s0) gsub(\" [ ]*\",\" \",s0) gsub(\"\\\([ ]*\",\"\(\",s0) gsub(\"[ ]*\\\)\",\"\)\",s0) gsub(\"[ ]*,[ ]*\",\",\",s0) gsub(\"[ ]*=[ ]*\",\"=\",s0) gsub(\" AND \",\" \\\& \",s0) ef=extract_FROM(s0) if(ef!=\"\"){print \"Table(s): \" ef} for(i=1;i<=nkw;i++){gsub(\" \" kw[i] \" \",\"\n__\" kw[i] \" \",s0)} # gsub(\"SELECT \",\"SELECT\n\",s0) print s0 } else{ if(s~sql1){state=\"SQL\"} else{ if(state==\"SQL\"){s0=s0 \$0 if(length(s0)>30000){print s0;s0=\"\"} } } } } close(com) } function extract_FROM(s ,s0,m,s1,s2 ){ s0=s s2=\"\" m=match(s0,FR) while(m>0){ s1=substr(s0,RSTART+6,RLENGTH-6) s0=substr(s0,RSTART+RLENGTH) if(s2!=\"\"){s2=s2 \"+\" s1}else{s2=s1} m=match(s0,FR) } return(s2) } " | pg -csnp " Who locks whom? ${HOSTNAME} %d>" rm lock.log ;; 17) #MA# 17#Dbspaces IO statistics clear;echo "Please wait...";PS=2 # Size of Informix page, Kbytes onstat -D | nawk " BEGIN{tI=\"INFORMIX-OnLine\"} (\$1==\"Dbspaces\"){st=1}(\$1==\"Chunks\"){st=2} ((st==1)&&(NF>7)&&(\$2~/[0-9][0-9]*/)){dbs[\$2]=\$NF} ((st==2)&&(NF==7)&&(\$3~/[0-9][0-9]*/)){ pagRd[dbs[\$3]]+=\$5*2;pagWr[dbs[\$3]]+=\$6*2} (\$1==tI){s=\$0;gsub(\"-- \",\"\",s);gsub(\"Version \",\"\",s); print s} END{ for(dv in pagRd){pagRdT+=pagRd[dv];pagWrT+=pagWr[dv] } for(dv in pagRd){ pctR=0;if(pagRdT>1){pctR=100*pagRd[dv]/pagRdT} pctW=0;if(pagWrT>1){pctW=100*pagWr[dv]/pagWrT} printf(\"%-11s %9ld %5.1f %9ld %5.1f\n\",dv, pagRd[dv],pctR, pagWr[dv],pctW) } printf(\"%-11s %9ld %5.1f %9ld %5.1f\n\",\"~TOTAL:\", pagRdT,100,pagWrT,100) freeT+=free[dv];sizeT+=size[dv] printf(\"**** Dbspace IO statistics **** ${HOSTNAME} ****\n\") }" | egrep -v "INFORMIX" | sort -k 1| pg -csnp \ "dbspace Read,Kb %% Write,Kb %% Page %d>" ;; #------------------------------------------------------------------------ # This gives the (in ascending order) the connected time for each session #------------------------------------------------------------------------ 18) #MA# 18#Session connected time clear;echo "Please wait..." echo "database sysmaster; select sid ses_id ,pid proc_id, hostname, round(((select max(connected) from sysscblst) - connected)/3600,3) hrs_conn from sysscblst where (connected - (select min(connected) from sysscblst where connected > 0) > 300) and ((select max(connected) from sysscblst) - connected > 0 ); " | dbaccess sysmaster 2>/dev/null | egrep -v '^[ ]*$' \ | pg -cnsp " Session Connected Time Page %d>" ;; #----------------------------------------------------------------------------- # This script displays checkpoint information (For Today, Current Month, All) #----------------------------------------------------------------------------- 19) clear;echo "Please wait......\c" mp=`grep MSGPATH $INFORMIXDIR/etc/$ONCONFIG | nawk '{print $2}'` CC="Checkpoint Completed" egrep "${CC}|199[8-9][ ]*$" ${mp} | nawk "{s=\$0} (s~\"199[8-9][ ]*\\$\"){day=substr(s,1,11);} ((day!=0)&&(s~\"${CC}\")){time=\$1;stamp=day time;dur=\$(NF-1); split(time,a,\":\"); sec_p=sec;sec=a[3]+60*(a[2]+60*a[1]); d=sec-sec_p;if(d<0){d+=60*60*24;} printf(\" %s %4ld %3ld Secs\n\",stamp,d,dur); } " | grep "`date | cut -c1-10`" | pg -csnp "Checkpoints: Date & Time Interval Duration Page %d>" ;;#MA# 19#Checkpoint Info(Today) 20) clear;echo "Please wait......\c" mp=`grep MSGPATH $INFORMIXDIR/etc/$ONCONFIG | nawk '{print $2}'` CC="Checkpoint Completed" egrep "${CC}|199[8-9][ ]*$" ${mp} | nawk "{s=\$0} (s~\"199[8-9][ ]*\\$\"){day=substr(s,1,11);} ((day!=0)&&(s~\"${CC}\")){time=\$1;stamp=day time;dur=\$(NF-1); split(time,a,\":\"); sec_p=sec;sec=a[3]+60*(a[2]+60*a[1]); d=sec-sec_p;if(d<0){d+=60*60*24;} printf(\" %s %4ld %3ld Secs\n\",stamp,d,dur); } " | grep `date | cut -f2,3 -d ' '` | pg -csnp "Checkpoints: Date & Time Interval Duration Page %d>" ;;#MA# 20#Checkpoint Info(Curr Month) 21) clear;echo "Please wait......\c" mp=`grep MSGPATH $INFORMIXDIR/etc/$ONCONFIG | nawk '{print $2}'` CC="Checkpoint Completed" egrep "${CC}|199[8-9][ ]*$" ${mp} | nawk "{s=\$0} (s~\"199[8-9][ ]*\\$\"){day=substr(s,1,11);} ((day!=0)&&(s~\"${CC}\")){time=\$1;stamp=day time;dur=\$(NF-1); split(time,a,\":\"); sec_p=sec;sec=a[3]+60*(a[2]+60*a[1]); d=sec-sec_p;if(d<0){d+=60*60*24;} printf(\" %s %4ld %3ld Secs\n\",stamp,d,dur); } " | grep `date | cut -f2,3 -d ' '` | pg -csnp "Checkpoints: Date & Time Interval Duration Page %d>" ;;#MA# 21#Checkpoint Info(All) *) WRONG $fnn;; esac done glob="`echo "${glob}" | sed "s/.$//g"`" } #----------------------------# End of functions #------------------------------# ################################################################################ # START OF THE PROGRAM ################################################################################ glob="" MENU_A echo echo "Quitting........ Please wait......." clear exit ################################################################################ # END OF THE PROGRAM ################################################################################