轻量级的linux监控工具njmon安装与使用

njmon与nmon类似,但是其可以保存成JSON格式或直接保存到InfluxDB,可以用于服务器性能统计。

1.环境准备

(1).CentOS7
(2).Python3

2.下载软件

官方网址:​​http://nmon.sourceforge.net/pmwiki.php?n=Site.Njmon​​

(1).下载njmon

目前njmon的最新版本是njmon_linux_binaries_v78

但是由于njmonchart_v40只支持njmon v40+ 和 50+ 版本,所以此处下载njmon_linux_binaries_v51版本

下载地址:​​https://sourceforge.net/projects/nmon/files/njmon_linux_binaries_v51.zip/download​​

(2).下载njmonchart,将json文件生成报告

目前版本是njmonchart_v40,下载地址:​​http://sourceforge.net/projects/nmon/files/njmonchart_v40.zip​​

3.安装软件

(1).安装njmon
unzip njmon_linux_binaries_v51.zip
mv njmon_linux_RHEL7_AMD64_v51 /usr/local/bin/njmon

验证是否安装成功

[root@localhost ~]# njmon -?
njmon: help information. Version:51@21/01/2020

- Performance stats collector outputing JSON format. Default is stdout
- Core syntax: njmon -s seconds -c count
- File output: -m directory -f
- njmon collector output: -i host -p port -X secret
- All options: -?

-s seconds : seconds between snapshots of data (default 60 seconds) #采集间隔时间,单位秒,默认 60 秒
-c count : number of snapshots (default forever) #采集次数,默认永久

-m directory : Program will cd to the directory before output #文件存储目录
-f : Output to file (not stdout) to two files below #输出到文件,数据内容:hostname_.json,错误内容:hostname_.err
: Data: hostname_<year><month><day>_<hour><minutes>.json
: Error: hostname_<year><month><day>_<hour><minutes>.err
-k : Read /tmp/njmon.pid for a running njmon PID & if found running then this copy exits
-P : Add process stats (take CPU cycles and large stats volume)
-t percent : Set ignore process percent threshold (default 0.01%)
-? or -h : This output and stop
-d : Switch on debug tracing (output will no longer be JSON format)
-w : Switch off warning messages in error output stream
-r : Random pause at the start. Stops cron starting every njmon in sync.
Push data to collector:
-i ip : IP address or hostname of the njmon central collector
-p port : port number on collector host
-X secret : Set the remote collector secret or use shell NJMON_SECRET

Examples:
1 Every 5 mins all day
/home/nag/njmon -s 300 -c 288 -f -m /home/perf
2 Piping to data handler using half a day
/home/nag/njmon -s 30 -c 1440 | myprog
3 Use the defaults (-s 60 forever) and save to a file
./njmon > my_server_today.json
4 Crontab entry
0 4 * * * /home/nag/njmon -s 300 -c 288 -f -m /home/perf
5 Crontab - hourly check/restart remote njmon, pipe stats back & insert into local DB
* 0 * * * /usr/bin/ssh nigel@server /usr/lbin/njmon -k -s 300 -c 288 | /usr/local/bin/injector
6 Crontab - for pumping data to the njmon central collector
* 0 * * * /usr/local/bin/njmon -s 300 -c 288 -i admin.acme.com -p 8181 -X SECRET42
* 0 * * * export NJMON_SECRET=abc123 && /usr/local/bin/njmon -s 300 -c 288 -i influx -p 8181
* 0 * * * export NJMON_SECRET=abc123 && /usr/local/bin/njmon -s 60 -k -i influx -p 8181

[root@localhost ~]#

使用:

1).默认间隔时间(-s 60),保存 json 结果
njmon > linux-db1.json

查看生成的json数据

