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 172.20.17.252
11612 11623 -            log_writer(R)   isredir-DPV: listening on 172.20.17.252
11659 11659 -            isredir-GWV     isredir-GWV: listening on 172.20.17.252
11659 11663 -            log_writer(R)   isredir-GWV: listening on 172.20.17.252
11683 11683 -            isredir-ICV     isredir-ICV: listening on 172.20.17.252
11683 11685 -            log_writer(R)   isredir-ICV: listening on 172.20.17.252
11683 22712 wait         cleanup         isredir-ICV: listening on 172.20.17.252
22619 22619 futex_wait_q join input thre isredir-ICV: handling 172.20.5.170/6301
22619 22620 futex_wait_q I/LGA0BAG/63018 isredir-ICV: handling 172.20.5.170/6301
28749 28749 futex_wait_q isredir-ICV     isredir-ICV: handling 172.20.5.170/5222
29175 29175 futex_wait_q join input thre isredir-ICV: handling 172.20.5.170/6168
29175 29176 -            I/LGA0BAG/61680 isredir-ICV: handling 172.20.5.170/6168
29175 29177 -            O/LGA12JG/48123 isredir-ICV: handling 172.20.5.170/6168

(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. Tildeslash repo owner

    we find that feature very useful and will implement it in the future, but putting on hold for now till the work will begin

  3. Tildeslash repo owner

    Fix Issue #205: Added test for threads count to process check. Syntax: if threads > 10 then alert

    TODO: implement system dependent thread statistics for *BSD, AIX, SOLARIS (done: linux, macosx)

    → <<cset ecfc8c94517b>>

  4. Log in to comment