性能监控

#!/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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值