enhance process check for threads

Issue #205 resolved
Ulrich Windl
created an issue

When monitoring a process, monit watches the child processes ("Children"), but it does not look at threads. As it is imaginable that you might be interested when some process creates many threads, it would be nice if monit could look at threads also. Consider this example (these processes are managed by monit already):

 PID   TID Queue        ThreadTitle     ProcessTitle
11612 11612 -            isredir-DPV     isredir-DPV: listening on
11612 11623 -            log_writer(R)   isredir-DPV: listening on
11659 11659 -            isredir-GWV     isredir-GWV: listening on
11659 11663 -            log_writer(R)   isredir-GWV: listening on
11683 11683 -            isredir-ICV     isredir-ICV: listening on
11683 11685 -            log_writer(R)   isredir-ICV: listening on
11683 22712 wait         cleanup         isredir-ICV: listening on
22619 22619 futex_wait_q join input thre isredir-ICV: handling
22619 22620 futex_wait_q I/LGA0BAG/63018 isredir-ICV: handling
28749 28749 futex_wait_q isredir-ICV     isredir-ICV: handling
29175 29175 futex_wait_q join input thre isredir-ICV: handling
29175 29176 -            I/LGA0BAG/61680 isredir-ICV: handling
29175 29177 -            O/LGA12JG/48123 isredir-ICV: handling

(I wrote that program, so it uses variable process titles and thread titles to indicate what each thread does)

Here we have one process using two threads (main, log writer) when idle. When the process handles requests, it runs an additional "cleanup" thread plus a new process per request that has three threads (main, input, output).

I've seen a commercial java application that started >200 threads, also. I never knew whether this was in error, but maybe you want to know if such a thing happens.

Comments (6)

  1. Tildeslash repo owner

    Formatted process listing. Regarding the issue, this seems useful. The number of threads in a process might say something meaningful about the task in question, at least the OS pressure regarding context switching, also how memory is distributed internally as each OS native thread uses a thread-stack of around 8MB. This should be "trivial" to implement. I suggest the configuration could be something simple like this:

    check process foo
              if threads > 200 then alert
  2. Log in to comment