Nmon (Nigel’s Monitor)是由IBM 提供、免费监控 AIX 系统与 Linux 系统资源的工具。该工具可将服务器系统资源耗用情况收集起来并输出一个特定的文件,并可利用 excel 分析工具(nmon analyser)进行数据的统计分析。
搜索下载nmon,上传到服务器解压。我用一个比较老的版本给大家演示一下。解压完有nmon16e_x86_rhel65,和nmon analyser v34a.xls。
启动nmon的命令如下,启动后自动后台运行
./nmon16e_x86_rhel65 -f -s 10 -c 999999999 -m ./
若首次执行失败提示Permission Denied,执行
chmod +x nmon16e_x86_rhel65 即可。
参数解释:
[root@localhost nmontest]# ./nmon16e_x86_rhel65 -f -s 10 -c 999999999 -m ./ [root@localhost nmontest]# ls -lrt total 372 -rwxr-xr-x. 1 root root 347506 Jul 1 2016 nmon16e_x86_rhel65 -rw-r--r--. 1 root root 29653 Aug 5 15:02 localhost_200805_1502.nmon
监控文件的名字由“主机名+时间”组成,nmon文件按照采样间隔,不断写入数据
[root@localhost nmontest]# tail -f localhost_200805_1502.nmon VM,T0004,2,0,0,1247,7428,-1,0,0,0,0,37,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 PROC,T0004,1,0,81.4,-1.0,-1.0,-1.0,0.8,-1.0,-1.0,-1.0 NET,T0004,0.0,0.1,0.0,0.0,0.0,0.1,0.0,0.0 NETPACKET,T0004,0.0,1.5,0.0,0.0,0.0,0.8,0.0,0.0 JFSFILE,T0004,29.6,0.0,1.4,29.6,13.3 DISKBUSY,T0004,0.0,0.0,0.0,0.0,0.0,0.0 DISKREAD,T0004,0.0,0.0,0.0,0.0,0.0,0.0 DISKWRITE,T0004,0.0,0.0,0.0,0.0,0.0,0.0 DISKXFER,T0004,0.0,0.0,0.0,0.0,0.0,0.0
采集结束,关闭nmon
[root@localhost nmontest]# ps -ef | grep nmon root 5226 1 0 15:02 pts/0 00:00:00 ./nmon16e_x86_rhel65 -f -s 10 -c 999999999 -m ./ root 6626 3519 0 15:24 pts/0 00:00:00 grep --color=auto nmon [root@localhost nmontest]# kill -9 5226
将nmon文件传到本地电脑(ASCII格式传输),用nmon analyser v34a.xls转换格式。如果有宏相关的警告,按“工具->宏->安全性->选择低安全性”即可。
会多次弹窗,问是否替换现有x86定义,全都点击是。
保存xls格式的文件。打开xls文件。下方标签名称代表该标签监控的硬件指标,
下面是网络和内存使用的监控指标。
nmon可以长期采集硬件信息,设置采集间隔大的话对服务器性能影响可以忽略不计。适用于采集一段时间,例如采集几天,然后汇总分析的场景。通过分析硬件资源的占用变化原因,会有很多新的发现,使我们对系统的掌握更加透彻。但不适用实时监控的要求。