{"timestamp": {"datetime": "2022-04-06T16:11:34","UTC": "2022-04-06T08:11:34","snapshot_seconds": 60,"snapshot_maxloops": -1,"snapshot_loop": 0},"identity": {"hostname": "localhost","fullhostname": "localhost.localdomain","njmon_command": "njmon","njmon_version": "51@21/01/2020","username": "root","userid": 0,"cookie": "0xdeadbeef","fullhostname1": "localhost","fullhostname2": "(null)","lo_Not_Supported_17": "","ens18_Not_Supported_17": "","lo_IP4": "127.0.0.1","ens18_IP4": "10.2.6.99","lo_IP6": "::1","ens18_IP6": "fe80::4852:a7e:ff9d:ef41","serial-number": "","model": "Bochs","vendor": "Bochs"},"os_release": {"name": "CentOS Linux","version": "7 (Core)","pretty_name": "CentOS Linux 7 (Core)","version_id": "7"},"proc_version": {"version": "Linux version 3.10.0-1160.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) ) #1 SMP Mon Oct 19 16:18:59 UTC 2020"},"lscpu": {"architecture": "x86_64","byte_order": "Little Endian","cpus": "8","online_cpu_list": "0-7","threads_per_core": "1","cores_per_socket": "8","sockets": "1","numa_nodes": "1","vendor_id": "GenuineIntel","cpu_family": "6","model": "85","model_name": "Intel(R) Xeon(R) Gold 5220R CPU @ 2.20GHz","stepping": "7","cpu_mhz": "2200.008","bogomips": "4400.01"},"cpu_total": {"user": 0.644,"nice": 0.000,"sys": 0.210,"idle": 98.523,"iowait": 0.412,"hardirq": 0.000,"softirq": 0.031,"steal": 0.006,"guest": 0.000,"guestnice": 0.000},"cpus": {"cpu0": {"user": 0.600,"nice": 0.000,"sys": 0.133,"idle": 98.950,"iowait": 0.117,"hardirq": 0.000,"softirq": 0.017,"steal": 0.000,"guest": 0.000,"guestnice": 0.000},"cpu1": {"user": 0.850,"nice": 0.000,"sys": 0.333,"idle": 97.817,"iowait": 0.900,"hardirq": 0.000,"softirq": 0.000,"steal": 0.000,"guest": 0.000,"guestnice": 0.000},"cpu2": {"user": 0.617,"nice": 0.000,"sys": 0.267,"idle": 98.267,"iowait": 0.783,"hardirq": 0.000,"softirq": 0.000,"steal": 0.000,"guest": 0.000,"guestnice": 0.000},"cpu3": {"user": 0.517,"nice": 0.000,"sys": 0.250,"idle": 98.683,"iowait": 0.450,"hardirq": 0.000,"softirq": 0.000,"steal": 0.000,"guest": 0.000,"guestnice": 0.000},"cpu4": {"user": 0.633,"nice": 0.000,"sys": 0.200,"idle": 98.483,"iowait": 0.583,"hardirq": 0.000,"softirq": 0.000,"steal": 0.000,"guest": 0.000,"guestnice": 0.000},"cpu5": {"user": 0.933,"nice": 0.000,"sys": 0.233,"idle": 97.717,"iowait": 0.067,"hardirq": 0.000,"softirq": 0.250,"steal": 0.033,"guest": 0.000,"guestnice": 0.000},"cpu6": {"user": 0.667,"nice": 0.000,"sys": 0.167,"idle": 98.933,"iowait": 0.217,"hardirq": 0.000,"softirq": 0.000,"steal": 0.000,"guest": 0.000,"guestnice": 0.000},"cpu7": {"user": 0.317,"nice": 0.000,"sys": 0.100,"idle": 99.333,"iowait": 0.183,"hardirq": 0.000,"softirq": 0.000,"steal": 0.000,"guest": 0.000,"guestnice": 0.000}},"stat_counters": {"ctxt": 1411.264,"btime": 1647998477,"processes_forks": 1.267,"procs_running": 2,"procs_blocked": 0},"cpuinfo": {"proc0": {"vendor_id": "GenuineIntel","model_name": "Intel(R) Xeon(R) Gold 5220R CPU @ 2.20GHz","cpu_mhz": 2200.008,"cache_size": 4096.000,"physical_id": 0,"siblings": 8,"core_id": 0,"cpu_cores": 8},"proc1": {"vendor_id": "GenuineIntel","model_name": "Intel(R) Xeon(R) Gold 5220R CPU @ 2.20GHz","cpu_mhz": 2200.008,"cache_size": 4096.000,"physical_id": 0,"siblings": 8,"core_id": 1,"cpu_cores": 8},"proc2": {"vendor_id": "GenuineIntel","model_name": "Intel(R) Xeon(R) Gold 5220R CPU @ 2.20GHz","cpu_mhz": 2200.008,"cache_size": 4096.000,"physical_id": 0,"siblings": 8,"core_id": 2,"cpu_cores": 8},"proc3": {"vendor_id": "GenuineIntel","model_name": "Intel(R) Xeon(R) Gold 5220R CPU @ 2.20GHz","cpu_mhz": 2200.008,"cache_size": 4096.000,"physical_id": 0,"siblings": 8,"core_id": 3,"cpu_cores": 8},"proc4": {"vendor_id": "GenuineIntel","model_name": "Intel(R) Xeon(R) Gold 5220R CPU @ 2.20GHz","cpu_mhz": 2200.008,"cache_size": 4096.000,"physical_id": 0,"siblings": 8,"core_id": 4,"cpu_cores": 8},"proc5": {"vendor_id": "GenuineIntel","model_name": "Intel(R) Xeon(R) Gold 5220R CPU @ 2.20GHz","cpu_mhz": 2200.008,"cache_size": 4096.000,"physical_id": 0,"siblings": 8,"core_id": 5,"cpu_cores": 8},"proc6": {"vendor_id": "GenuineIntel","model_name": "Intel(R) Xeon(R) Gold 5220R CPU @ 2.20GHz","cpu_mhz": 2200.008,"cache_size": 4096.000,"physical_id": 0,"siblings": 8,"core_id": 6,"cpu_cores": 8},"proc7": {"vendor_id": "GenuineIntel","model_name": "Intel(R) Xeon(R) Gold 5220R CPU @ 2.20GHz","cpu_mhz": 2200.008,"cache_size": 4096.000,"physical_id": 0,"siblings": 8,"core_id": 7,"cpu_cores": 8}},"proc_meminfo": {"MemTotal": 8008052,"MemFree": 156148,"MemAvailable": 576256,"Buffers": 0,"Cached": 586968,"SwapCached": 1835168,"Active": 5959916,"Inactive": 1410396,"Active_anon": 5653240,"Inactive_anon": 1137356,"Active_file": 306676,"Inactive_file": 273040,"Unevictable": 0,"Mlocked": 0,"SwapTotal": 8388604,"SwapFree": 5760516,"Dirty": 0,"Writeback": 0,"AnonPages": 6779592,"Mapped": 39580,"Shmem": 7268,"Slab": 159540,"SReclaimable": 123656,"SUnreclaim": 35884,"KernelStack": 8544,"PageTables": 28220,"NFS_Unstable": 0,"Bounce": 0,"WritebackTmp": 0,"CommitLimit": 12392628,"Committed_AS": 6253552,"VmallocTotal": 34359738367,"VmallocUsed": 24236,"VmallocChunk": 34359710200,"Percpu": 1408,"HardwareCorrupted": 0,"AnonHugePages": 2646016,"CmaTotal": 0,"CmaFree": 0,"HugePages_Total": 0,"HugePages_Free": 0,"HugePages_Rsvd": 0,"HugePages_Surp": 0,"Hugepagesize": 2048,"DirectMap4k": 110464,"DirectMap2M": 5132288,"DirectMap1G": 5242880},"proc_vmstat": {"nr_free_pages": 39037,"nr_alloc_batch": 3615,"nr_inactive_anon": 284339,"nr_active_anon": 1413310,"nr_inactive_file": 68260,"nr_active_file": 76669,"nr_unevictable": 0,"nr_mlock": 0,"nr_anon_pages": 1033394,"nr_mapped": 9895,"nr_file_pages": 605534,"nr_dirty": 0,"nr_writeback": 0,"nr_slab_reclaimable": 30914,"nr_slab_unreclaimable": 8971,"nr_page_table_pages": 7055,"nr_kernel_stack": 534,"nr_unstable": 0,"nr_bounce": 0,"nr_vmscan_write": 1088200,"nr_vmscan_immediate_reclaim": 6873,"nr_writeback_temp": 0,"nr_isolated_anon": 0,"nr_isolated_file": 0,"nr_shmem": 1817,"nr_dirtied": 218785051,"nr_written": 170361760,"numa_hit": 454069453,"numa_miss": 0,"numa_foreign": 0,"numa_interleave": 16858,"numa_local": 454069453,"numa_other": 0,"workingset_refault": 26661643,"workingset_activate": 774313,"workingset_nodereclaim": 105791,"nr_anon_transparent_hugepages": 1292,"nr_free_cma": 0,"nr_dirty_threshold": 39849,"nr_dirty_background_threshold": 13283,"pgpgin": 178107220,"pgpgout": 1866922763,"pswpin": 1657362,"pswpout": 1088113,"pgalloc_dma": 8,"pgalloc_dma32": 245901285,"pgalloc_normal": 405601984,"pgalloc_movable": 0,"pgfree": 651544569,"pgactivate": 40627677,"pgdeactivate": 34441147,"pgfault": 413737759,"pgmajfault": 392835,"pglazyfreed": 32132,"pgrefill_dma": 0,"pgrefill_dma32": 12472005,"pgrefill_normal": 18796815,"pgrefill_movable": 0,"pgsteal_kswapd_dma": 0,"pgsteal_kswapd_dma32": 18354908,"pgsteal_kswapd_normal": 27991307,"pgsteal_kswapd_movable": 0,"pgsteal_direct_dma": 0,"pgsteal_direct_dma32": 8112,"pgsteal_direct_normal": 23500,"pgsteal_direct_movable": 0,"pgscan_kswapd_dma": 0,"pgscan_kswapd_dma32": 20312689,"pgscan_kswapd_normal": 31019993,"pgscan_kswapd_movable": 0,"pgscan_direct_dma": 0,"pgscan_direct_dma32": 10080,"pgscan_direct_normal": 63503,"pgscan_direct_movable": 0,"pgscan_direct_throttle": 0,"zone_reclaim_failed": 0,"pginodesteal": 0,"slabs_scanned": 731136,"kswapd_inodesteal": 12,"kswapd_low_wmark_hit_quickly": 4841,"kswapd_high_wmark_hit_quickly": 765,"pageoutrun": 10477,"allocstall": 614,"pgrotated": 1073280,"drop_pagecache": 0,"drop_slab": 0,"numa_pte_updates": 0,"numa_huge_pte_updates": 0,"numa_hint_faults": 0,"numa_hint_faults_local": 0,"numa_pages_migrated": 0,"pgmigrate_success": 311,"pgmigrate_fail": 0,"compact_migrate_scanned": 3837,"compact_free_scanned": 12493,"compact_isolated": 645,"compact_stall": 19,"compact_fail": 17,"compact_success": 2,"htlb_buddy_alloc_success": 0,"htlb_buddy_alloc_fail": 0,"unevictable_pgs_culled": 0,"unevictable_pgs_scanned": 0,"unevictable_pgs_rescued": 15,"unevictable_pgs_mlocked": 15,"unevictable_pgs_munlocked": 15,"unevictable_pgs_cleared": 0,"unevictable_pgs_stranded": 0,"thp_fault_alloc": 6332,"thp_fault_fallback": 11057,"thp_collapse_alloc": 2135,"thp_collapse_alloc_failed": 30454,"thp_split": 1139,"thp_zero_page_alloc": 2,"thp_zero_page_alloc_failed": 0,"balloon_inflate": 15779328,"balloon_deflate": 15779328,"balloon_migrate": 0,"swap_ra": 1377287,"swap_ra_hit": 1354362},"disks": {"vda": {"reads": 8.050,"rmerge": 0.000,"rkb": 32.200,"rmsec": 3.900,"writes": 102.950,"wmerge": 0.133,"wkb": 812.615,"wmsec": 152.433,"inflight": 0,"busy": 13.783,"backlog": 156.133,"xfers": 111.000,"bsize": 6144},"sr0": {"reads": 0.000,"rmerge": 0.000,"rkb": 0.000,"rmsec": 0.000,"writes": 0.000,"wmerge": 0.000,"wkb": 0.000,"wmsec": 0.000,"inflight": 0,"busy": 0.000,"backlog": 0.000,"xfers": 0.000,"bsize": 58368}},"networks": {"lo": {"ibytes": 32429.363,"ipackets": 9.883,"ierrs": 0.000,"idrop": 0.000,"ififo": 0.000,"iframe": 0.000,"obytes": 32429.363,"opackets": 9.883,"oerrs": 0.000,"odrop": 0.000,"ofifo": 0.000,"ocolls": 0.000,"ocarrier": 0.000},"ens18": {"ibytes": 119251.353,"ipackets": 168.950,"ierrs": 0.000,"idrop": 0.000,"ififo": 0.000,"iframe": 0.000,"obytes": 62489.363,"opackets": 130.716,"oerrs": 0.000,"odrop": 0.000,"ofifo": 0.000,"ocolls": 0.000,"ocarrier": 0.000}},"uptime": {"days": 14,"hours": 6,"minutes": 50,"users": 5},"filesystems": {"/dev/mapper/centos-root": {"fs_dir": "/","fs_type": "xfs","fs_opts": "rw,relatime,attr2,inode64,noquota","fs_freqs": 0,"fs_passno": 0,"fs_bsize": 4096,"fs_size_mb": 503358,"fs_free_mb": 409292,"fs_used_mb": 94066,"fs_full_percent": 18.688,"fs_avail": 409292,"fs_files": 257845248,"fs_files_free": 257801269,"fs_namelength": 255},"/dev/vda2": {"fs_dir": "/boot","fs_type": "xfs","fs_opts": "rw,relatime,attr2,inode64,noquota","fs_freqs": 0,"fs_passno": 0,"fs_bsize": 4096,"fs_size_mb": 196,"fs_free_mb": 65,"fs_used_mb": 131,"fs_full_percent": 66.610,"fs_avail": 65,"fs_files": 102400,"fs_files_free": 102073,"fs_namelength": 255}}}
{"timestamp": {"datetime": "2022-04-06T16:12:34","UTC": "2022-04-06T08:12:34","snapshot_seconds": 60,"snapshot_maxloops": -1,"snapshot_loop": 1},"identity": {"hostname": "localhost","fullhostname": "localhost.localdomain","njmon_command": "njmon","njmon_version": "51@21/01/2020","username": "root","userid": 0,"cookie": "0xdeadbeef","fullhostname1": "localhost","fullhostname2": "(null)","lo_Not_Supported_17": "","ens18_Not_Supported_17": "","lo_IP4": "127.0.0.1","ens18_IP4": "10.2.6.99","lo_IP6": "::1","ens18_IP6": "fe80::4852:a7e:ff9d:ef41","serial-number": "","model": "Bochs","vendor": "Bochs"},"os_release": {"name": "CentOS Linux","version": "7 (Core)","pretty_name": "CentOS Linux 7 (Core)","version_id": "7"},"proc_version": {"version": "Linux version 3.10.0-1160.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) ) #1 SMP Mon Oct 19 16:18:59 UTC 2020"},"lscpu": {"architecture": "x86_64","byte_order": "Little Endian","cpus": "8","online_cpu_list": "0-7","threads_per_core": "1","cores_per_socket": "8","sockets": "1","numa_nodes": "1","vendor_id": "GenuineIntel","cpu_family": "6","model": "85","model_name": "Intel(R) Xeon(R) Gold 5220R CPU @ 2.20GHz","stepping": "7","cpu_mhz": "2200.008","bogomips": "4400.01"},"cpu_total": {"user": 1.675,"nice": 0.000,"sys": 0.483,"idle": 95.556,"iowait": 1.602,"hardirq": 0.000,"softirq": 0.117,"steal": 0.021,"guest": 0.000,"guestnice": 0.000},"cpus": {"cpu0": {"user": 0.633,"nice": 0.000,"sys": 0.050,"idle": 98.833,"iowait": 0.083,"hardirq": 0.000,"softirq": 0.000,"steal": 0.067,"guest": 0.000,"guestnice": 0.000},"cpu1": {"user": 2.033,"nice": 0.000,"sys": 0.833,"idle": 93.617,"iowait": 3.083,"hardirq": 0.000,"softirq": 0.000,"steal": 0.000,"guest": 0.000,"guestnice": 0.000},"cpu2": {"user": 1.583,"nice": 0.000,"sys": 0.783,"idle": 94.417,"iowait": 2.816,"hardirq": 0.000,"softirq": 0.000,"steal": 0.017,"guest": 0.000,"guestnice": 0.000},"cpu3": {"user": 1.750,"nice": 0.000,"sys": 0.733,"idle": 94.534,"iowait": 2.683,"hardirq": 0.000,"softirq": 0.000,"steal": 0.017,"guest": 0.000,"guestnice": 0.000},"cpu4": {"user": 1.133,"nice": 0.000,"sys": 0.433,"idle": 96.516,"iowait": 1.666,"hardirq": 0.000,"softirq": 0.000,"steal": 0.000,"guest": 0.000,"guestnice": 0.000},"cpu5": {"user": 4.849,"nice": 0.000,"sys": 0.533,"idle": 90.434,"iowait": 0.800,"hardirq": 0.000,"softirq": 0.900,"steal": 0.067,"guest": 0.000,"guestnice": 0.000},"cpu6": {"user": 0.600,"nice": 0.000,"sys": 0.200,"idle": 98.499,"iowait": 0.550,"hardirq": 0.000,"softirq": 0.000,"steal": 0.000,"guest": 0.000,"guestnice": 0.000},"cpu7": {"user": 0.833,"nice": 0.000,"sys": 0.300,"idle": 97.600,"iowait": 1.100,"hardirq": 0.000,"softirq": 0.000,"steal": 0.017,"guest": 0.000,"guestnice": 0.000}},"stat_counters": {"ctxt": 4100.484,"btime": 1647998477,"processes_forks": 0.867,"procs_running": 1,"procs_blocked": 1},"cpuinfo": {"proc0": {"vendor_id": "GenuineIntel","model_name": "Intel(R) Xeon(R) Gold 5220R CPU @ 2.20GHz","cpu_mhz": 2200.008,"cache_size": 4096.000,"physical_id": 0,"siblings": 8,"core_id": 0,"cpu_cores": 8},"proc1": {"vendor_id": "GenuineIntel","model_name": "Intel(R) Xeon(R) Gold 5220R CPU @ 2.20GHz","cpu_mhz": 2200.008,"cache_size": 4096.000,"physical_id": 0,"siblings": 8,"core_id": 1,"cpu_cores": 8},"proc2": {"vendor_id": "GenuineIntel","model_name": "Intel(R) Xeon(R) Gold 5220R CPU @ 2.20GHz","cpu_mhz": 2200.008,"cache_size": 4096.000,"physical_id": 0,"siblings": 8,"core_id": 2,"cpu_cores": 8},"proc3": {"vendor_id": "GenuineIntel","model_name": "Intel(R) Xeon(R) Gold 5220R CPU @ 2.20GHz","cpu_mhz": 2200.008,"cache_size": 4096.000,"physical_id": 0,"siblings": 8,"core_id": 3,"cpu_cores": 8},"proc4": {"vendor_id": "GenuineIntel","model_name": "Intel(R) Xeon(R) Gold 5220R CPU @ 2.20GHz","cpu_mhz": 2200.008,"cache_size": 4096.000,"physical_id": 0,"siblings": 8,"core_id": 4,"cpu_cores": 8},"proc5": {"vendor_id": "GenuineIntel","model_name": "Intel(R) Xeon(R) Gold 5220R CPU @ 2.20GHz","cpu_mhz": 2200.008,"cache_size": 4096.000,"physical_id": 0,"siblings": 8,"core_id": 5,"cpu_cores": 8},"proc6": {"vendor_id": "GenuineIntel","model_name": "Intel(R) Xeon(R) Gold 5220R CPU @ 2.20GHz","cpu_mhz": 2200.008,"cache_size": 4096.000,"physical_id": 0,"siblings": 8,"core_id": 6,"cpu_cores": 8},"proc7": {"vendor_id": "GenuineIntel","model_name": "Intel(R) Xeon(R) Gold 5220R CPU @ 2.20GHz","cpu_mhz": 2200.008,"cache_size": 4096.000,"physical_id": 0,"siblings": 8,"core_id": 7,"cpu_cores": 8}},"proc_meminfo": {"MemTotal": 8008052,"MemFree": 146528,"MemAvailable": 578480,"Buffers": 0,"Cached": 598828,"SwapCached": 1835168,"Active": 5967680,"Inactive": 1414724,"Active_anon": 5653488,"Inactive_anon": 1137356,"Active_file": 314192,"Inactive_file": 277368,"Unevictable": 0,"Mlocked": 0,"SwapTotal": 8388604,"SwapFree": 5760516,"Dirty": 844,"Writeback": 16,"AnonPages": 6779796,"Mapped": 39628,"Shmem": 7268,"Slab": 159532,"SReclaimable": 123656,"SUnreclaim": 35876,"KernelStack": 8544,"PageTables": 28224,"NFS_Unstable": 0,"Bounce": 0,"WritebackTmp": 0,"CommitLimit": 12392628,"Committed_AS": 6253556,"VmallocTotal": 34359738367,"VmallocUsed": 24236,"VmallocChunk": 34359710200,"Percpu": 1408,"HardwareCorrupted": 0,"AnonHugePages": 2646016,"CmaTotal": 0,"CmaFree": 0,"HugePages_Total": 0,"HugePages_Free": 0,"HugePages_Rsvd": 0,"HugePages_Surp": 0,"Hugepagesize": 2048,"DirectMap4k": 110464,"DirectMap2M": 5132288,"DirectMap1G": 5242880},"proc_vmstat": {"nr_free_pages": 36632,"nr_alloc_batch": 2820,"nr_inactive_anon": 284339,"nr_active_anon": 1413372,"nr_inactive_file": 69342,"nr_active_file": 78548,"nr_unevictable": 0,"nr_mlock": 0,"nr_anon_pages": 1033445,"nr_mapped": 9907,"nr_file_pages": 608499,"nr_dirty": 211,"nr_writeback": 4,"nr_slab_reclaimable": 30914,"nr_slab_unreclaimable": 8969,"nr_page_table_pages": 7056,"nr_kernel_stack": 534,"nr_unstable": 0,"nr_bounce": 0,"nr_vmscan_write": 1088200,"nr_vmscan_immediate_reclaim": 6873,"nr_writeback_temp": 0,"nr_isolated_anon": 0,"nr_isolated_file": 0,"nr_shmem": 1817,"nr_dirtied": 218802545,"nr_written": 170376555,"numa_hit": 454080850,"numa_miss": 0,"numa_foreign": 0,"numa_interleave": 16858,"numa_local": 454080850,"numa_other": 0,"workingset_refault": 26663483,"workingset_activate": 774313,"workingset_nodereclaim": 105791,"nr_anon_transparent_hugepages": 1292,"nr_free_cma": 0,"nr_dirty_threshold": 40015,"nr_dirty_background_threshold": 13338,"pgpgin": 178114640,"pgpgout": 1867007407,"pswpin": 1657362,"pswpout": 1088113,"pgalloc_dma": 8,"pgalloc_dma32": 245910092,"pgalloc_normal": 405616570,"pgalloc_movable": 0,"pgfree": 651565068,"pgactivate": 40630217,"pgdeactivate": 34441147,"pgfault": 413740248,"pgmajfault": 392841,"pglazyfreed": 32132,"pgrefill_dma": 0,"pgrefill_dma32": 12472005,"pgrefill_normal": 18796815,"pgrefill_movable": 0,"pgsteal_kswapd_dma": 0,"pgsteal_kswapd_dma32": 18354908,"pgsteal_kswapd_normal": 27991307,"pgsteal_kswapd_movable": 0,"pgsteal_direct_dma": 0,"pgsteal_direct_dma32": 8112,"pgsteal_direct_normal": 23500,"pgsteal_direct_movable": 0,"pgscan_kswapd_dma": 0,"pgscan_kswapd_dma32": 20312689,"pgscan_kswapd_normal": 31019993,"pgscan_kswapd_movable": 0,"pgscan_direct_dma": 0,"pgscan_direct_dma32": 10080,"pgscan_direct_normal": 63503,"pgscan_direct_movable": 0,"pgscan_direct_throttle": 0,"zone_reclaim_failed": 0,"pginodesteal": 0,"slabs_scanned": 731136,"kswapd_inodesteal": 12,"kswapd_low_wmark_hit_quickly": 4841,"kswapd_high_wmark_hit_quickly": 765,"pageoutrun": 10477,"allocstall": 614,"pgrotated": 1073280,"drop_pagecache": 0,"drop_slab": 0,"numa_pte_updates": 0,"numa_huge_pte_updates": 0,"numa_hint_faults": 0,"numa_hint_faults_local": 0,"numa_pages_migrated": 0,"pgmigrate_success": 311,"pgmigrate_fail": 0,"compact_migrate_scanned": 3837,"compact_free_scanned": 12493,"compact_isolated": 645,"compact_stall": 19,"compact_fail": 17,"compact_success": 2,"htlb_buddy_alloc_success": 0,"htlb_buddy_alloc_fail": 0,"unevictable_pgs_culled": 0,"unevictable_pgs_scanned": 0,"unevictable_pgs_rescued": 15,"unevictable_pgs_mlocked": 15,"unevictable_pgs_munlocked": 15,"unevictable_pgs_cleared": 0,"unevictable_pgs_stranded": 0,"thp_fault_alloc": 6332,"thp_fault_fallback": 11057,"thp_collapse_alloc": 2135,"thp_collapse_alloc_failed": 30455,"thp_split": 1139,"thp_zero_page_alloc": 2,"thp_zero_page_alloc_failed": 0,"balloon_inflate": 15779328,"balloon_deflate": 15779328,"balloon_migrate": 0,"swap_ra": 1377287,"swap_ra_hit": 1354362},"disks": {"vda": {"reads": 30.911,"rmerge": 0.000,"rkb": 123.645,"rmsec": 12.198,"writes": 416.294,"wmerge": 0.117,"wkb": 1410.471,"wmsec": 636.739,"inflight": 0,"busy": 63.522,"backlog": 647.937,"xfers": 447.205,"bsize": 6144},"sr0": {"reads": 0.000,"rmerge": 0.000,"rkb": 0.000,"rmsec": 0.000,"writes": 0.000,"wmerge": 0.000,"wkb": 0.000,"wmsec": 0.000,"inflight": 0,"busy": 0.000,"backlog": 0.000,"xfers": 0.000,"bsize": 58368}},"networks": {"lo": {"ibytes": 32470.883,"ipackets": 9.532,"ierrs": 0.000,"idrop": 0.000,"ififo": 0.000,"iframe": 0.000,"obytes": 32470.883,"opackets": 9.532,"oerrs": 0.000,"odrop": 0.000,"ofifo": 0.000,"ocolls": 0.000,"ocarrier": 0.000},"ens18": {"ibytes": 524867.386,"ipackets": 588.347,"ierrs": 0.000,"idrop": 0.000,"ififo": 0.000,"iframe": 0.000,"obytes": 472832.301,"opackets": 576.499,"oerrs": 0.000,"odrop": 0.000,"ofifo": 0.000,"ocolls": 0.000,"ocarrier": 0.000}},"uptime": {"days": 14,"hours": 6,"minutes": 51,"users": 5},"filesystems": {"/dev/mapper/centos-root": {"fs_dir": "/","fs_type": "xfs","fs_opts": "rw,relatime,attr2,inode64,noquota","fs_freqs": 0,"fs_passno": 0,"fs_bsize": 4096,"fs_size_mb": 503358,"fs_free_mb": 409292,"fs_used_mb": 94066,"fs_full_percent": 18.688,"fs_avail": 409292,"fs_files": 257845248,"fs_files_free": 257801269,"fs_namelength": 255},"/dev/vda2": {"fs_dir": "/boot","fs_type": "xfs","fs_opts": "rw,relatime,attr2,inode64,noquota","fs_freqs": 0,"fs_passno": 0,"fs_bsize": 4096,"fs_size_mb": 196,"fs_free_mb": 65,"fs_used_mb": 131,"fs_full_percent": 66.610,"fs_avail": 65,"fs_files": 102400,"fs_files_free": 102073,"fs_namelength": 255}}}
{"timestamp": {"datetime": "2022-04-06T16:13:34","UTC": "2022-04-06T08:13:34","snapshot_seconds": 60,"snapshot_maxloops": -1,"snapshot_loop": 2},"identity": {"hostname": "localhost","fullhostname": "localhost.localdomain","njmon_command": "njmon","njmon_version": "51@21/01/2020","username": "root","userid": 0,"cookie": "0xdeadbeef","fullhostname1": "localhost","fullhostname2": "(null)","lo_Not_Supported_17": "","ens18_Not_Supported_17": "","lo_IP4": "127.0.0.1","ens18_IP4": "10.2.6.99","lo_IP6": "::1","ens18_IP6": "fe80::4852:a7e:ff9d:ef41","serial-number": "","model": "Bochs","vendor": "Bochs"},"os_release": {"name": "CentOS Linux","version": "7 (Core)","pretty_name": "CentOS Linux 7 (Core)","version_id": "7"},"proc_version": {"version": "Linux version 3.10.0-1160.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) ) #1 SMP Mon Oct 19 16:18:59 UTC 2020"},"lscpu": {"architecture": "x86_64","byte_order": "Little Endian","cpus": "8","online_cpu_list": "0-7","threads_per_core": "1","cores_per_socket": "8","sockets": "1","numa_nodes": "1","vendor_id": "GenuineIntel","cpu_family": "6","model": "85","model_name": "Intel(R) Xeon(R) Gold 5220R CPU @ 2.20GHz","stepping": "7","cpu_mhz": "2200.008","bogomips": "4400.01"},"cpu_total": {"user": 1.929,"nice": 0.000,"sys": 0.625,"idle": 94.771,"iowait": 1.889,"hardirq": 0.000,"softirq": 0.144,"steal": 0.027,"guest": 0.000,"guestnice": 0.000},"cpus": {"cpu0": {"user": 0.700,"nice": 0.000,"sys": 0.150,"idle": 97.966,"iowait": 0.533,"hardirq": 0.000,"softirq": 0.017,"steal": 0.083,"guest": 0.000,"guestnice": 0.000},"cpu1": {"user": 2.733,"nice": 0.000,"sys": 1.166,"idle": 91.251,"iowait": 4.383,"hardirq": 0.000,"softirq": 0.017,"steal": 0.017,"guest": 0.000,"guestnice": 0.000},"cpu2": {"user": 2.083,"nice": 0.000,"sys": 0.817,"idle": 94.117,"iowait": 2.583,"hardirq": 0.000,"softirq": 0.000,"steal": 0.000,"guest": 0.000,"guestnice": 0.000},"cpu3": {"user": 1.533,"nice": 0.000,"sys": 0.617,"idle": 95.833,"iowait": 1.666,"hardirq": 0.000,"softirq": 0.000,"steal": 0.017,"guest": 0.000,"guestnice": 0.000},"cpu4": {"user": 0.950,"nice": 0.000,"sys": 0.367,"idle": 97.233,"iowait": 1.250,"hardirq": 0.000,"softirq": 0.000,"steal": 0.017,"guest": 0.000,"guestnice": 0.000},"cpu5": {"user": 5.382,"nice": 0.000,"sys": 1.033,"idle": 87.585,"iowait": 2.116,"hardirq": 0.000,"softirq": 1.133,"steal": 0.067,"guest": 0.000,"guestnice": 0.000},"cpu6": {"user": 0.966,"nice": 0.000,"sys": 0.417,"idle": 97.000,"iowait": 1.483,"hardirq": 0.000,"softirq": 0.000,"steal": 0.017,"guest": 0.000,"guestnice": 0.000},"cpu7": {"user": 1.083,"nice": 0.000,"sys": 0.417,"idle": 97.183,"iowait": 1.116,"hardirq": 0.000,"softirq": 0.000,"steal": 0.000,"guest": 0.000,"guestnice": 0.000}},"stat_counters": {"ctxt": 4951.232,"btime": 1647998477,"processes_forks": 0.850,"procs_running": 1,"procs_blocked": 0},"cpuinfo": {"proc0": {"vendor_id": "GenuineIntel","model_name": "Intel(R) Xeon(R) Gold 5220R CPU @ 2.20GHz","cpu_mhz": 2200.008,"cache_size": 4096.000,"physical_id": 0,"siblings": 8,"core_id": 0,"cpu_cores": 8},"proc1": {"vendor_id": "GenuineIntel","model_name": "Intel(R) Xeon(R) Gold 5220R CPU @ 2.20GHz","cpu_mhz": 2200.008,"cache_size": 4096.000,"physical_id": 0,"siblings": 8,"core_id": 1,"cpu_cores": 8},"proc2": {"vendor_id": "GenuineIntel","model_name": "Intel(R) Xeon(R) Gold 5220R CPU @ 2.20GHz","cpu_mhz": 2200.008,"cache_size": 4096.000,"physical_id": 0,"siblings": 8,"core_id": 2,"cpu_cores": 8},"proc3": {"vendor_id": "GenuineIntel","model_name": "Intel(R) Xeon(R) Gold 5220R CPU @ 2.20GHz","cpu_mhz": 2200.008,"cache_size": 4096.000,"physical_id": 0,"siblings": 8,"core_id": 3,"cpu_cores": 8},"proc4": {"vendor_id": "GenuineIntel","model_name": "Intel(R) Xeon(R) Gold 5220R CPU @ 2.20GHz","cpu_mhz": 2200.008,"cache_size": 4096.000,"physical_id": 0,"siblings": 8,"core_id": 4,"cpu_cores": 8},"proc5": {"vendor_id": "GenuineIntel","model_name": "Intel(R) Xeon(R) Gold 5220R CPU @ 2.20GHz","cpu_mhz": 2200.008,"cache_size": 4096.000,"physical_id": 0,"siblings": 8,"core_id": 5,"cpu_cores": 8},"proc6": {"vendor_id": "GenuineIntel","model_name": "Intel(R) Xeon(R) Gold 5220R CPU @ 2.20GHz","cpu_mhz": 2200.008,"cache_size": 4096.000,"physical_id": 0,"siblings": 8,"core_id": 6,"cpu_cores": 8},"proc7": {"vendor_id": "GenuineIntel","model_name": "Intel(R) Xeon(R) Gold 5220R CPU @ 2.20GHz","cpu_mhz": 2200.008,"cache_size": 4096.000,"physical_id": 0,"siblings": 8,"core_id": 7,"cpu_cores": 8}},"proc_meminfo": {"MemTotal": 8008052,"MemFree": 158664,"MemAvailable": 604544,"Buffers": 0,"Cached": 612620,"SwapCached": 1835168,"Active": 5949696,"Inactive": 1419512,"Active_anon": 5626500,"Inactive_anon": 1137360,"Active_file": 323196,"Inactive_file": 282152,"Unevictable": 0,"Mlocked": 0,"SwapTotal": 8388604,"SwapFree": 5760516,"Dirty": 44,"Writeback": 0,"AnonPages": 6752844,"Mapped": 39648,"Shmem": 7268,"Slab": 159788,"SReclaimable": 123936,"SUnreclaim": 35852,"KernelStack": 8560,"PageTables": 28224,"NFS_Unstable": 0,"Bounce": 0,"WritebackTmp": 0,"CommitLimit": 12392628,"Committed_AS": 6253548,"VmallocTotal": 34359738367,"VmallocUsed": 24236,"VmallocChunk": 34359710200,"Percpu": 1408,"HardwareCorrupted": 0,"AnonHugePages": 2646016,"CmaTotal": 0,"CmaFree": 0,"HugePages_Total": 0,"HugePages_Free": 0,"HugePages_Rsvd": 0,"HugePages_Surp": 0,"Hugepagesize": 2048,"DirectMap4k": 110464,"DirectMap2M": 5132288,"DirectMap1G": 5242880},"proc_vmstat": {"nr_free_pages": 39666,"nr_alloc_batch": 3701,"nr_inactive_anon": 284340,"nr_active_anon": 1406625,"nr_inactive_file": 70538,"nr_active_file": 80799,"nr_unevictable": 0,"nr_mlock": 0,"nr_anon_pages": 1026707,"nr_mapped": 9912,"nr_file_pages": 611947,"nr_dirty": 11,"nr_writeback": 0,"nr_slab_reclaimable": 30984,"nr_slab_unreclaimable": 8963,"nr_page_table_pages": 7056,"nr_kernel_stack": 535,"nr_unstable": 0,"nr_bounce": 0,"nr_vmscan_write": 1088200,"nr_vmscan_immediate_reclaim": 6873,"nr_writeback_temp": 0,"nr_isolated_anon": 0,"nr_isolated_file": 0,"nr_shmem": 1817,"nr_dirtied": 218823744,"nr_written": 170395459,"numa_hit": 454107982,"numa_miss": 0,"numa_foreign": 0,"numa_interleave": 16858,"numa_local": 454107982,"numa_other": 0,"workingset_refault": 26665707,"workingset_activate": 774314,"workingset_nodereclaim": 105791,"nr_anon_transparent_hugepages": 1292,"nr_free_cma": 0,"nr_dirty_threshold": 41960,"nr_dirty_background_threshold": 13986,"pgpgin": 178123480,"pgpgout": 1867284976,"pswpin": 1657363,"pswpout": 1088113,"pgalloc_dma": 8,"pgalloc_dma32": 245924841,"pgalloc_normal": 405642611,"pgalloc_movable": 0,"pgfree": 651609082,"pgactivate": 40633104,"pgdeactivate": 34441147,"pgfault": 413757285,"pgmajfault": 392847,"pglazyfreed": 32132,"pgrefill_dma": 0,"pgrefill_dma32": 12472005,"pgrefill_normal": 18796815,"pgrefill_movable": 0,"pgsteal_kswapd_dma": 0,"pgsteal_kswapd_dma32": 18354908,"pgsteal_kswapd_normal": 27991307,"pgsteal_kswapd_movable": 0,"pgsteal_direct_dma": 0,"pgsteal_direct_dma32": 8112,"pgsteal_direct_normal": 23500,"pgsteal_direct_movable": 0,"pgscan_kswapd_dma": 0,"pgscan_kswapd_dma32": 20312689,"pgscan_kswapd_normal": 31019993,"pgscan_kswapd_movable": 0,"pgscan_direct_dma": 0,"pgscan_direct_dma32": 10080,"pgscan_direct_normal": 63503,"pgscan_direct_movable": 0,"pgscan_direct_throttle": 0,"zone_reclaim_failed": 0,"pginodesteal": 0,"slabs_scanned": 731136,"kswapd_inodesteal": 12,"kswapd_low_wmark_hit_quickly": 4841,"kswapd_high_wmark_hit_quickly": 765,"pageoutrun": 10477,"allocstall": 614,"pgrotated": 1073280,"drop_pagecache": 0,"drop_slab": 0,"numa_pte_updates": 0,"numa_huge_pte_updates": 0,"numa_hint_faults": 0,"numa_hint_faults_local": 0,"numa_pages_migrated": 0,"pgmigrate_success": 311,"pgmigrate_fail": 0,"compact_migrate_scanned": 3837,"compact_free_scanned": 12493,"compact_isolated": 645,"compact_stall": 19,"compact_fail": 17,"compact_success": 2,"htlb_buddy_alloc_success": 0,"htlb_buddy_alloc_fail": 0,"unevictable_pgs_culled": 0,"unevictable_pgs_scanned": 0,"unevictable_pgs_rescued": 15,"unevictable_pgs_mlocked": 15,"unevictable_pgs_munlocked": 15,"unevictable_pgs_cleared": 0,"unevictable_pgs_stranded": 0,"thp_fault_alloc": 6332,"thp_fault_fallback": 11057,"thp_collapse_alloc": 2135,"thp_collapse_alloc_failed": 30457,"thp_split": 1139,"thp_zero_page_alloc": 2,"thp_zero_page_alloc_failed": 0,"balloon_inflate": 15779328,"balloon_deflate": 15779328,"balloon_migrate": 0,"swap_ra": 1377287,"swap_ra_hit": 1354362},"disks": {"vda": {"reads": 36.827,"rmerge": 0.000,"rkb": 147.308,"rmsec": 16.131,"writes": 621.874,"wmerge": 0.117,"wkb": 4625.356,"wmsec": 874.080,"inflight": 0,"busy": 81.302,"backlog": 888.994,"xfers": 658.701,"bsize": 6144},"sr0": {"reads": 0.000,"rmerge": 0.000,"rkb": 0.000,"rmsec": 0.000,"writes": 0.000,"wmerge": 0.000,"wkb": 0.000,"wmsec": 0.000,"inflight": 0,"busy": 0.000,"backlog": 0.000,"xfers": 0.000,"bsize": 58368}},"networks": {"lo": {"ibytes": 32480.292,"ipackets": 9.565,"ierrs": 0.000,"idrop": 0.000,"ififo": 0.000,"iframe": 0.000,"obytes": 32480.292,"opackets": 9.565,"oerrs": 0.000,"odrop": 0.000,"ofifo": 0.000,"ocolls": 0.000,"ocarrier": 0.000},"ens18": {"ibytes": 610002.917,"ipackets": 661.201,"ierrs": 0.000,"idrop": 0.000,"ififo": 0.000,"iframe": 0.000,"obytes": 527260.381,"opackets": 660.634,"oerrs": 0.000,"odrop": 0.000,"ofifo": 0.000,"ocolls": 0.000,"ocarrier": 0.000}},"uptime": {"days": 14,"hours": 6,"minutes": 52,"users": 5},"filesystems": {"/dev/mapper/centos-root": {"fs_dir": "/","fs_type": "xfs","fs_opts": "rw,relatime,attr2,inode64,noquota","fs_freqs": 0,"fs_passno": 0,"fs_bsize": 4096,"fs_size_mb": 503358,"fs_free_mb": 409292,"fs_used_mb": 94066,"fs_full_percent": 18.688,"fs_avail": 409292,"fs_files": 257845248,"fs_files_free": 257801269,"fs_namelength": 255},"/dev/vda2": {"fs_dir": "/boot","fs_type": "xfs","fs_opts": "rw,relatime,attr2,inode64,noquota","fs_freqs": 0,"fs_passno": 0,"fs_bsize": 4096,"fs_size_mb": 196,"fs_free_mb": 65,"fs_used_mb": 131,"fs_full_percent": 66.610,"fs_avail": 65,"fs_files": 102400,"fs_files_free": 102073,"fs_namelength": 255}}}
2).间隔 5 分钟,采集一天
njmon -s 300 -c 100 -f -m /tmp
(2).安装njmonchart(需要Python3环境)
unzip njmonchart_v40.zip
mv njmonchart_linux_v40.py /usr/local/bin/njmonchart
chmod +x /usr/local/bin/njmonchart

生成 html 报告

njmonchart linux-db1.json linux-db1.html

轻量级的linux监控工具njmon安装与使用

参考资料:​https://www.ibm.com/support/pages/just-got-sent-1000s-nmon-files-help-nsum-rescue​​