Could we disable the "monitor the number of open files of a process" by default.
The feature is added by following commit:
tildeslash / monit / Commit cb30233aadf1 — Bitbucket
_parseProcFdCount(&proc);
By default monit will read the /proc/<pid> all the time, even without configuration related rules.
Could we disable the "monitor the number of open files of a process" by default, and enable it just after the related rule exist?
Thanks,
Mark
Comments (7)
-
reporter -
I’m mostly on BSD and macOS so haven’t used this, but when I look at the Linux code I can see that it is indeed called all the time whenever ProcessTable is updated (which is often). The code in
_parseProcFdCount
does seem to be heavy and should probably not run if not used in the configuration. Have you profiled Monit and see that this particularly code is heavy on the CPU?
-
reporter Hello hauk,
Yes it is. I can see the CPU usage of monit could periodically peak to about 20% in several seconds, by top command.
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
3748 sbcsig 20 0 8404 4796 4200 S 21.2 0.0 9:42.67 monit
And by perf, I could see following call-back from kernel level.
perf report --no-children
Samples: 2K of event 'cpu-clock:pppH', Event count (approx.): 690500000
Overhead Comma Shared Object Symbol- 29.72% monit [kernel.kallsyms] [k] __d_lookup
- __d_lookup
- 29.65% d_lookup
proc_fill_cache `
proc_readfd_common
iterate_dir
ksys_getdents64
__ia32_sys_getdents64
do_fast_syscall_32
entry_SYSENTER_compat
0xf7f5a129
0x1 - 15.03% monit [kernel.kallsyms] [k] proc_readfd_common
proc_readfd_common
iterate_dir
ksys_getdents64
__ia32_sys_getdents64
do_fast_syscall_32
entry_SYSENTER_compat
0xf7f5a129
0x1 - 12.93% monit [kernel.kallsyms] [k] filldir64
- 12.24% monit [kernel.kallsyms] [k] proc_fill_cache
- 6.15% monit [kernel.kallsyms] [k] _raw_spin_lock
- 2.28% monit [kernel.kallsyms] [k] __raw_callee_save___pv_queued_spin_unlock
Thanks,
Mark
-
reporter FYI.
We used RHEL8 as test bed.
uname -a
Linux oam-a 4.18.0-513.11.1.el8_9.x86_64
#1SMP Thu Dec 7 03:06:13 EST 2023 x86_64 x86_64 x86_64 GNU/Linux
-
reporter -
Over 1 Million TCP sockets! That’s a lot! No wonder it takes time and CPU counting those
-
- changed status to open
- Log in to comment
If enable by default, it will contribute more CPU usage.