码迷,mamicode.com
首页 > 数据库 > 详细

dstat mysql5-io 模块使用

时间:2014-07-22 22:52:14      阅读:552      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   使用   os   io   

[root@shylock dstat]# dstat --list
internal:
        aio, cpu, cpu24, disk, disk24, disk24old, epoch, fs, int, int24, io, ipc, load, lock, mem, net, page, page24, proc, raw, socket, swap, swapold, sys, tcp,
        time, udp, unix, vm
/usr/share/dstat:
        battery, battery-remain, cpufreq, dbus, disk-util, fan, freespace, gpfs, gpfs-ops, helloworld, innodb-buffer, innodb-io, innodb-ops, lustre, memcache-hits,
        mysql-io, mysql-keys, mysql5-cmds, mysql5-conn, mysql5-io, mysql5-keys, net-packets, nfs3, nfs3-ops, nfsd3, nfsd3-ops, ntp, postfix, power, proc-count, rpc,
        rpcd, sendmail, snooze, thermal, top-bio, top-cpu, top-cputime, top-cputime-avg, top-io, top-latency, top-latency-avg, top-mem, top-oom, utmp, vm-memctl,
        vmk-hba, vmk-int, vmk-nic, vz-cpu, vz-io, vz-ubc, wifi

 

当运行dstat 监控mysql io 的时候报连接不到mysql server

[root@shylock ~]# dstat --mysql5-io
Module dstat_mysql5_io failed to load. (Cannot interface with MySQL server)
None of the stats you selected are available.
[root@shylock ~]# cd /usr/share/dstat
[root@shylock dstat]# vi dstat_mysql5_io.py
      3 global mysql_user
      4 mysql_user = os.getenv(DSTAT_MYSQL_USER) or os.getenv(USER)
      5
      6 global mysql_pwd
      7 mysql_pwd = os.getenv(DSTAT_MYSQL_PWD)

在/usr/shared/dstat目录下有dstat的命令和插件
vi dstat_mysql5_io.py
在3-7行里有声明mysql_user 和mysql_pwd 
os.getenv(环境变量名称) 从环境变量中获取MYSQL的用户名密码
#!/bin/bash
#file:mysql5io.sh

export DSTAT_MYSQL_USER=‘user
export DSTAT_MYSQL_PWD=‘pwd

dstat --mysql5-io $@

编写shell脚本 --"$@" 数组  "$*" 字符串 

chmod 700 mysql5io.sh 
./mysql5io.sh 3 5  #停3秒,获取5次结果

-mysql5-io-
recv sent
1.00B 3.34B
778B 2618B
791B 2677B
804B 2736B
817B 2794B
830B 2853B

因为在脚本里 dstat --mysql5_io $@ 运行脚本传参数(参考dstat -h)

[root@shylock ~]# ./mysql5io.sh -c -s -m 3 5
-mysql5-io- ----total-cpu-usage---- ----swap--- ------memory-usage-----
 recv  sent|usr sys idl wai hiq siq| used  free| used  buff  cach  free
1.11B 3.75B| 16   2  78   4   0   0|   0  2016M|95.7M 41.5M  276M  594M
 885B 2996B|  0   0 100   0   0   0|   0  2016M|95.8M 41.5M  276M  594M
 898B 3055B|  0   0  99   0   0   0|   0  2016M|95.8M 41.5M  276M  594M
 911B 3114B|  0   0 100   0   0   0|   0  2016M|95.8M 41.5M  276M  594M
 924B 3172B|  0   0 100   0   0   0|   0  2016M|95.8M 41.5M  276M  594M
 937B 3231B|  0   0 100   0   0   0|   0  2016M|95.8M 41.5M  276M  594M

dstat mysql5-io 模块使用,布布扣,bubuko.com

dstat mysql5-io 模块使用

标签:style   blog   color   使用   os   io   

原文地址:http://www.cnblogs.com/jachin/p/3855290.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!