- 论坛徽章:
- 0
|
问题解决,看效果
本帖最后由 lq2003 于 2010-04-19 15:00 编辑
在本地执行结果如下:
root@WYdb1 # sh -x /usr/local/nagios/libexec/check_oracle --tablespace noap gdnoap ****** NOAP_PCOUNT_INDX 90 80
+ basename /usr/local/nagios/libexec/check_oracle
PROGNAME=check_oracle
+ sed -e s,[\/][^\/][^\/]*$,,
+ echo /usr/local/nagios/libexec/check_oracle
PROGPATH=/usr/local/nagios/libexec
+ sed -e s/[^0-9.]//g
+ echo $Revision: 1749 $
REVISION=1749
+ . /usr/local/nagios/libexec/utils.sh
STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3
STATE_DEPENDENT=4
+ test -x /usr/bin/printf
ECHO=/usr/bin/printf
cmd=--tablespace
+ [ -z ]
+ [ ! -f /var/opt/oracle/oratab ]
IFS=:
+ read SID ORACLE_HOME junk
+ [ # = noap -o # = * ]
+ read SID ORACLE_HOME junk
+ [ = noap -o = * ]
+ read SID ORACLE_HOME junk
+ [ = noap -o = * ]
+ read SID ORACLE_HOME junk
+ [ = noap -o = * ]
+ read SID ORACLE_HOME junk
+ [ # This file is used by ORACLE utilities. It is created by root.sh = noap -o # This file is used by ORACLE utilities. It is created by root.sh = * ]
+ read SID ORACLE_HOME junk
+ [ # and updated by the Database Configuration Assistant when creating = noap -o # and updated by the Database Configuration Assistant when creating = * ]
+ read SID ORACLE_HOME junk
+ [ # a database. = noap -o # a database. = * ]
+ read SID ORACLE_HOME junk
+ [ = noap -o = * ]
+ read SID ORACLE_HOME junk
+ [ # A colon, ' = noap -o # A colon, ' = * ]
+ read SID ORACLE_HOME junk
+ [ # the entry. Lines beginning with a pound sign, '#', are comments. = noap -o # the entry. Lines beginning with a pound sign, '#', are comments. = * ]
+ read SID ORACLE_HOME junk
+ [ # = noap -o # = * ]
+ read SID ORACLE_HOME junk
+ [ # Entries are of the form = noap -o # Entries are of the form = * ]
+ read SID ORACLE_HOME junk
+ [ # $ORACLE_SID = noap -o # $ORACLE_SID = * ]
+ read SID ORACLE_HOME junk
+ [ # = noap -o # = * ]
+ read SID ORACLE_HOME junk
+ [ # The first and second fields are the system identifier and home = noap -o # The first and second fields are the system identifier and home = * ]
+ read SID ORACLE_HOME junk
+ [ # directory of the database respectively. The third filed indicates = noap -o # directory of the database respectively. The third filed indicates = * ]
+ read SID ORACLE_HOME junk
+ [ # to the dbstart utility that the database should , "Y", or should not, = noap -o # to the dbstart utility that the database should , "Y", or should not, = * ]
+ read SID ORACLE_HOME junk
+ [ # "N", be brought up at system boot time. = noap -o # "N", be brought up at system boot time. = * ]
+ read SID ORACLE_HOME junk
+ [ # = noap -o # = * ]
+ read SID ORACLE_HOME junk
+ [ # Multiple entries with the same $ORACLE_SID are not allowed. = noap -o # Multiple entries with the same $ORACLE_SID are not allowed. = * ]
+ read SID ORACLE_HOME junk
+ [ # = noap -o # = * ]
+ read SID ORACLE_HOME junk
+ [ # = noap -o # = * ]
+ read SID ORACLE_HOME junk
+ [ noap = noap -o noap = * ]
+ echo /export/home/oracle/product/10.2
+ exit
ORACLE_HOME=/export/home/oracle/product/10.2
+ [ -n /export/home/oracle/product/10.2 ]
+ break
+ [ -z /export/home/oracle/product/10.2 -a -d /usr/local/nagios/libexec/oracle ]
+ [ --tablespace != --db ]
+ [ -z /export/home/oracle/product/10.2 -o ! -d /export/home/oracle/product/10.2 ]
PATH=/usr/local/bin:/usr/sbin:/usr/sfw/bin:/usr/sfw/sbin:/usr/ccs/bin:/usr/sadm/admin/bin:/usr/local/ssl/bin:/usr/sbin:/usr/bin:/usr/ccs/bin:/usr/openwin/bin:/usr/dt/bin:/usr/platform/SUNW,SPARC-Enterprise/sbin:/opt/sun/bin:/usr/cluster/bin:/usr/cluster/lib/sc:/opt/SUNWexplo/bin:/opt/SUNWsneep/bin:/opt/CTEact/bin:/export/home/oracle/product/10.2/bin
LD_LIBRARY_PATH=/usr/local/lib:/usr/local/ssl/lib:/usr/sfw/lib/::/usr/openwin/lib:/export/home/oracle/product/10.2/lib
+ export ORACLE_HOME PATH LD_LIBRARY_PATH
+ [ 90 -lt 80 ]
+ sqlplus -s gdnoap/*****@noap
set pagesize 0
set numf '9999999.99'
select NVL(b.free,0.0),a.total,100 - trunc(NVL(b.free,0.0)/a.total * 1000) / 10 prc
from (
select tablespace_name,sum(bytes)/1024/1024 total
from dba_data_files group by tablespace_name) A
LEFT OUTER JOIN
( select tablespace_name,sum(bytes)/1024/1024 free
from dba_free_space group by tablespace_name) B
ON a.tablespace_name=b.tablespace_name WHERE a.tablespace_name='NOAP_PCOUNT_INDX';
result= 112642.63 122800.00 8.30
+ grep ORA-
+ echo 112642.63 122800.00 8.30
+ [ -n ]
+ awk /^[ 0-9\.\t ]+$/ {print int($1)}
+ echo 112642.63 122800.00 8.30
ts_free=112642
+ awk /^[ 0-9\.\t ]+$/ {print int($2)}
+ echo 112642.63 122800.00 8.30
ts_total=122800
+ awk /^[ 0-9\.\t ]+$/ {print int($3)}
+ echo 112642.63 122800.00 8.30
ts_pct=8
+ awk /^[ 0-9\.\t ]+$/ {print $3}
+ echo 112642.63 122800.00 8.30
ts_pctx=8.30
+ [ 112642 -eq 0 -a 122800 -eq 0 -a 8 -eq 0 ]
+ [ 8 -ge 90 ]
+ [ 8 -ge 80 ]
+ echo noap : NOAP_PCOUNT_INDX OK - 8.30% used [ 112642 / 122800 MB available ]|NOAP_PCOUNT_INDX=8.30%;80;90;0;100
noap : NOAP_PCOUNT_INDX OK - 8.30% used [ 112642 / 122800 MB available ]|NOAP_PCOUNT_INDX=8.30%;80;90;0;100 |
|