龚哥哥 - 山里男儿 爱生活、做自己!
Linux上排查IO使用过高的进程
发表于 2016-12-7 | 浏览(8044) | 服务器

iotop 命令

CentOS7以下使用yum安装
    yum -y install iotop
    iotop
CentOS7由于yum源没有包
    git clone git://repo.or.cz/iotop.git
        cd iotop
        python iotop.py

iostat 命令

iostat -x 1 10

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           5.48    0.00    1.24   10.22    4.28   78.78

Device:         rrqm/s   wrqm/s     r/s     w/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
xvda              0.37     3.00   27.30    5.47   722.00   173.14    54.64     0.78   23.81    9.61   94.70   1.40   4.58
xvdb              0.00     0.00    0.32    0.00     2.19     0.00    13.75     0.00    5.39    5.30   31.00   2.73   0.09
xvdc              1.29    21.12  130.74   13.60  3575.35   175.45    51.97     2.97   20.55   21.01   16.15   4.78  69.03

%idle小于70% IO压力就较大了,一般读取速度有较多的%wait.
如果 %util 接近 100%,说明产生的I/O请求太多,I/O系统已经满负荷,该磁盘可能存在瓶颈。

dstat 命令

dstat --top-io -d --top-bio -l
dstat -t --top-io-adv -d -l

监控工具,根据系统类型选择脚本然后直接运行即可,以下是centos

centos下直接
  yum -y install nmon

其它linux系统可以下载包使用
wget http://sourceforge.net/projects/nmon/files/nmon_linux_14i.tar.gz
tar -zxvf http://sourceforge.net/projects/nmon/files/nmon_linux_14i.tar.gz
./nmon_x86_64_centos6

阅读全文

Linux磁盘使用量监控
发表于 2016-11-2 | 浏览(6489) | 服务器

Linux中使用crontab定时运行脚本即可。添加文件 vim disk.sh

#!/bin/bash

#@desc:服务器磁盘使用量报警脚本
#@author:Devil
#@blog:http://gong.gg/
#@date:2016-11-02

# 获取磁盘使用量
list=`df -h | awk 'NR==2,NR==$NF{print int(substr($5,0,length($5)-1));}'`

# 计算磁盘超过比例的值
server='博客'
max=95
count=0
for i in $list
do
    if [ $i -ge $max ]
    then
        let count++
    fi
done

# 邮件通知
if [ $count -gt 0 ]
then
    echo "亲^_^!您的[${server}]服务器有${count}块磁盘使用超过${max}%,请尽快处理哦~" | mail -v -s '服务器磁盘使用量报警' xxx[at]gongfuxiang.com
fi

邮件发送方法,搜索本博客中的文章

阅读全文

TOP