First, download the nmon
Download the appropriate version according to system type:
http://nmon.sourceforge.net/pmwiki.php?n=Site.Download
Currently centos7 system used by most servers, so I chose
https://jaist.dl.sourceforge.net/project/nmon/nmon16h_helpsystems_v2.tar.gz
Second, the installation nmon
[root@mululu ~]# cd ~ [root@mululu opt]# mkdir nmon [root@mululu opt]# cd nmon [root@mululu nmon]# tar zxvf nmon16h_helpsystems_v2.tar.gz [root@mululu nmon]# mv nmon_x86_64_centos7 nmon [root@mululu nmon]# chmod +x nmon [root@mululu nmon]#./nmon
After performing ./nmon we can see the screen as shown in FIG.
CPU, memory, disk and network consumption are very intuitive to show up.
Key "c" can see the CPU-related information;
Button "d" can view the disk information;
"M" corresponding to the memory, "n" and the like corresponding to the network;
Complete shortcut keys corresponding content can be viewed by helping (the key "h").
可以显示Linux系统CPU、内存、进程信息,包括了CPU的用户、系统、等待和空闲状态值,可用内存、缓存大小以及进程的CPU消耗等详细指标。该种方式显示信息实时性强,能够及时掌握系统承受压力下的运行情况,每颗CPU利用率是多少、内存使用多少、网络流量多少、磁盘读写……这些数据均是实时刷新,一目了然。
三、生成nmon报告
1、采集系统数据
[root@mululu nmon]#./nmon -s10 -c60 -f -m ~/nmon
参数说明:
-s10 每10秒采集一次数据
-c60 采集60次,即执行总时间为10*60为10分钟
-f 生成的数据文件中包含文件的创建时间
-m 生成的数据文件的存放目录
这条命令会在nmon目录下生成一个nmon文件
2、生成报表
下载nmon analyser(生成报告的免费工具)
根据需要下载相应的版本,这里我下载的是60版本
将之前生成的moon文件,下载下来,用Excel打开分析工具 nmon analyser v60.xlsm.点击Excel文件中的 "Analyze nmon data" 按钮,选择 nmon 数据文件,这样就会生成一个分析后的结果文件,打开该结果文件就可以获取到相应的结果了
如果使用WPS打开,会提示没有VBA支持库需要开会员下载,这里我就没有使用WPS了,不过网上有相应的攻略,根据需要选择
3、定时任务
除配合性能测试的短期监控外,也可以使用定时任务对服务器进行长期监控
1) 执行命令:#crontab –e
2) 在最后一行添加如下命令:
0 8 * * 1,2,3,4,5 /nmon/nmon -f -N -m /nmon/log -s 30 -c 1200
表示:
周一到周五,从早上08点开始,监控10个小时(到18:00整为止),输出到/nmon/log
自动按天采集数据:
在 crontab 中增加一条记录:
0 0 * * * root nmon -s300 -c288 -f -m /nmon/log > /dev/null 2>&1
300*288=86400 秒,正好是一天的数据。