1. 程式人生 > >伺服器效能監控神器nmon使用介紹

伺服器效能監控神器nmon使用介紹

## 介紹 Nmon (Nigel’s Monitor)是由IBM 提供、免費監控 AIX 系統與 Linux 系統資源的工具。該工具可將伺服器系統資源耗用情況收集起來並輸出一個特定的檔案,並可利用 excel 分析工具(nmon analyser)進行資料的統計分析。 ## 下載 搜尋下載nmon,上傳到伺服器解壓。我用一個比較老的版本給大家演示一下。解壓完有nmon16e_x86_rhel65,和nmon analyser v34a.xls。 - nmon16e_x86_rhel65前面是可執行檔案,執行結束會生成監控檔案,監控檔案記錄採集的伺服器硬體指標,字尾是.nmon。 - nmon analyser v34a.xls用來將這個監控檔案轉化為易讀的Excel表格,帶有圖表。 ## 使用步驟 ### 伺服器處理 啟動nmon的命令如下,啟動後自動後臺執行 ``` ./nmon16e_x86_rhel65 -f -s 10 -c 999999999 -m ./ ``` 若首次執行失敗提示Permission Denied,執行 ``` chmod +x nmon16e_x86_rhel65 即可。 ``` 引數解釋: - -s 10 每 10 秒採集一次資料。 - -c 999999999 採集 999999999 次硬體資料,表示要長時間採集 - -f 生成的資料檔名中包含檔案建立的時間。 - -m 生成的資料檔案的存放目錄為當前目錄。 ``` [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轉換格式。如果有巨集相關的警告,按“工具->巨集->安全性->選擇低安全性”即可。 ![](https://gitee.com/xllntl/picture/raw/master/2020-11-8/1604841996883-%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20200805152850.png) ![](https://gitee.com/xllntl/picture/raw/master/2020-11-8/1604842035400-%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20200805152919.png) 會多次彈窗,問是否替換現有x86定義,全都點選是。 ![](https://gitee.com/xllntl/picture/raw/master/2020-11-8/1604842102720-%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20200805153046.png) 儲存xls格式的檔案。開啟xls檔案。下方標籤名稱代表該標籤監控的硬體指標, ![](https://gitee.com/xllntl/picture/raw/master/2020-11-8/1604842152723-%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20200805153239.png) 下面是網路和記憶體使用的監控指標。 ![](https://gitee.com/xllntl/picture/raw/master/2020-11-8/1604842196143-%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20200805153325.png) ![](https://gitee.com/xllntl/picture/raw/master/2020-11-8/1604842226487-%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20200805153346.png) ## 總結 nmon可以長期採集硬體資訊,設定採集間隔大的話對伺服器效能影響可以忽略不計。適用於採集一段時間,例如採集幾天,然後彙總分析的場景。通過分析硬體資源的佔用變化原因,會有很多新的發現,使我們對系統的掌握更加透徹。但不適用實時監控的要