-
assigned issue to
- edited description
Monit shows zero percent CPU usage for a few seconds after Monit (or a process) starts/stops
Is this normal?
Monit shows most process at 0% CPU for a few moments after startup or a program is started/stopped. This causes incorrect flags in the monitoring such as "if CPU <" or "if CPU = 0" etc.
This is also reflected in the web page Monit Service Manager, which is much slower to update with correct values.
[BST May 11 08:40:49] info : Starting Monit HTTP server at [*]:22812
[BST May 11 08:40:49] info : Monit HTTP server started
[BST May 11 08:40:49] info : 'encoder-1A' Monit reloaded
[BST May 11 08:40:49] error : 'itv2' cpu usage of 0.0% matches resource limit [cpu usage=0.0%]
[BST May 11 08:40:49] error : 'bbconehd' cpu usage of 0.0% matches resource limit [cpu usage=0.0%]
[BST May 11 08:40:49] error : 'bbcfourhd' cpu usage of 0.0% matches resource limit [cpu usage=0.0%]
[BST May 11 08:40:49] error : 'itvhd' cpu usage of 0.0% matches resource limit [cpu usage=0.0%]
[BST May 11 08:40:49] error : 'pbsamerica' cpu usage of 0.0% matches resource limit [cpu usage=0.0%]
[BST May 11 08:40:49] error : 'sonycrime2' cpu usage of 0.0% matches resource limit [cpu usage=0.0%]
[BST May 11 08:40:49] error : 'freesports' cpu usage of 0.0% matches resource limit [cpu usage=0.0%]
[BST May 11 08:40:49] error : 'bbctwohd' cpu usage of 0.0% matches resource limit [cpu usage=0.0%]
[BST May 11 08:40:49] error : 'channel4hd' cpu usage of 0.0% matches resource limit [cpu usage=0.0%]
[BST May 11 08:40:49] error : 'channel5hd' cpu usage of 0.0% matches resource limit [cpu usage=0.0%]
[BST May 11 08:40:49] error : 'film4plus1' cpu usage of 0.0% matches resource limit [cpu usage=0.0%]
an example of similar when a process is started/stopped etc:
[BST May 11 08:27:46] error : 'bbcfourhd' cpu usage of 0.0% matches resource limit [cpu usage=0.0%]
[BST May 11 08:27:46] info : 'bbcfourhd' exec: /home/user/monit-restart-service.sh
[BST May 11 08:27:46] info : 'bbcfourhd' stop on user request
[BST May 11 08:27:46] info : Monit daemon with PID 4110 awakened
[BST May 11 08:27:46] info : Awakened by User defined signal 1
[BST May 11 08:27:46] info : 'bbcfourhd' stop: /etc/init.d/bbcfourhd
[BST May 11 08:27:46] info : 'bbcfourhd' stop action done
[BST May 11 08:27:46] error : 'mutp110' cpu usage of 15.9% matches resource limit [cpu usage>8.0%]
[BST May 11 08:27:46] error : 'itv2' cpu usage of 0.0% matches resource limit [cpu usage=0.0%]
[BST May 11 08:27:46] error : 'itvhd' cpu usage of 0.0% matches resource limit [cpu usage=0.0%]
[BST May 11 08:27:46] error : 'sonycrime2' cpu usage of 0.0% matches resource limit [cpu usage=0.0%]
[BST May 11 08:27:46] error : 'freesports' cpu usage of 0.0% matches resource limit [cpu usage=0.0%]
[BST May 11 08:27:46] error : 'bbctwohd' cpu usage of 0.0% matches resource limit [cpu usage=0.0%]
[BST May 11 08:27:46] error : 'channel4hd' cpu usage of 0.0% matches resource limit [cpu usage=0.0%]
[BST May 11 08:27:46] error : 'channel5hd' cpu usage of 0.0% matches resource limit [cpu usage=0.0%]
[BST May 11 08:27:46] error : 'film4plus1' cpu usage of 0.0% matches resource limit [cpu usage=0.0%]
Thank you.
Comments (5)
-
repo owner -
repo owner Please can you verify the monit version?:
monit -V
The problem should be fixed in monit 5.25.0 and later, changelog snip:
Fixed: Issue #676: Process CPU usage is reported always as 0.0% in the first cycle after process start
-
It's definitely version 5.25.1
Thank you.
-
repo owner I'm unable to reproduce the issue. I used the following configuration:
set daemon 5 set httpd port 2812 allow localhost check process test matching test if cpu usage > 10% then alert
and the following cpu-hog script executed with "bash test.sh":
while true; do echo hello; done
When i reloaded monit, it reported the CPU usage correctly.
Please can you provide some test case with monit configuration example that will allow to reproduce the issue? (some cpu-hog shell script).
Note that monit reflects the number of threads and CPU cores when calculating the CPU usage, the formula is described in the manual: https://mmonit.com/monit/documentation/monit.html#Process-resource-tests If your processes have lots of idle threads and the machine has enough CPU cores, the average CPU usage of your process can be close to 0%. You can check the number of threads for example this way:
ps -eo pid,nlwp,args
-
@welshdemon
did you watch the processes with top or htop, at the same moment ? what does it report ?
- Log in to comment