Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> awk question
Thanks for the advice on the Darrell!
I am trying to implements and running into an issue. Can you or anyone
else provide some additional guidance, it is much appreciated.
Here is what I have thus far:
#!/bin/ksh
SID=$1
cd /m1/homes/oracle
. ./$SID
export WARNING_THRESHHOLD=55
export CRITICAL_THRESHHOLD=65
export TBS_WARNING=`orastat -ts | awk '{print $10}' | grep -vi generic | grep -vi pct | grep -vi === | grep -vi listed | grep -vi accurat` export TBS_CRITICAL=`orastat -ts | awk '{print $10}' | grep -vi generic | grep -vi pct | grep -vi === | grep -vi listed | grep -vi accurat`
export CHK_TBS_WARNING="$TBS_WARNING $WARNING_THRESHHOLD" export CHK_TBS_CRITICAL="$TBS_CRITICAL $CRITICAL_THRESHHOLD" export CHK_TBS_WARNING_EVAL=`echo $CHK_TBS_WARNING | awk '{if ($1 > $2)print $1}'`
if [ $CHK_TBS_CRITICAL_EVAL -gt 65 ]; then
./orastat -ts|mailx -s "TBS CRITICAL for $SID" dgreen-email elif [ $CHK_TBS_WARNING_EVAL -gt 55 ]; then
./orastat -ts|mailx -s "TBS WARNING for $SID" dgreen-email fi
I receive the following, when trying to run: ./check_tbs.sh[18]: test: argument expected ./check_tbs.sh[20]: test: argument expected
I think it is because the CHK_TBS_WARNING_EVAL and CHK_TBS_CRITICAL_EVAL systax I'm using is not working. I think that is due to the tbs percents are being returned as a row of numbers and thus the comparision of $1 > $2 is no good:
+ SID=SDTEST01
+ cd /m1/homes/oracle
+ . ./SDTEST01
+ test
/bin:/sbin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sony-bin:/usr/local/etc:/usr/ucb:/usr/bin/X11:/usr/dt/bin:/usr/openwin/bin:/opt/SUNWspro/bin:/usr/ccs/bin:.
= X
+ ORACLE_SID=SDTEST01
+ ORACLE_BASE=/opt/app/oracle
+ ORACLE_HOME=/opt/app/oracle/product/9.2.0.4
+ ORACLE_PATH=/opt/app/oracle/product/9.2.0.4/bin
+ ORACLE_TERM=vt100
+ INIT=/opt/app/oracle/admin/SDTEST01/pfile/initSDTEST01.ora
+ ALERT=/opt/app/oracle/admin/SDTEST01/bdump/alert_SDTEST01.log
+ BDUMP=/opt/app/oracle/admin/SDTEST01/bdump
+ CDUMP=/opt/app/oracle/admin/SDTEST01/cdump
+ UDUMP=/opt/app/oracle/admin/SDTEST01/udump
+ OSCRIPTS=/opt/app/oracle/scripts
+ TNS_ADMIN=/var/opt/oracle
+
PATH=/usr/ccs/bin:/opt/app/oracle/product/9.2.0.4/bin:/opt/app/oracle/product/9.2.0.4:/bin:/sbin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sony-bin:/usr/local/etc:/usr/ucb:/usr/bin/X11:/usr/dt/bin:/usr/openwin/bin:/opt/SUNWspro/bin:/usr/ccs/bin:.
+
LD_LIBRARY_PATH=/opt/app/oracle/product/9.2.0.4/lib:/opt/app/oracle/product/9.2.0.4/jdbc/lib:/usr/openwin/lib:/usr/dt/lib:/usr/lib:/lib
+ export LD_LIBRARY_PATHPATH OSCRIPTS UDUMP CDUMP BDUMP INIT ALERT TNS_ADMIN
+ export ORACLE_BASE ORACLE_HOME ORACLE_PATH ORACLE_SID ORACLE_TERM
+ alias alert=tail -500 $ALERT|more
+ PS1=\u@\h_at_SDTEST01>
+ export WARNING_THRESHHOLD=55
+ export CRITICAL_THRESHHOLD=65
+ orastat -ts
+ awk {print $10}
+ grep -vi generic
+ grep -vi pct
+ grep -vi ===
+ grep -vi accurat
+ grep -vi listed
+ export TBS_WARNING=
62.8 61.0 34.4 22.4 11.9 9.9 3.8 0.1 0.0 0.0
62.8 61.0 34.4 22.4 11.9 9.9 3.8 0.1 0.0 0.0
62.8 61.0 34.4 22.4 11.9 9.9 3.8 0.1 0.0 0.0
62.8 61.0 34.4 22.4 11.9 9.9 3.8 0.1 0.0 0.0
Thanks for any further ideas and assistance! - David
-----Original Message-----
From: oracle-l-bounce_at_freelists.org [mailto:oracle-l-bounce_at_freelists.org]
On Behalf Of Darrell Landrum
Sent: Tuesday, June 08, 2004 8:55 PM
To: oracle-l_at_freelists.org
Subject: Re: awk question
Here is an example of one idea, although there may be a cleaner way. I've used an ls -l command to get a particular file size instead of the orastat in your code, then compare that to a previously defined threshold. Basically, I take the threshold and the ls result and concat them into one variable with a space in between. Then, send that value into your awk statement for the test of $1 to $2.
hp19:/home/dlandrum $ cat ak
export WARNING_THRESHHOLD=10
export TBS_WARNING=`ls -l test.ksh| awk '{print $5}'`
export CHK_TBS_WARNING="$TBS_WARNING $WARNING_THRESHHOLD"
echo $CHK_TBS_WARNING | awk '{if ($1 > $2) print $1}'
hp19:/home/dlandrum $ ksh -x ak
+ export WARNING_THRESHHOLD=10
+ awk {print $5}
+ ls -l test.ksh
+ export TBS_WARNING=21
+ export CHK_TBS_WARNING=21 10
+ echo 21 10
+ awk {if ($1 > $2) print $1}
21
Can someone please fill me in on if and how I can use the commented out
threshhold variables(after uncommenting) and reference those variables in
my awk test/evaluation in place of the hardcoded values($10 > 55 or 65).
Thanks
- David
#!/bin/ksh
SID=$1
cd /m1/homes/oracle
. ./$SID
#export WARNING_THRESHHOLD=55
#export CRITICAL_THRESHHOLD=65
export TBS_WARNING=`orastat -ts | awk '{if ($10 > 55) print $10}' | grep
-vi generic | grep -vi pct | grep -vi === | gr
ep -vi listed | grep -vi accurat`
export TBS_CRITICAL=`orastat -ts | awk '{if ($10 > 65) print $10}' | grep
-vi generic | grep -vi pct | grep -vi === | g
rep -vi listed | grep -vi accurat`
echo $TBS_WARNING
echo $TBS_CRITICAL
if [ $TBS_CRITICAL -gt 65 ]; then
./orastat -ts|mailx -s "TBS CRITICAL for $SID" dgreen_at_soe.sony.com elif [ $TBS_WARNING -gt 55 ]; then
./orastat -ts|mailx -s "TBS WARNING for $SID" dgreen_at_soe.sony.com fi
-- Archives are at http://www.freelists.org/archives/oracle-l/ FAQ is at http://www.freelists.org/help/fom-serve/cache/1.html -----------------------------------------------------------------Received on Wed Jun 09 2004 - 12:06:16 CDT
![]() |
![]() |