【RHCA+】nmon命令(监控系统资源)

发布时间:2026/11/2 10:56:24
【RHCA+】nmon命令(监控系统资源) “ 目录RHCA - 12 系统监控 - 7 nmon命令监控系统资源 ”监控系统资源语法格式nmon一、nmon1、下载官网https://nmon.sourceforge.io/pmwiki.php?nSite.Download[rootwuzuniao ~]# wget http://sourceforge.net/projects/nmon/files/nmon16e_x86_rhel72 #下载二进制文件[rootwuzuniao ~]# chmod x nmon16e_x86_rhel72 #赋予执行权限[rootwuzuniao ~]# mv nmon16e_x86_rhel72 /usr/sbin/nmon16e #重命名到系统命令目录文件名可任意命名2、使用[rootwuzuniao ~]# nmon16e #执行程序二、njmonnjmon和nmon一样但可以将结果保存为JSON格式文件或保存到InfluxDB1、下载官网https://zh.osdn.net/projects/sfnet_nmon/downloads/njmon_linux_binaries_v78.zip浏览器访问后下载到本地然后本地解压上传对应架构和系统的二进制文件到Linux服务器直接下载到Linux上unzip解压缩不了[rootwuzuniao ~]# chmod x njmon_RHEL7_x86_64_v78 #赋予执行权限[rootwuzuniao ~]# mv njmon_RHEL7_x86_64_v78 /usr/sbin/njmon #重命名到系统命令目录2、使用[rootwuzuniao ~]# njmon #执行程序默认每60s输出一次报告立即回显的为PID号61116[rootwuzuniao ~]#{timestamp: {datetime: 2024-06-26T23:30:53,UTC: 2024-06-26T15:30:53,snapshot_seconds: 60,snapshot_maxloops: -1,snapshot_loop: 1,sleeping: 59.953,execute_time: 0.047,sleep_overrun: 0.001,elapsed: 60.001},identity: {hostname: wuzuniao,fullhostname: wuzuniao,njmon_command: njmon ,njmon_version: njmon4Linux-v78-RHEL-7-x86_64-njmon_linux_v78.c (Sep 23 2021),username: root,userid: 0,fullhostname1: wuzuniao,lo_IP4: 127.0.0.1,ens33_IP4: 192.168.1.160,virbr0_IP4: 192.168.122.1,lo_IP6: ::1,ens33_IP6: 2408:8266:201:a67:5738:bc71:8ce4:c576,ens33_IP6_b: fe80::381f:f8bd:1052:2747,serial-number: VMware-56 4d 7b 83 ed a9 af 6a-98 31 17 5e 2a 29 9a e2,model: VMware Virtual Platform,vendor: VMware, Inc.},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 (mockbuildkbuilder.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: 1,online_cpu_list: 0,threads_per_core: 1,cores_per_socket: 1},cpu_total: {user: 0.133,nice: 0.000,sys: 0.233,idle: 99.299,iowait: 0.017,hardirq: 0.000,softirq: 0.000,steal: 0.000,guest: 0.000,guestnice: 0.000},cpus: {cpu0: {user: 0.133,nice: 0.000,sys: 0.233,idle: 99.299,iowait: 0.017,hardirq: 0.000,softirq: 0.000,steal: 0.000,guest: 0.000,guestnice: 0.000}},stat_counters: {ctxt: 91.832,btime: 1719410534,processes_forks: 0.350,procs_running: 2,procs_blocked: 0},cpuinfo: {proc0: {vendor_id: GenuineIntel,model_name: 12th Gen Intel(R) Core(TM) i5-12400,cpu_mhz: 2496.003,cache_size: 18432.000,physical_id: 0,siblings: 1,core_id: 0,cpu_cores: 1}},proc_meminfo: {MemTotal: 995672,MemFree: 67228,MemAvailable: 290024,Buffers: 0,Cached: 327860,SwapCached: 128,Active: 349816,Inactive: 245760,Active_anon: 189108,Inactive_anon: 90628,Active_file: 160708,Inactive_file: 155132,Unevictable: 0,Mlocked: 0,SwapTotal: 2097148,SwapFree: 2095604,Dirty: 4,Writeback: 0,AnonPages: 267552,Mapped: 40832,Shmem: 12020,Slab: 132656,SReclaimable: 69308,SUnreclaim: 63348,KernelStack: 7168,PageTables: 20836,NFS_Unstable: 0,Bounce: 0,WritebackTmp: 0,CommitLimit: 2594984,Committed_AS: 2147376,VmallocTotal: 34359738367,VmallocUsed: 213544,VmallocChunk: 34359277564,Percpu: 56320,HardwareCorrupted: 0,AnonHugePages: 67584,CmaTotal: 0,CmaFree: 0,HugePages_Total: 0,HugePages_Free: 0,HugePages_Rsvd: 0,HugePages_Surp: 0,Hugepagesize: 2048,DirectMap4k: 108416,DirectMap2M: 940032,DirectMap1G: 0},proc_vmstat: {nr_free_pages: 16807,nr_alloc_batch: 698,nr_inactive_anon: 22657,nr_active_anon: 47277,nr_inactive_file: 38783,nr_active_file: 40177,nr_unevictable: 0,nr_mlock: 0,nr_anon_pages: 49992,nr_mapped: 10208,nr_file_pages: 81997,nr_dirty: 1,nr_writeback: 0,nr_slab_reclaimable: 17327,nr_slab_unreclaimable: 15837,nr_page_table_pages: 5209,nr_kernel_stack: 448,nr_unstable: 0,nr_bounce: 0,nr_vmscan_write: 362,nr_vmscan_immediate_reclaim: 0,nr_writeback_temp: 0,nr_isolated_anon: 0,nr_isolated_file: 0,nr_shmem: 3005,nr_dirtied: 17643,nr_written: 16852,numa_hit: 4734218,numa_miss: 0,numa_foreign: 0,numa_interleave: 19450,numa_local: 4734218,numa_other: 0,workingset_refault: 17541,workingset_activate: 9213,workingset_nodereclaim: 0,nr_anon_transparent_hugepages: 33,nr_free_cma: 0,nr_dirty_threshold: 20309,nr_dirty_background_threshold: 6769,pgpgin: 759175,pgpgout: 104425,pswpin: 20,pswpout: 362,pgalloc_dma: 50937,pgalloc_dma32: 5143258,pgalloc_normal: 0,pgalloc_movable: 0,pgfree: 5211095,pgactivate: 120592,pgdeactivate: 106251,pgfault: 10829508,pgmajfault: 2023,pglazyfreed: 0,pgrefill_dma: 1546,pgrefill_dma32: 116882,pgrefill_normal: 0,pgrefill_movable: 0,pgsteal_kswapd_dma: 1162,pgsteal_kswapd_dma32: 100950,pgsteal_kswapd_normal: 0,pgsteal_kswapd_movable: 0,pgsteal_direct_dma: 0,pgsteal_direct_dma32: 0,pgsteal_direct_normal: 0,pgsteal_direct_movable: 0,pgscan_kswapd_dma: 1380,pgscan_kswapd_dma32: 119539,pgscan_kswapd_normal: 0,pgscan_kswapd_movable: 0,pgscan_direct_dma: 0,pgscan_direct_dma32: 0,pgscan_direct_normal: 0,pgscan_direct_movable: 0,pgscan_direct_throttle: 0,zone_reclaim_failed: 0,pginodesteal: 0,slabs_scanned: 61184,kswapd_inodesteal: 0,kswapd_low_wmark_hit_quickly: 7,kswapd_high_wmark_hit_quickly: 4,pageoutrun: 23,allocstall: 0,pgrotated: 362,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: 0,pgmigrate_fail: 0,compact_migrate_scanned: 0,compact_free_scanned: 0,compact_isolated: 0,compact_stall: 0,compact_fail: 0,compact_success: 0,htlb_buddy_alloc_success: 0,htlb_buddy_alloc_fail: 0,unevictable_pgs_culled: 0,unevictable_pgs_scanned: 0,unevictable_pgs_rescued: 0,unevictable_pgs_mlocked: 0,unevictable_pgs_munlocked: 0,unevictable_pgs_cleared: 0,unevictable_pgs_stranded: 0,thp_fault_alloc: 247,thp_fault_fallback: 14,thp_collapse_alloc: 27,thp_collapse_alloc_failed: 0,thp_split: 14,thp_zero_page_alloc: 0,thp_zero_page_alloc_failed: 0,balloon_inflate: 0,balloon_deflate: 0,balloon_migrate: 0,swap_ra: 17,swap_ra_hit: 8},disks: {sda: {reads: 0.000,rmerge: 0.000,rkb: 0.000,rmsec: 0.000,writes: 0.117,wmerge: 0.000,wkb: 0.450,wmsec: 0.000,inflight: 0,busy: 0.000,backlog: 0.000,xfers: 0.117,bsize: 24576},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: 0.000,ipackets: 0.000,ierrs: 0.000,idrop: 0.000,ififo: 0.000,iframe: 0.000,obytes: 0.000,opackets: 0.000,oerrs: 0.000,odrop: 0.000,ofifo: 0.000,ocolls: 0.000,ocarrier: 0.000},ens33: {ibytes: 41.800,ipackets: 0.533,ierrs: 0.000,idrop: 0.200,ififo: 0.000,iframe: 0.000,obytes: 204.131,opackets: 0.317,oerrs: 0.000,odrop: 0.000,ofifo: 0.000,ocolls: 0.000,ocarrier: 0.000}},uptime: {days: 0,hours: 1,minutes: 28,users: 1},filesystems: {/dev/mapper/centos-root: {fs_dir: /,fs_type: xfs,fs_opts: rw,seclabel,relatime,attr2,inode64,noquota,fs_freqs: 0,fs_passno: 0,fs_bsize: 4096,fs_blocks: 23581440,fs_bfree: 22176871,fs_bavail: 22176871,fs_size_mb: 92115,fs_free_mb: 86628,fs_used_mb: 5487,fs_full_percent: 5.956,fs_avail: 86628,fs_files: 47185920,fs_files_free: 47021778,fs_namelength: 255},/dev/sda1: {fs_dir: /boot,fs_type: xfs,fs_opts: rw,seclabel,relatime,attr2,inode64,noquota,fs_freqs: 0,fs_passno: 0,fs_bsize: 4096,fs_blocks: 259584,fs_bfree: 215702,fs_bavail: 215702,fs_size_mb: 1014,fs_free_mb: 842,fs_used_mb: 172,fs_full_percent: 16.905,fs_avail: 842,fs_files: 524288,fs_files_free: 523948,fs_namelength: 255},/dev/mapper/centos-home: {fs_dir: /home,fs_type: xfs,fs_opts: rw,seclabel,relatime,attr2,inode64,noquota,fs_freqs: 0,fs_passno: 0,fs_bsize: 4096,fs_blocks: 1829376,fs_bfree: 1820116,fs_bavail: 1820116,fs_size_mb: 7146,fs_free_mb: 7109,fs_used_mb: 37,fs_full_percent: 0.506,fs_avail: 7109,fs_files: 3663872,fs_files_free: 3663706,fs_namelength: 255}}}[rootwuzuniao ~]# njmon -? #查看命令帮助njmon: help information. Version:njmon4Linux-v78-RHEL-7-x86_64-njmon_linux_v78.c (Sep 23 2021)- Performance stats collector outputting JSON or Influx Line Protocol format.- If the commend starts with njmon it runs in NJMON mode- If the commend starts with nimon it runs in NIJMON mode- -J forces NJMON mode regardless of the command name- -I forces NIMON mode regardless of the command name- Default is stdout- Core syntax : njmon -s seconds -c count- File output : -m directory -f- Check restart: -k and -K filename- Data options: -H -P -t % -b -d -W -r -n -R -F- Argument file: -a file (do not include the command name)- NJMON Network connection: -i njmond_host -p port- NIMON Network connection: -i InfluxDB_host -p portNIMON InfluxDB Details : -x database [-y username [-x password]]Prometheus mode : -w-! : Version check and immediate exit-? : This help informtion-s seconds : seconds between snapshots of data (default 60 seconds)-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: NIMON mode - Data: hostname__.influxlp: NJMON mode - Data: hostname__.json: Error: hostname__.err-ff : NIMON mode - Note: a second -f adds a timestamp so this data can be added to InfluxDB later-a file : Command line arguments are in the file (hides passwords): Use the same arguments, all on the first line, space separated: Only have the -a option on the actual command line-H : NIMON mode - Force host tag to be a Fully Qualified Domain Name-k : NIMON mode - Read /tmp/nimon.pid for a running nimon PID if found-k : NJMON mode - Read /tmp/njmon.pid for a running njmon PID if foundstill running then this process exits quietly-K filename : User defined pid filename (implies -k). Allows not using /tmp ormultiple concurrent data captures-I : Force to NIMON mode. Saving InfluxDB Line Protocol data or njmond.py or other Timeseries database-J : Force to NJMON mode. Set njmon mode for JSON format for njmond.py or other Timeseries database-P : Add process stats (take CPU cycles and large stats volume)-t percent : Set ignore process CPU use percent threshold (default 0.01%)-b : Switch of adding pid to the process names: ksh_76927 - ksh-? or -h : This output and stop-d : Switch on debug tracing (output no longer JSON/line protocol format)-D : Disk stats include all devices in /proc/diskstats, not just the real disks-W : Switch off warning messages in error output stream-r : Random start pause. Stops cron making every program send data in sync-n : No PID printed out at start up.-R : Reduced stats - skip logical CPU stats for SMT threads.-F : Switch off filesystem stats (autofs and tmpfs can cause issues)--- NIMON mode options ---- Sent data to InfluxDB (all of these are inportant for InfluxDB):-i hostname : Hostmane or IP address of the influxDB server-p port : InfluxDB port (default is 8086)-x njmon : InfluxDB database name created with influx create database njmon-y user : Mandatory InfluxDB username - if you have set a username for the API (otherwise ignored)-z pass : Mandatory InfluxDB password - if you have set a password for the API (otherwise ignored)-w : For output to Telegraf. Dont send POST, message type or packet size-v : Show data response to InfluxDB on stderrCurrently, InfluxDB security certificates are not implementedExamples:1 Take a look at the Line Protocol data/usr/local/bin/nimon -s 2 -c 3 -f then edit __.influxlp2 Every 1 minute all day using the default port of 8086/usr/local/bin/nimon -s 30 -c 2880 -i influxbox -x njmon -y Nigel -z passwd3 Add process stats use IP address/usr/local/bin/nimon -s 60 -c 1440 -P -i 9.137.62.12 -p 8086 -x njmon -y nag -z XXXX4 Crontab run 1 day - start 1 minute after midnight, save local data every 30 seconds1 0 * * * /usr/local/bin/nimon -s 30 -c 2880 -i influxbox -p 8086 -x njmon -y Nigel -z passwd5 Crontab - hourly check/restart nimon (if nimon is not running)0 * * * * /usr/lbin/nimon -k -s 60 -i influxbox -p 8086 -x njmon -y jane -z j1j1j16 Crontab - as 5 but output for telegraf0 * * * * /usr/lbin/nimon -w -k -s 60 -i influxbox -p 8086 -x njmon -y jane -z j1j1j1--- NJMON mode options or other Time-Series database ---Push data to central njmond daemon:-i ip/host : IP address or Hostname of the njmond central daemon-p port : Port number on njmond.py hostExamples:1 Every 5 mins all day/usr/local/bin/njmon -s 300 -c 288 -f -m /home/perf2 Piping to data handler all day at 30 second intervals/usr/local/bin/njmon -s 30 -c 1440 | myprog3 Use the defaults (-s 60 forever) and save to a file./njmon my_server_today.json4 Send data to the central daemon with no password./njmon -s 30 -c 2880 -i admin.acme.com -p 81815 Send data to the central daemon with process stats and with password./njmon -s 60 -c 1440 -P -i admin.acme.com -p 8181 -X passwordCrontab options:6 Crontab only save to a file (2 minutes past midnight)2 0 * * * /usr/local/bin/njmon -s 60 -c 1440 -f -m /home/perf7 Crontab daily at midnight start sending data to central server0 0 * * * /usr/local/bin/njmon -s 30 -c 2880 -i admin.acme.com -p 81818 Crontab send data to central server check hourly (if njmon is not running)0 * * * * /usr/local/bin/njmon -k -s 30 -i admin.acme.com -p 81819 Crontab use ssh to start njmon, send data back via socket to a local InfluxDB injector program0 0 * * * ssh rootendpoint /usr/local/bin/njmon -s 30 -c 2880 -i admin.acme.com -p 8181[rootwuzuniao ~]#

关于本文作者

来自尧图内容编辑团队

尧图内容编辑团队 内容团队

尧图内容编辑团队

本文由尧图网络内容编辑团队执笔。团队由资深项目经理、前端工程师与设计师组成,所有内容均来自亲手交付的真实项目,先讲清问题、再给出可落地的解法。尧图深耕北京网站建设十年,服务过京华建材集团、智造科技等各行业客户,把一线经验沉淀为可复用的行业观察。

  • 十年建站经验,覆盖建材、制造、服务、文创等
  • 项目经理把关选题与事实准确性
  • 工程师与设计师联合撰写专业细节
  • 统一编辑规范,保证文风与排版一致
  • 每月复盘转化数据,迭代选题方向

延伸阅读

相关资讯与近期热门内容

深度阅读推荐

建站决策前值得细读的三篇

网站改版的5个关键决策
2024-08-12

网站改版的5个关键决策

什么时候该改版、改到什么程度、如何避免流量掉光,京华建材集团改版复盘给出答案。

获取专属建站方案

看完文章,把您的行业与预算告诉我们,免费获取一份量身定制的官网建设方案与报价。

立即免费咨询