192.168.50.235配置
[root@BMS006 ~]# cat /shell/compress_syslogs.sh
#!/bin/bash
set -x
#Author:welsey
#Date:2011/11/25
LOGFILE_DIR=/data/syslogs
CurYear=`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/sh
set -x
LOGFILE="/tmp/gzip.log"
DIR="/data/applogs"
cd $DIR
for i in `find ./ -type f -mtime +30 | grep BMS | grep -v gz | grep log`
do
echo $i >> $LOGFILE
gzip $i
done
exit
#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/sh
Year=$(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.log
File2=/data/applogs/BMS016/$Year/$Month/$Day/local2.log
fun(){
#订购鉴权
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 ser1
logfile="/opt/backup/backup.log"
#
echo "--------------------------" >> $logfile
echo $(date +"%y-%m-%d %H:%M:%S") >> $logfile
echo "--------------------------" >> $logfile
date1=$(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!!" >> $logfile
for i in `cat /opt/backup/weblist`
do
mkdir -p $bakdir/$date1"$i"
cd $i/
pwd
tar czf $bakdir/$date1"$i"/$date1.tar.gz ./*
if [ -f $bakdir/$date1"$i"/$date1.tar.gz ]
then
echo "web backup success!" >> $logfile
else
echo "web backup no success!" >> $logfile
fi
cd $bakdir
if [ -d $olddir ]
then
rm $olddir -rf >> $logfile 2>&1
echo "rm olddir success!!" >> $logfile
else
echo "there no olddir!!" >> $logfile
fi
done
[root@BMS006 ~]# cat /shell/bms3aexpect.sh
#!/usr/bin/expect -f
spawn scp /shell/bms3acount.txt root@192.168.35.186:/root/BMS/
set timeout 20
expect "(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/profile
logfile="/tmp/count.log"
echo "--------------------------" >> $logfile
echo $(date +"%y-%m-%d %H:%M:%S") >> $logfile
echo "--------------------------" >> $logfile
date1=$(date +%Y/%m/%d)
countdir="/opt/count"
datedir=$(date +%Y/%m/%d --date='1 days ago')
echo "start count!!" >> $logfile
mkdir -p $countdir/$datedir
cd /data/applogs/BMS001/$datedir
awk -F "<Result>" '{print $2}' local2.log | tr -s "\n" | awk -F "<" '{print $1}' > $countdir/$datedir/data.txt
cd /data/applogs/BMS016/$datedir
awk -F "<Result>" '{print $2}' local2.log | tr -s "\n" | awk -F "<" '{print $1}' >> $countdir/$datedir/data.txt
cat $countdir/$datedir/data.txt | sort | uniq -c | sort -nr > $countdir/$datedir/count.txt
cp $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/profile
logfile="/tmp/dgtd.log"
echo "--------------------------" >> $logfile
echo $(date +"%y-%m-%d %H:%M:%S") >> $logfile
echo "--------------------------" >> $logfile
date1=$(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!!" >> $logfile
cd /data/applogs/BMS001/$datedir
grep "</InstantSubscribeRequest>" ./local1.log|grep "<Action>1</Action>" > /sanss/ftproot/3A_dgqq_$date2.log
grep "</InstantSubscribeRequest>" ./local1.log|grep "<Action>2</Action>" > /sanss/ftproot/3A_tdqq_$date2.log
grep "</ns1:instantSubscribeResponse>" ./local2.log|grep "<Description>1</Description>" |grep "<Result>0" > /sanss/ftproot/3A_dg_$date2.log
grep "</ns1:instantSubscribeResponse>" ./local2.log|grep "<Description>2</Description>" |grep "<Result>0</Result>" > /sanss/ftproot/3A_td_$date2.log
cd /data/applogs/BMS016/$datedir
grep "</InstantSubscribeRequest>" ./local1.log|grep "<Action>1</Action>" >> /sanss/ftproot/3A_dgqq_$date2.log
grep "</InstantSubscribeRequest>" ./local1.log|grep "<Action>2</Action>" >> /sanss/ftproot/3A_tdqq_$date2.log
grep "</ns1:instantSubscribeResponse>" ./local2.log|grep "<Description>1</Description>" |grep "<Result>0" >> /sanss/ftproot/3A_dg_$date2.log
grep "</ns1:instantSubscribeResponse>" ./local2.log|grep "<Description>2</Description>" |grep "<Result>0</Result>" >> /sanss/ftproot/3A_td_$date2.log
local_dir=/sanss/ftproot/
dgqqlog=3A_dgqq_$date2.log
tdqqlog=3A_tdqq_$date2.log
tydglog=3A_dg_$date2.log
tytdlog=3A_td_$date2.log
cd /sanss/ftproot/
ftp -v -n 192.168.40.125 << EOF
user huangjia HuangJia111
binary
prompt
lcd $local_dir
mput $dgqqlog $tdqqlog $tydglog $tytdlog
close
bye
EOF
[root@BMS006 ~]# cat /shell/jianquanqingdan.sh
#!/bin/sh
# 0 3 * * * /shell/jianquanqingdan.sh > /dev/null
#2013-11-19 by ser1
. /etc/profile
logfile="/tmp/jianquanqingdan.log"
echo "--------------------------" >> $logfile
echo $(date +"%y-%m-%d %H:%M:%S") >> $logfile
echo "--------------------------" >> $logfile
date1=$(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!!" >> $logfile
cd /data/applogs/BMS001/$datedir
grep "</ns1:identifyBusinessResponse" ./local2.log |awk -F'<Result>' '{print $2}'| awk -F "[<>]" '{print $1"|"$5}' > /opt/jianquanqingdan/yewujianquan_$date2.txt
grep "</ns1:instantSubscribeResponse>" ./local2.log |grep "<Description>1</Description>" | awk -F'<Result>' '{print $2}'| awk -F "[<>]" '{print $1"|"$5}' >> /opt/jianquanqingdan/dinggoujianquan_$date2.txt
cd /data/applogs/BMS016/$datedir
grep "</ns1:identifyBusinessResponse" ./local2.log |awk -F'<Result>' '{print $2}'| awk -F "[<>]" '{print $1"|"$5}' >> /opt/jianquanqingdan/yewujianquan_$date2.txt
grep "</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 ~]#