Merge pull request #7163 from lujun9972/translate-MjAxMjEyMTEgUHl0aG9uIE5tb24gQW5hbHl6ZXItIG1vdmluZyBhd2F5IGZyb20gZXhjZWwgbWFjcm9zLm1kCg==

translate done: 20121211 Python Nmon Analyzer- moving away from excel…
This commit is contained in:
DarkSun 2018-01-14 18:32:58 +08:00 committed by GitHub
commit 1e882e3e89
2 changed files with 100 additions and 101 deletions

View File

@ -1,101 +0,0 @@
translating by lujun9972
Python Nmon Analyzer: moving away from excel macros
======
[Nigel's monitor][1], dubbed "Nmon", is a fantastic tool for monitoring, recording and analyzing a Linux/*nix system's performance over time. Nmon was originally developed by IBM and Open Sourced in the summer of 2009. By now Nmon is available on just about every linux platfrom and architecture. It provides a great real-time command line visualization of current system statistics, such as CPU, RAM, Network and Disk I/O. However, Nmon's greatest feature is the capability to record system performance snapshots over time.
For example: `nmon -f -s 1`.
![nmon CPU and Disk utilization][2]
This will create a log file starting of with some system metadata(Section AAA - BBBV), followed by timed snapshots of all monitored system attributes, such as CPU and Memory usage. This produces a file that is hard to directly interpret with a spreadsheet application, hence the birth of the [Nmon_Analyzer][3] excel macro. This tool is great, if you have access to Windows/Mac with Microsoft Office installed. If not there is also the Nmon2rrd tool, which generates RRD input files to generate your graphs. This is a very rigid approach and slightly painful. Now to provide a more flexible tool, I am introducing the pyNmonAnalyzer, which aims to provide a customization solution for generating organized CSV files and simple HTML reports with [matplotlib][4] based graphs.
### Getting Started:
System requirements:
As the name indicates you will need python. Additionally pyNmonAnalyzer depends on matplotlib and numpy. If you are on a debian-derivative system these are the packages you'll need to install:
```
$> sudo apt-get install python-numpy python-matplotlib
```
##### Getting pyNmonAnalyzer:
Either clone the git repository:
```
$> git clone git@github.com:madmaze/pyNmonAnalyzer.git
```
or
Download the current release here: [pyNmonAnalyzer-0.1.zip][5]
Next we need an an Nmon file, if you do not already have one, either use the example provided in the release or record a sample: `nmon -F test.nmon -s 1 -c 120`, this will record 120 snapshots at 1 second intervals to test.nmon.
Lets have a look at the basic help output:
```
$> ./pyNmonAnalyzer.py -h
usage: pyNmonAnalyzer.py [-h] [-x] [-d] [-o OUTDIR] [-c] [-b] [-r CONFFNAME]
input_file
nmonParser converts Nmon monitor files into time-sorted
CSV/Spreadsheets for easier analysis, without the use of the
MS Excel Macro. Also included is an option to build an HTML
report with graphs, which is configured through report.config.
positional arguments:
input_file Input NMON file
optional arguments:
-h, --help show this help message and exit
-x, --overwrite overwrite existing results (Default: False)
-d, --debug debug? (Default: False)
-o OUTDIR, --output OUTDIR
Output dir for CSV (Default: ./data/)
-c, --csv CSV output? (Default: False)
-b, --buildReport report output? (Default: False)
-r CONFFNAME, --reportConfig CONFFNAME
Report config file, if none exists: we will write the
default config file out (Default: ./report.config)
```
There are 2 main options of using this tool
1. Turn the nmon file into a set of separate CSV file
2. Generate an HTML report with matplotlib graphs
The following command does both:
```
$> ./pyNmonAnalyzer.py -c -b test.nmon
```
This will create a directory called ./data in which you will find a folder of CSV files ("./data/csv/"), a folder of PNG graphs ("./data/img/") and an HTML report ("./data/report.html").
By default the HTML report will include graphs for CPU, Disk Busy, Memory utilization and Network transfers. This is all defined in a self explanitory configuration file, "report.config". At the moment this is not yet very flexible as CPU and MEM are not configurable besides on or off, but one of the next steps will be to refine the plotting approach and to expose more flexibility with which graphs plot which data points.
### Report Example:
[![pyNmonAnalyzer Graph output][6]
**Click to see the full Report**][7]
Currently these reports are very bare bones and only prints out basic labeled graphs, but development is on-going. Currently in development is a wizard that will make adjusting the configurations easier. Please do let me know if you have any suggestions, find any bugs or have feature requests.
--------------------------------------------------------------------------------
via: https://matthiaslee.com/python-nmon-analyzer-moving-away-from-excel-macros/
作者:[Matthias Lee][a]
译者:[lujun9972](https://github.com/lujun9972)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://matthiaslee.com/
[1]:http://nmon.sourceforge.net/
[2]:https://matthiaslee.com//content/images/2015/06/nmon_cpudisk.png
[3]:http://www.ibm.com/developerworks/wikis/display/WikiPtype/nmonanalyser
[4]:http://matplotlib.org/
[5]:https://github.com/madmaze/pyNmonAnalyzer/blob/master/release/pyNmonAnalyzer-0.1.zip?raw=true
[6]:https://matthiaslee.com//content/images/2017/04/teaser-short_0.png (pyNmonAnalyzer Graph output)
[7]:http://matthiaslee.com/pub/pyNmonAnalyzer/data/report.html

View File

@ -0,0 +1,100 @@
Python 版的 Nmon 分析器:让你远离 excel 宏
======
[Nigel's monitor][1],也叫做 "Nmon",是一个很好的监控,记录和分析 Linux/*nix 系统性能随时间变化的工具。Nmon 最初由 IBM 开发并于 2009 年夏天开源。时至今日 Nmon 已经在所有 linux 平台和架构上都可用了。它提供了大量的实时工具来可视化当前系统统计信息,这些统计信息包括 CPURAM网络和磁盘 I/O。然而Nmon 最棒的特性是可以随着时间的推移记录系统性能快照。
比如:`nmon -f -s 1`。
![nmon CPU and Disk utilization][2]
会创建一个日志文件,该日志文件最开头是一些系统的元数据 T( 章节 AAA - BBBV),后面是定时抓取的监控系统属性的快照,比如 CPU 和内存的使用情况。这个文件很难直接由电子表格应用来处理,因此诞生了 [Nmon_Analyzer][3] excel 宏。如果你用的是 Windows/Mac 并安装了 Microsoft Office那么这个工具非常不错。如果没有这个环境那也可以使用 Nmon2rrd 工具,这个工具能将日志文件转换 RRD 输入文件,进而生成图形。这个过程很死板而且有点麻烦。现在出现了一个更灵活的工具,像你们介绍一下 pyNmonAnalyzer它一个可定制化的解决方案来生成结构化的 CSV 文件和基于 [matplotlib][4] 生成图片的简单 HTML 报告。
### 入门介绍:
系统需求:
从名字中就能看出我们需要有 python。此外 pyNmonAnalyzer 还依赖于 matplotlib 和 numpy。若你使用的是 debian 衍生的系统,则你需要先安装这些包:
```
$> sudo apt-get install python-numpy python-matplotlib
```
##### 获取 pyNmonAnalyzer
你可页克隆 git 仓库:
```
$> git clone git@github.com:madmaze/pyNmonAnalyzer.git
```
或者
直接从这里下载:[pyNmonAnalyzer-0.1.zip][5]
接下来我们需要一个 Nmon 文件,如果没有的话,可以使用发行版中提供的实例或者自己录制一个样本:`nmon -F test.nmon -s 1 -c 120`,会录制每个 1 秒录制一次,供录制 120 个快照道 test.nmon 文件中 .nmon。
让我们来看看基本的帮助信息:
```
$> ./pyNmonAnalyzer.py -h
usage: pyNmonAnalyzer.py [-h] [-x] [-d] [-o OUTDIR] [-c] [-b] [-r CONFFNAME]
input_file
nmonParser converts Nmon monitor files into time-sorted
CSV/Spreadsheets for easier analysis, without the use of the
MS Excel Macro. Also included is an option to build an HTML
report with graphs, which is configured through report.config.
positional arguments:
input_file Input NMON file
optional arguments:
-h, --help show this help message and exit
-x, --overwrite overwrite existing results (Default: False)
-d, --debug debug? (Default: False)
-o OUTDIR, --output OUTDIR
Output dir for CSV (Default: ./data/)
-c, --csv CSV output? (Default: False)
-b, --buildReport report output? (Default: False)
-r CONFFNAME, --reportConfig CONFFNAME
Report config file, if none exists: we will write the
default config file out (Default: ./report.config)
```
该工具有两个主要的选项
1。将 nmon 文件传唤成一系列独立的 CSV 文件
2。使用 matplotlib 生成带图形的 HTML 报告
下面命令既会生成 CSV 文件,也会生成 HTML 报告:
```
$> ./pyNmonAnalyzer.py -c -b test.nmon
```
这会常见一个 `。/data` 目录,其中有一个存放 CSV 文件的目录 ("。/data/csv/"),一个存放 PNG 图片的目录 ("。/data/img/") 以及一个 HTML 报告 ("。/data/report.html")。
默认情况下HTML 报告中会用图片展示 CPU磁盘繁忙度内存使用情况和网络传输情况。所有这些都定义在一个自解释的配置文件中 ("report.config")。目前这个工具 h 那不是特别的灵活,因为 CPU 和 MEM 除了 on 和 off 外,无法做其他的配置。不过下一步将会改进作图的方法并允许用户灵活地指定针对哪些数据使用哪种作图方法。
### 报告的例子:
[![pyNmonAnalyzer Graph output][6]
**Click to see the full Report**][7]
目前这些报告还十分的枯燥而且只能打印出基本的几种标记图表,不过它的功能还在不断的完善中。目前在开发的是一个向导来让配置调整变得更容易。如果有任何建议,找到任何 bug 或者有任何功能需求,欢迎与我交流。
--------------------------------------------------------------------------------
via: https://matthiaslee.com/python-nmon-analyzer-moving-away-from-excel-macros/
作者:[Matthias Lee][a]
译者:[lujun9972](https://github.com/lujun9972)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://matthiaslee.com/
[1]:http://nmon.sourceforge.net/
[2]:https://matthiaslee.com//content/images/2015/06/nmon_cpudisk.png
[3]:http://www.ibm.com/developerworks/wikis/display/WikiPtype/nmonanalyser
[4]:http://matplotlib.org/
[5]:https://github.com/madmaze/pyNmonAnalyzer/blob/master/release/pyNmonAnalyzer-0.1.zip?raw=true
[6]:https://matthiaslee.com//content/images/2017/04/teaser-short_0.png (pyNmonAnalyzer Graph output)
[7]:http://matthiaslee.com/pub/pyNmonAnalyzer/data/report.html