Check MK CPU Utilization check

Checkmk Raw Edition 2.2.0p21
Ubuntu 22

Hello guys,

I am trying to implement something that will count the CPU time of processes running on the server. There is already a check in ‘Check_MK’ named ‘CPU utilization of Devices with Modules’.

Unfortunately, it seems that such data is not being pushed out from the agent, as the service is not being detected.

Do you have any other suggestions on how to proceed with this?

My final goal is to monitor CPU time per user(if possible) or globally for each process on the server. The server is a Linux environment, Almalinux 8 to be specific.

Thanks a ton.

Regards,

Marcus

Hi Marcus!
Have you seen the rule Setup→Services→Service discovery rules→Process discovery?

With these settings:

I get these services:

The data stems from the standard ps section which is delivered by the agent anyway, so nothing special must be installed on the agent side.

However, it does not sum up the total CPU time for a certain user, i.e. you cannot say “user X used 1.4 hours of the CPU last week”.

For such a task you need an accounting system, not a monitoring system.

Have a look at https://www.cyberciti.biz/tips/howto-log-user-activity-using-process-accounting.html for example.

The output of the sa command could then be used as input for a checkmk check if you need to define thresholds and notify on them.

1 Like

Dirk, hello, and thanks a ton!

Would it be possible to apply the following config:

Process Name: lsphp %u
Regular experssion matching command line: ps auxf | grep lsphp
Name of the operating system user: Grab user from found processes

Apologize for asking and not testing, but I am not sure if this is even possible.

Appreciate your help a lot.

Marcus

No. In that field you should enter either the name of the binary (e.g. /usr/bin/lsphp) or a regular expression that matches (the beginning of) the process(es) you want to find (e.g. .*lsphp). The latter will find all processes with some prefix (like /usr/bin/ or /bin/ or /sbin/) and then the string lsphp.

The field is NOT meant for some shell command (like ps …| grep …) that should be run on the client computer to find processes.

If you want to find all lsphp processes, then either write

image

or

image

And yes, I assume it will work. It doesn’t differ much from my bash example.

Hello,

Thanks a lot. I cant get this to work, apologize for multiple replies, but I’ve done exactly as you mentioned. Also went through the docs.

What I have done so far:

Added rule in ‘Process Discovery’ with these specs:

Process name: httpd %u
Process Matching: .*httpd
Name of operating system user:
Default parameters for detected services: CPU rescale maximum load: 100% is all cores at full load


Levels for process count: 1 processes, 1 processes, 99999 processes, 99999 processes
Levels on total CPU utilization: 90.0%, 98.0%
CPU averaging: 15 minutes
Virtual memory usage: 1000 MiB, 2000 MiB
Virtual memory averaging: 15 minutes
Enable per-process details in long-output: HTML output [! testing

I did run service discovery, even though this should not be the case.

When I add process discovery it should apply it to all hosts under a folder, that have agent installed right?

I am missing something and cant seem to find what.

Thanks !

Marcus

Update! Got it. I do not know but the second service discovery did the trick!

Thanks a ton for the help.

If by any change you can push me in a direction for CPU time monitoring for X user, I would love to hear it!

Marcus