- 论坛徽章:
- 0
|
在HP服务器上装的ORACLE数据库,想用脚本监控表空间情况, < 10的时候触发相应的动作。 用sql语句只取了三个字段的内容,一个是表空间的名称,一个是表空间的剩余百分比,最后一个就是真正剩余的多少,是以M为单位的。
我在AIX的机器上测试脚本都没有问题,可是移到HP机器上老是报错就。
脚本如下:
vi table_space.sh
"table_space.sh" 65 lines, 2853 characters
#!/bin/sh
###################################################################
#THE SCRIPT creat time: 2008-04-11
#THE SCRIPT NOTE is : watch the table_space
###################################################################
CMD_PATH=/usr/bin
ORACLE_BASE=/oracle/app;export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/9.2.0;export ORACLE_HOME
ORACLE_SID=siebdb;export ORACLE_SID
TEST_BASE=/oracle/itm6;export TEST_BASE
PATH=$PATH ORACLE_HOME/bin TEST_BASE:.
export PATH
ALARM_PATH="/oracle/itm6/patrol_event"
HOST_IP=10.4.44.24
TIME_VAL="`date '+%y/%m/%d %H:%M:%S'`"
#sqlplus ${DB_USER}/${DB_PASS}@${Service_Name} <<! >/dev/null
sqlplus '/as sysdba' <<! >/dev/null
set linesize 800
set head off
set feedback off
set termout off
WHENEVER SQLERROR EXIT FAILURE
WHENEVER OSERROR EXIT FAILURE
spool spaceview.txt
SELECT tablespace_name ,100*(sum_max-sum_alloc+nvl(sum_free,0))/sum_max ,(sum_max-sum_alloc+nvl(sum_free,0))/10
24/1024 FROM ( SELECT tablespace_name, sum(bytes) AS sum_alloc, sum(decode(maxbytes,0,bytes,maxbytes)) AS sum
_max FROM dba_data_files GROUP BY tablespace_name),( SELECT tablespace_name AS fs_ts_name, sum(bytes) AS sum_fr
ee FROM dba_free_space GROUP BY tablespace_name )WHERE tablespace_name = fs_ts_name(+)order by 1;
!
$CMD_PATH/cat spaceview.txt|$CMD_PATH/grep -v '^SQL'|sed '/^$/d' > $TEST_BASE/oracle.log
while read LINE
do
s=$LINE
FRE_NU=`$CMD_PATH/echo $s|awk '{ if ($2 < 10) print $2}'`
TABLE_NAME=`echo $s|awk '{ if( $2 < 10) print $1}'`
FRE_TOAL=`$CMD_PATH/echo $s|awk '{ if ( $2 < 10) print $3}'`
echo "FRE_NU is FRE_NU" > log1.log
if [ $FRE_NU < 10 ] ;then
$CMD_PATH/echo $TIME_VAL >>log4.log
echo "${ALARM_PATH}/AddExtEvent.sh HOST_IP $TABLE_NAME tb_space Nms minor $FRE_NU $FRE_TOAL 36 "${TIME_VAL}"">>
$TEST_BASE/table_space.log
fi
done < $TEST_BASE/oracle.log
执行后总是报错,说是table_space.sh[37]: 10: Cannot find or open the file.
然后我用sh -x table_space.sh 看了一下脚本的执行过程,都是到了if判断这就出问题了,请帮忙看一下,是什么原因呢?
sh -x table_space.sh
+ CMD_PATH=/usr/bin
+ ORACLE_BASE=/oracle/app
+ export ORACLE_BASE
+ ORACLE_HOME=/oracle/app/product/9.2.0
+ export ORACLE_HOME
+ ORACLE_SID=siebdb
+ export ORACLE_SID
+ TEST_BASE=/oracle/itm6
+ export TEST_BASE
+ PATH=/usr/sbin:/usr/bin:/opt/ansic/bin:/usr/ccs/bin:/usr/contrib/bin:/opt/hparray/bin:/opt/nettladm/bin:/opt/upgrade/bin:/opt/fcms/bin:/opt/pd/bin:/usr/bin/X11:/usr/contrib/bin/X11:/opt/resmon/bin:/opt/aCC/bin:/opt/gnome/bin:/opt/ignite/bin:/opt/mozilla:/opt/wbem/bin:/opt/wbem/sbin:/opt/hpsmh/bin:/opt/perl/bin:/opt/ssh/bin:/opt/langtools/bin:/opt/imake/bin:/opt/gwlm/bin:/usr/sbin/diag/contrib:/opt/graphics/common/bin:/opt/perf/bin:/sbin:/home/root:/oracle/app/product/9.2.0/bin:/oracle/itm6:.
+ export PATH
+ ALARM_PATH=/oracle/itm6/patrol_event
+ HOST_IP=10.4.44.24
+ + date +%y/%m/%d %H:%M:%S
TIME_VAL=08/04/28 14:12:46
+ sqlplus /as sysdba
+ 0< /var/tmp/sh20193.1 1> /dev/null
+ /usr/bin/cat spaceview.txt
+ /usr/bin/grep -v ^SQL
+ sed /^$/d
+ 1> /oracle/itm6/oracle.log
+ 0< /oracle/itm6/oracle.log
+ read LINE
+ s=EIM_DATA 58.7422917 35245.375
+ + awk { if ($2 < 10) print $2}
+ /usr/bin/echo EIM_DATA 58.7422917 35245.375
FRE_NU=
+ + awk { if( $2 < 10) print $1}
+ echo EIM_DATA 58.7422917 35245.375
TABLE_NAME=
+ + awk { if ( $2 < 10) print $3}
+ /usr/bin/echo EIM_DATA 58.7422917 35245.375
FRE_TOAL=
+ echo FRE_NU is :
+ 1> log1.log
+ [ ]
+ table_space.sh[37]: 10: Cannot find or open the file.
+ read LINE
+ s=EIM_IDX 71.0909856 36967.3125
+ + awk { if ($2 < 10) print $2}
+ /usr/bin/echo EIM_IDX 71.0909856 36967.3125
FRE_NU=
+ + echo EIM_IDX 71.0909856 36967.3125
+ awk { if( $2 < 10) print $1}
TABLE_NAME=
+ + awk { if ( $2 < 10) print $3}
+ /usr/bin/echo EIM_IDX 71.0909856 36967.3125
FRE_TOAL=
+ echo FRE_NU is :
+ 1> log1.log
+ [ ]
+ table_space.sh[37]: 10: Cannot find or open the file.
+ read LINE
+ s=SIEB_DATA 5.95303775 156294.625
+ + awk { if ($2 < 10) print $2}
+ /usr/bin/echo SIEB_DATA 5.95303775 156294.625
FRE_NU=5.95303775
+ + awk { if( $2 < 10) print $1}
+ echo SIEB_DATA 5.95303775 156294.625
TABLE_NAME=SIEB_DATA
+ + awk { if ( $2 < 10) print $3}
+ /usr/bin/echo SIEB_DATA 5.95303775 156294.625
FRE_TOAL=156294.625
+ echo FRE_NU is :5.95303775
+ 1> log1.log
+ [ 5.95303775 ]
+ table_space.sh[37]: 10: Cannot find or open the file.
+ read LINE
+ s=SIEB_IDX 11.2030312 239668.688
+ + awk { if ($2 < 10) print $2}
+ /usr/bin/echo SIEB_IDX 11.2030312 239668.688
FRE_NU=
+ + echo SIEB_IDX 11.2030312 239668.688
+ awk { if( $2 < 10) print $1}
TABLE_NAME=
+ + awk { if ( $2 < 10) print $3}
+ /usr/bin/echo SIEB_IDX 11.2030312 239668.688
FRE_TOAL=
+ echo FRE_NU is :
+ 1> log1.log
+ [ ]
+ table_space.sh[37]: 10: Cannot find or open the file.
+ read LINE
+ s=SYSTEM 68.1660156 1363.32031
+ + /usr/bin/echo SYSTEM 68.1660156 1363.32031
+ awk { if ($2 < 10) print $2}
FRE_NU=
+ + echo SYSTEM 68.1660156 1363.32031
+ awk { if( $2 < 10) print $1}
TABLE_NAME=
+ + awk { if ( $2 < 10) print $3}
+ /usr/bin/echo SYSTEM 68.1660156 1363.32031
FRE_TOAL=
+ echo FRE_NU is :
+ 1> log1.log
+ [ ]
+ table_space.sh[37]: 10: Cannot find or open the file.
+ read LINE
+ s=TIVOLIORTS 74.7025994 12213.875
+ + awk { if ($2 < 10) print $2}
+ /usr/bin/echo TIVOLIORTS 74.7025994 12213.875
FRE_NU=
+ + awk { if( $2 < 10) print $1}
+ echo TIVOLIORTS 74.7025994 12213.875
TABLE_NAME=
+ + awk { if ( $2 < 10) print $3}
+ /usr/bin/echo TIVOLIORTS 74.7025994 12213.875
FRE_TOAL=
+ echo FRE_NU is :
+ 1> log1.log
+ [ ]
+ table_space.sh[37]: 10: Cannot find or open the file.
+ read LINE
+ s=UNDOTBS 32.5243317 19465.8125
+ + awk { if ($2 < 10) print $2}
+ /usr/bin/echo UNDOTBS 32.5243317 19465.8125
FRE_NU=
+ + awk { if( $2 < 10) print $1}
+ echo UNDOTBS 32.5243317 19465.8125
TABLE_NAME=
+ + awk { if ( $2 < 10) print $3}
+ /usr/bin/echo UNDOTBS 32.5243317 19465.8125
FRE_TOAL=
+ echo FRE_NU is :
+ 1> log1.log
+ [ ]
+ table_space.sh[37]: 10: Cannot find or open the file.
+ read LINE |
|