1. nmon gets the .nmon data file (centos6 environment)
1. Install nmon and execute the command:
wget https://nchc.dl.sourceforge.net/project/nmon/nmon16d_x86.tar.gz
Step 2: Unzip to a specified directory nmon16d_x86 (create it first)
Step 3: Add execution permissions to the nmon_x86_64_centos6 file, and then add the program file to the environment variable running directory
chmod +x nmon_x86_64_centos6
mv nmon_x86_64_centos6 /usr/local/bin/nmon
Step 4: Run nmon
nmon
q : 停止并退出 Nmon
h : 查看帮助
c : 查看 CPU 统计数据
m : 查看内存统计数据
d : 查看硬盘统计数据
k : 查看内核统计数据
n : 查看网络统计数据
N : 查看 NFS 统计数据
j : 查看文件系统统计数据
t : 查看高耗进程
V : 查看虚拟内存统计数据
v : 详细模式
...
Step 5: Generate .nmon file
nmon -f -T -s 10 -c 60 -m /tmp
-f 参数:生成文件,文件名=主机名+当前时间.nmon
-T 参数:显示资源占有率较高的进程
-s 参数:-s 10表示每隔10秒采集一次数据
-c 参数:-c 60表示总共采集60次数据
-m 参数:指定文件保存目录
2. Convert the .nmon data file into a csv file (environment Windows):
python install 3 packages
pip install matplotlib numpy pyNmonAnalyzer
Execute the command to convert into a csv file
pyNmonAnalyzer -c -x -o testOut -i blueking_200427_1454.nmon
-c 参数:-c 代表输出文件为csv
-x 参数:-x 覆盖,如果同名没有-x会执行命令报错
-o 参数:-o 输出文件 + 文件名
-i 参数:-i 输入文件名称
Simply wrote a demo to read these data
# -*- coding: utf-8 -*-
import os
path1 = os.getcwd() + '/testOut/csv/'
x = os.listdir(path1)
for i in x:
if i.endswith('.csv'):
with open(path1 + i, 'r') as f:
lines = f.readlines()
title = lines.pop(0)
print '==========================================='
print title
for m in lines:
print m
Execution result
You can design the table structure later, store all these data in the database, then process the data and return it to the front-end display.