AIX日志收集整理脚本
问题:
aix服务器数据库进程报警,收集整理日志进行处理
脚本
AIX日志收集整理脚本,收集一段时间内/proc用户的进程数及目录
收集0点到11点之间日志统计信息
#!/bin/bash
TIME1_log () {
for i in {00..11};do
for j in {00..08};do
HR=$(echo "${j}+01"|bc)
echo ${i} ${j} ${HR}
echo '--------------------' >> ./test1
DATETIME=$(egrep "^Fri Mar 11 ${i}:${j}" result.log)
echo ${DATETIME}
echo ${DATETIME} >> ./test1
PROC=$(egrep -A 2 "^Fri Mar 11 ${i}:${j}" result.log|tail -1|awk '{print $1}')
echo "proctotal: ${PROC} " >> ./test1
echo '--------------------' >> ./test1
sed -nr "/Fri Mar 11 ${i}:${j}/,/Fri Mar 11 ${i}:0${HR}/p" result.log |egrep -e '^[-dbclps]' |grep -v '^------------' |awk '{print $3}'|sort -nr|uniq -c |sort -nr >> ./test1
done
done
}
TIME2_log () { for i in {00..11};do for j in {09..58};do HR=$(echo "${j}+01"|bc) echo ${i} ${j} ${HR} echo '--------------------' >> ./test1 DATETIME=$(egrep "^Fri Mar 11 ${i}:${j}" result.log) echo ${DATETIME} echo ${DATETIME} >> ./test1 PROC=$(egrep -A 2 "^Fri Mar 11 ${i}:${j}" result.log|tail -1|awk '{print $1}') echo "proctotal: ${PROC} " >> ./test1 echo '--------------------' >> ./test1 sed -nr "/Fri Mar 11 ${i}:${j}/,/Fri Mar 11 ${i}:${HR}/p" result.log |egrep -e '^[-dbclps]' |grep -v '^------------' |awk '{print $3}'|sort -nr|uniq -c |sort -nr >> ./test1 done done
}
TIME3_log () {
for i in {00..11};do
for j in 00;do
echo ${i} ${j}
echo '--------------------' >> ./test1
DATETIME=$(egrep "^Fri Mar 11 ${i}:${j}" result.log)
echo ${DATETIME}
echo ${DATETIME} >> ./test1
PROC=$(egrep -A 2 "^Fri Mar 11 ${i}:${j}" result.log|tail -1|awk '{print $1}')
echo "proctotal: ${PROC} " >> ./test1
echo '--------------------' >> ./test1
sed -nr "/Fri Mar 11 ${i}:${j}/,/Fri Mar 11 ${i}:${j}/p" result.log |egrep -e '^[-dbclps]' |grep -v '^------------' |awk '{print $3}'|sort -nr|uniq -c |sort -nr >> ./test1
done
done
}
TIME1_log
TIME2_log
TIME3_log
收集信息为