shell oracle
#!/bin/sh traffic=10 rm -rf test.txt data=`sqlplus -S anoscfg/anoscfg <<EOF spool test.txt set pages 0 set feed off set heading off; set feedback off; set verify off; set linesize 1000; select TIME_START, SGSN, round(UL_FLOW/(1024*1024),0), round(DL_FLOW/(1024*1024),0) from (select * from RT_SGSN_FLOW_5 order by TIME_start desc ) where rownum <5; EOF` data_1_up=`echo $data |awk -F' ' '{print $3}'` data_2_up=`echo $data |awk -F' ' '{print $7}'` data_11_up=`echo $data |awk -F' ' '{print $11}'` data_22_up=`echo $data |awk -F' ' '{print $15}'` num_092_up=`expr ${data_11_up} / ${traffic}` num_221_up=`expr ${data_22_up} / ${traffic}` if [ ${data_1_up} -lt ${num_092_up} ];then echo 'alarm' 'warning' 'is' "SGSN 092 UL_flow $data_1_up -lt $data_11_up `date '+%Y-%m-%d %T'`" "$HOSTNAME" fi if [ $data_2_up -lt $num_221_up ];then echo 'alarm' 'warning' 'is' "SGSN 221 UL_flow $data_2_up -lt $data_22_up `date '+%Y-%m-%d %T'`" "$HOSTNAME" fi