网络连接数监控:
echo "`date +\"%H:%M:%S\"`" >> /home/count/netstatmonitor/netmonitor.`date +%Y%m%d` netstat -n |grep 7001| awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}' >> /home/count/netstatmonitor/netmonitor.`date +%Y%m%d`
监控进程是否存在并重启:
#!/bin/bash echo > /home/count/start/testOK.jsp wget -q http://localhost:7001/templet/testOK.jsp -O /home/count/start/testOK.jsp & #wget -q --no-check-certificate https://localhost:8443/templet/testOK.jsp -O /home/count/start/testOK.jsp & sleep 5 cd /home/count/start size=$(ls -l | grep testOK.jsp | awk '{printf $5}') zero=0 rightline=7 right=7 if [ $size -eq $right ]; then echo "`date +\"%H:%M:%S\"` sss is ok" >> /home/count/start/`date +%Y%m%d`.data rm -f /home/count/start/line else echo "`date +\"%H:%M:%S\"` sss is not ok" >> /home/count/start/`date +%Y%m%d`.data process=$(ps -ef | grep tomcat | grep -c sss) if [ $process -gt $zero ]; then echo 1 >> /home/count/start/line linenum=$(wc -l /home/count/start/line | cut -c 1) if [ $linenum -gt $rightline ]; then rm -f /home/mecp/count/start/line num=$(ps -ef | grep tomcat | grep sss | head -n 1 | awk '{printf $2}') kill -9 $num sleep 10 num=$(ps -ef | grep tomcat | grep -c sss) if [ $num -gt $zero ]; then num=$(ps -ef | grep tomcat | grep sss | head -n 1 | awk '{printf $2}') kill -9 $num sleep 10 fi . /home/sss/setenv.sh /home/tomcat-6.0.32/bin/startup.sh fi else rm -f /home/count/start/line . /home/setenv.sh /home/tomcat-6.0.32/bin/startup.sh fi fi
做时间同步:
[root@sss ~]# crontab -l
*/30 * * * * /usr/sbin/ntpdate 40.40.40.100
执行sql操作
#!/bin/bash v_date=$(date +%Y%m%d); /oracle/product/10.2.0/bin/sqlplus -s 'name/passwaord@sid'<<EOF set pages 0 set feed off set heading off; set feedback off; set verify off; set trimout on; set trimspool on; set trims on; set linesize 4000; set pagesize 4000; spool /home/resourcesub_points_rec_$v_date.csv SELECT '1'||','||trim(DONEDATE)||',' FROM ponitsinfo where substr(donedate,0,8) =(select to_char( dt ,'YYYYMMDD') dt from (select sysdate-1 dt from dual)); spool off EOF