#!/bin/bash
# check_xingneng.sh
# 0 * * * * /home/check_xu.sh
DAT="`date +%Y%m%d`"
HOUR="`date +%H`"
hostname=`hostname`
DIR="`pwd`/function_logs"
DELAY=5
runtime=$1
filePrefix=$2
# whether the responsible directory exist
if ! test -d ${DIR}
then
/bin/mkdir -p ${DIR}
fi
# general check
export TERM=linux
/usr/bin/top -b -d $DELAY > ${DIR}/${hostname}_top.log 2>&1 &
# cpu check
/usr/bin/sar -u $DELAY $runtime > ${DIR}/${hostname}_cpu.log 2>&1 &
# memory check
/usr/bin/sar -r $DELAY $runtime > ${DIR}/${hostname}_mem.log 2>&1 &
# I/O check
/usr/bin/iostat -x -k $DELAY $runtime > ${DIR}/${hostname}_iostat.log 2>&1 &
# network check
/usr/bin/sar -n DEV $DELAY $runtime > ${DIR}/${hostname}_recive_net.log 2>&1 &
/usr/bin/sar -n DEV $DELAY $runtime > ${DIR}/${hostname}_send_net.log 2>&1 &
=================================================================================
=================================================================================
#!/bin/bash
#筛选后的日志路径
DIR="`pwd`/select_logs"
hostname=`hostname`
DAT="`date +%Y%m%d`"
if ! test -d ${DIR}
then
/bin/mkdir -p ${DIR}
fi
#进入完全日志路径
cd function_logs
#开始筛选cpu
awk '{print $1"\t"$8}' *cpu.log > ../select_logs/${hostname}${DAT}_cpu.log 2>&1 &
#筛选IO,
#$6为•rkB/s: 每秒读数据量(kB为单位)
#$7为•wkB/s: 每秒写数据量(kB为单位)
#$10为•await: 平均每次IO请求等待时间(包括等待时间和处理时间,毫秒为单位)
#$11为•svctm: 平均每次IO请求的处理时间(毫秒为单位)
awk '{if ($1 ~/^sd/) print $1"\t"$6"\t"$7"\t"$10"\t"$11}' *iostat.log > ../select_logs/${hostname}${DAT}_iostat.log 2>&1 &
#筛选内存
awk '{print $1"\t"$2"\t"$3"\t"$5"\t\t"$6}' *mem.log > ../select_logs/${hostname}${DAT}_mem.log 2>&1 &
#筛选网络发送量
#txkB/s: 每秒发的数据量(kB为单位)
awk '{if ($2 !~ /(IFACE)|(lo)/) print $1,$2"\t"$6}' *send*.log > ../select_logs/${hostname}${DAT}_send_net.log 2>&1 &
#筛选网络接收量
#rxkB/s: 每秒收的数据量(kB为单位)
awk '{if ($2 !~ /(IFACE)|(lo)/) print $1,$2"\t"$5}' *recive*.log > ../select_logs/${hostname}${DAT}_recive_net.log 2>&1 &
=================================================================================
=================================================================================
#!/bin/bash
pid=`ps -ef |grep sar|grep -v grep| awk '{print $2}'`
for i in $pid
do
kill -9 $i
done
pid=`ps -ef |grep iostat|grep -v grep| awk '{print $2}'`
for i in $pid
do
kill -9 $i
done
# check_xingneng.sh
# 0 * * * * /home/check_xu.sh
DAT="`date +%Y%m%d`"
HOUR="`date +%H`"
hostname=`hostname`
DIR="`pwd`/function_logs"
DELAY=5
runtime=$1
filePrefix=$2
# whether the responsible directory exist
if ! test -d ${DIR}
then
/bin/mkdir -p ${DIR}
fi
# general check
export TERM=linux
/usr/bin/top -b -d $DELAY > ${DIR}/${hostname}_top.log 2>&1 &
# cpu check
/usr/bin/sar -u $DELAY $runtime > ${DIR}/${hostname}_cpu.log 2>&1 &
# memory check
/usr/bin/sar -r $DELAY $runtime > ${DIR}/${hostname}_mem.log 2>&1 &
# I/O check
/usr/bin/iostat -x -k $DELAY $runtime > ${DIR}/${hostname}_iostat.log 2>&1 &
# network check
/usr/bin/sar -n DEV $DELAY $runtime > ${DIR}/${hostname}_recive_net.log 2>&1 &
/usr/bin/sar -n DEV $DELAY $runtime > ${DIR}/${hostname}_send_net.log 2>&1 &
=================================================================================
=================================================================================
#!/bin/bash
#筛选后的日志路径
DIR="`pwd`/select_logs"
hostname=`hostname`
DAT="`date +%Y%m%d`"
if ! test -d ${DIR}
then
/bin/mkdir -p ${DIR}
fi
#进入完全日志路径
cd function_logs
#开始筛选cpu
awk '{print $1"\t"$8}' *cpu.log > ../select_logs/${hostname}${DAT}_cpu.log 2>&1 &
#筛选IO,
#$6为•rkB/s: 每秒读数据量(kB为单位)
#$7为•wkB/s: 每秒写数据量(kB为单位)
#$10为•await: 平均每次IO请求等待时间(包括等待时间和处理时间,毫秒为单位)
#$11为•svctm: 平均每次IO请求的处理时间(毫秒为单位)
awk '{if ($1 ~/^sd/) print $1"\t"$6"\t"$7"\t"$10"\t"$11}' *iostat.log > ../select_logs/${hostname}${DAT}_iostat.log 2>&1 &
#筛选内存
awk '{print $1"\t"$2"\t"$3"\t"$5"\t\t"$6}' *mem.log > ../select_logs/${hostname}${DAT}_mem.log 2>&1 &
#筛选网络发送量
#txkB/s: 每秒发的数据量(kB为单位)
awk '{if ($2 !~ /(IFACE)|(lo)/) print $1,$2"\t"$6}' *send*.log > ../select_logs/${hostname}${DAT}_send_net.log 2>&1 &
#筛选网络接收量
#rxkB/s: 每秒收的数据量(kB为单位)
awk '{if ($2 !~ /(IFACE)|(lo)/) print $1,$2"\t"$5}' *recive*.log > ../select_logs/${hostname}${DAT}_recive_net.log 2>&1 &
=================================================================================
=================================================================================
#!/bin/bash
pid=`ps -ef |grep sar|grep -v grep| awk '{print $2}'`
for i in $pid
do
kill -9 $i
done
pid=`ps -ef |grep iostat|grep -v grep| awk '{print $2}'`
for i in $pid
do
kill -9 $i
done