服务器维护脚本2
. $HOME/shell/dalertenv.sh##############################################
####check connect to oracle
##############################################
HOST=`hostname`
value=$1
sdate=`date +%Y-%m-%d:%H:%M:%S`
sqlplus ${USER}/${PASSWD}@${SID} << ! |grep "终端数" >$HOME/shell/zdnum.lst
select '终端数:' ||count(1) from (
select (terminal_pos_info.COLLECTION_TIME -sysdate)*24*60*60 ctt
FROM a CAR, a TERMINAL, CORP_INFO CORP, terminal_pos_info
WHERE CAR.TERMINAL_ID = TERMINAL.TERMINAL_IDAND CAR.CORP_NO = CORP.CORP_NO
andcorp.CORP_NO in (1019,1190,628) and terminal_pos_info.msisdn=terminal.msisdn
order by ctt) where ctt > -120
/
exit
!
znum=`cat /zdnum.lst |grep -v "||" |awk -F ":" '{print $2}'`
echo "znum=$znum"
DataHour=`date +%k`
#DataHour=`expr $strDataHour`
echo "DataHour=$DataHour"
if [ $DataHour -lt 9 ] || [ $DataHour -gt 20 ];
then
carcount=430
else
carcount=470
fi
echo "carcount=$carcount"
if [ $znum -lt $carcount ]
then
sqlplus ${USER}/${PASSWD}@${SID} << ! >/dev/null
insert into SMS_PUSH_REC (SERIAL_NO,USER_PHONE,SERV_NO,LONG_SERV_NO,OUT_GATEWAY_ID,INSERT_TIME,VALID_TIME,SEND_FLAG,SERV_TYPE,SMS_TYPE,SEND_CONTENT)
values
(SEQ_SMS_PUSH_REC.nextval, '15899181163','1107','10657009','2',sysdate,sysdate, 0,'02',0,'位置上报终端数($znum)');
insert into SMS_PUSH_REC (SERIAL_NO,USER_PHONE,SERV_NO,LONG_SERV_NO,OUT_GATEWAY_ID,INSERT_TIME,VALID_TIME,SEND_FLAG,SERV_TYPE,SMS_TYPE,SEND_CONTENT)
values
(SEQ_SMS_PUSH_REC.nextval, '13999297104','1107','10657009','2',sysdate,sysdate, 0,'02',0,'位置上报终端数($znum)');
commit;
exit
!
else
echo "$sdate 数据正常 znum=$znum">>$HOME/log/checkpos.log
fi
页:
[1]