[root@BMS006 ~]# cat /shell/compress_syslogs.sh
#!/bin/bashset -x#Author:welsey#Date:2011/11/25LOGFILE_DIR=/data/syslogsCurYear=`date +%Y` CurMonth=`date +%m` CurDay=`date +%d` GetYear="$CurYear"GetMonth="$CurMonth"GetYesterday="`expr $CurDay - 1`" hostlist="BMS001 BMS002"filenamelist="cron kern messages secure"for host in $hostlist do cd $LOGFILE_DIR/$host/$GetYear/$GetMonth/$GetYesterday for filename in $filenamelist do tar zcvf $filename.tar.gz $filename rm -rf $filename done done[root@BMS006 ~]# cat /data/applogs/gzip.sh#!/bin/shset -xLOGFILE="/tmp/gzip.log"DIR="/data/applogs"cd $DIRfor i in `find ./ -type f -mtime +30 | grep BMS | grep -v gz | grep log`do echo $i >> $LOGFILE gzip $i doneexit#for i in `cat logall.txt `#do# cd $i # gzip local0.log# gzip local1.log# gzip local2.log# gzip local3.log# gzip local4.log# gzip local5.log# gzip local6.log#done
[root@BMS006 ~]# cat /shell/jianquan.sh
#!/bin/shYear=$(date -d '1 day ago' +%Y)Month=$(date -d '1 day ago' +%m)Day=$(date -d '1 day ago' +%d)File1=/data/applogs/BMS001/$Year/$Month/$Day/local2.logFile2=/data/applogs/BMS016/$Year/$Month/$Day/local2.logfun(){ #订购鉴权 echo "订购鉴权异常统计" echo -e " Count\tResult" grep '<Description>1</Description>' $File1 $File2|awk -F'<Result>' '{print $2}'|awk -F'</Result>' '{print $1}'|sort |uniq -c #退订鉴权 echo "退订鉴权异常统计" echo -e " Count\tResult" grep "<Description>2</Description>" $File1 $File2|awk -F'<Result>' '{print $2}'|awk -F'</Result>' '{print $1}'|sort |uniq -c #业务鉴权 echo "业务鉴权异常统计" echo -e " Count\tResult" grep "</ns1:identifyBusinessResponse" $File1 $File2|awk -F'<Result>' '{print $2}'|awk -F'</Result>' '{print $1}'|sort |uniq -c #登录鉴权 echo "登录鉴权异常统计" echo -e " Count\tResult" grep "</ns1:loginResponse" $File1 $File2|awk -F'<Result>' '{print $2}'|awk -F'</Result>' '{print $1}'|sort |uniq -c}fun > /var/log/3a/$Year-$Month-$Day.log
[root@BMS006 ~]# cat /opt/backup/rc.backup.sh
#!/bin/bash# 0 2 * * * /opt/backup/rc.backup.sh > /dev/null#2012-11-21 by ser1logfile="/opt/backup/backup.log"#echo "--------------------------" >> $logfileecho $(date +"%y-%m-%d %H:%M:%S") >> $logfileecho "--------------------------" >> $logfiledate1=$(date +%Y%m%d)bakdir="/opt/backup"#httpdir=`cat /opt/backup/weblist`olddir=$(date +%Y%m%d --date='7 days ago')echo "start web backup!!" >> $logfilefor i in `cat /opt/backup/weblist`domkdir -p $bakdir/$date1"$i"cd $i/pwdtar czf $bakdir/$date1"$i"/$date1.tar.gz ./*if [ -f $bakdir/$date1"$i"/$date1.tar.gz ] thenecho "web backup success!" >> $logfileelseecho "web backup no success!" >> $logfileficd $bakdirif [ -d $olddir ]thenrm $olddir -rf >> $logfile 2>&1echo "rm olddir success!!" >> $logfileelseecho "there no olddir!!" >> $logfilefidone
[root@BMS006 ~]# cat /shell/bms3aexpect.sh
#!/usr/bin/expect -fspawn scp /shell/bms3acount.txt root@192.168.35.186:/root/BMS/set timeout 20expect "(yes/no)?" { send "yes\r"}expect "password:" { send "3344134\r" }expect eof#set Year [exec date +%Y]#set Month [exec date +%m]#set Day [exec date +%d-1]#spawn scp /var/log/3a/$Year-$Month-$Day.log root@192.168.35.186:~/BMS/#set timeout 20#expect "(yes/no)?" { #send "yes\r"}#expect "assword:" { #send "3344134\r" }#expect eof
[root@BMS006 ~]# cat /shell/bms3acount.sh
#!/bin/sh# 0 6 * * * /shell/bms3acount.sh > /dev/null#2013-09-04 by ser1. /etc/profilelogfile="/tmp/count.log"echo "--------------------------" >> $logfileecho $(date +"%y-%m-%d %H:%M:%S") >> $logfileecho "--------------------------" >> $logfiledate1=$(date +%Y/%m/%d)countdir="/opt/count"datedir=$(date +%Y/%m/%d --date='1 days ago')echo "start count!!" >> $logfilemkdir -p $countdir/$datedircd /data/applogs/BMS001/$datedirawk -F "<Result>" '{print $2}' local2.log | tr -s "\n" | awk -F "<" '{print $1}' > $countdir/$datedir/data.txtcd /data/applogs/BMS016/$datedirawk -F "<Result>" '{print $2}' local2.log | tr -s "\n" | awk -F "<" '{print $1}' >> $countdir/$datedir/data.txtcat $countdir/$datedir/data.txt | sort | uniq -c | sort -nr > $countdir/$datedir/count.txtcp $countdir/$datedir/count.txt /shell/bms3acount.txt
[root@BMS006 ~]# cat /shell/3adgtd.sh
#!/bin/sh# 0 2 * * * /shell/3adgtd.sh > /dev/null#2013-11-04 by ser1. /etc/profilelogfile="/tmp/dgtd.log"echo "--------------------------" >> $logfileecho $(date +"%y-%m-%d %H:%M:%S") >> $logfileecho "--------------------------" >> $logfiledate1=$(date +%Y/%m/%d)datedir=$(date +%Y/%m/%d --date='1 days ago')date2=$(date +%Y%m%d --date='1 days ago')echo "start dgtd!!" >> $logfilecd /data/applogs/BMS001/$datedirgrep "</InstantSubscribeRequest>" ./local1.log|grep "<Action>1</Action>" > /sanss/ftproot/3A_dgqq_$date2.loggrep "</InstantSubscribeRequest>" ./local1.log|grep "<Action>2</Action>" > /sanss/ftproot/3A_tdqq_$date2.loggrep "</ns1:instantSubscribeResponse>" ./local2.log|grep "<Description>1</Description>" |grep "<Result>0" > /sanss/ftproot/3A_dg_$date2.loggrep "</ns1:instantSubscribeResponse>" ./local2.log|grep "<Description>2</Description>" |grep "<Result>0</Result>" > /sanss/ftproot/3A_td_$date2.logcd /data/applogs/BMS016/$datedirgrep "</InstantSubscribeRequest>" ./local1.log|grep "<Action>1</Action>" >> /sanss/ftproot/3A_dgqq_$date2.loggrep "</InstantSubscribeRequest>" ./local1.log|grep "<Action>2</Action>" >> /sanss/ftproot/3A_tdqq_$date2.loggrep "</ns1:instantSubscribeResponse>" ./local2.log|grep "<Description>1</Description>" |grep "<Result>0" >> /sanss/ftproot/3A_dg_$date2.loggrep "</ns1:instantSubscribeResponse>" ./local2.log|grep "<Description>2</Description>" |grep "<Result>0</Result>" >> /sanss/ftproot/3A_td_$date2.loglocal_dir=/sanss/ftproot/dgqqlog=3A_dgqq_$date2.logtdqqlog=3A_tdqq_$date2.logtydglog=3A_dg_$date2.logtytdlog=3A_td_$date2.logcd /sanss/ftproot/ftp -v -n 192.168.40.125 << EOF user huangjia HuangJia111 binary prompt lcd $local_dir mput $dgqqlog $tdqqlog $tydglog $tytdlogclose bye EOF
[root@BMS006 ~]# cat /shell/jianquanqingdan.sh
#!/bin/sh# 0 3 * * * /shell/jianquanqingdan.sh > /dev/null#2013-11-19 by ser1. /etc/profilelogfile="/tmp/jianquanqingdan.log"echo "--------------------------" >> $logfileecho $(date +"%y-%m-%d %H:%M:%S") >> $logfileecho "--------------------------" >> $logfiledate1=$(date +%Y/%m/%d)datedir=$(date +%Y/%m/%d --date='1 days ago')date2=$(date +%Y%m%d --date='1 days ago')echo "start jianquanqingdan!!" >> $logfilecd /data/applogs/BMS001/$datedirgrep "</ns1:identifyBusinessResponse" ./local2.log |awk -F'<Result>' '{print $2}'| awk -F "[<>]" '{print $1"|"$5}' > /opt/jianquanqingdan/yewujianquan_$date2.txtgrep "</ns1:instantSubscribeResponse>" ./local2.log |grep "<Description>1</Description>" | awk -F'<Result>' '{print $2}'| awk -F "[<>]" '{print $1"|"$5}' >> /opt/jianquanqingdan/dinggoujianquan_$date2.txtcd /data/applogs/BMS016/$datedirgrep "</ns1:identifyBusinessResponse" ./local2.log |awk -F'<Result>' '{print $2}'| awk -F "[<>]" '{print $1"|"$5}' >> /opt/jianquanqingdan/yewujianquan_$date2.txtgrep "</ns1:instantSubscribeResponse>" ./local2.log |grep "<Description>1</Description>" | awk -F'<Result>' '{print $2}'| awk -F "[<>]" '{print $1"|"$5}' >> /opt/jianquanqingdan/dinggoujianquan_$date2.txt[root@BMS006 ~]#