#65 check_procs Process State Matching

open
nobody
None
5
2010-10-15
2010-10-15
J. Bern
No

[Checked with 1.4.14 on CentOS 5.5]

SUMMARY: Please provide state-matching options better suited for multi-character "stat" fields in the "ps" output.

DETAILS: check_procs.c effectively does the state matching with a strstr(command_line_parameter,stat_field_of_ps_output). That's OK for platforms where the state is a single character, like the "S", "R", etc. mentioned in the plugin's online help. Linux, and supposedly several more platforms, however use multi-character not-fully-specified-order states:

# ./check_procs -vv | grep '^Ma[t]ched:' | sed -e 's/.* \(stat=[^ ]*\) .*/\1/' | sort -u | tr '\n' ' '
stat=R stat=R+ stat=RN stat=Rs stat=S stat=S< stat=S+ stat=SLs stat=SN stat=Ss stat=S<s stat=Ss+ stat=Ssl stat=S<sl

EXAMPLE 1: check_procs *cannot* match Nagios' own master process (stat=Ssl or Rsl; there should be only one!) without matching all its temp children (stat=S or R) as well.

EXAMPLE 2: To match "all nonblocked processes" (state=R* or S*, as opposed to D*, T*, or Z*), one would have to construct an "-s" parameter which contains all possible variations as explicit substrings ... which is prohibitive.

SUGGESTION (if I may): Two new options which implement "*all* characters from stat must appear in parameter" and "*one* character from stat needs to appear in parameter" and can be combined would IMHO go a long way.

WHY AM I NOT DOING THIS MYSELF: Sorry, Linux is currently the only platform I have available ...

Discussion

  • Thomas Oettli
    Thomas Oettli
    2011-01-26

    I've got the same problem here.
    Currently, I'm checking a lot Linux servers for zombie processes, this is working well so far.
    Today, one machine had a lot of hanging backup processes and I was wondering, why the plugin didn't recognize that.

    After some debugging, I've seen that these processes had the state ZN (zombie with low-priority).

    In fact it isn't important for me if zombie processes have a lower priority or not, I would like to be able to count all processes which have a "Z" in their state.

    POSSIBLE SOLUTION: Please implement a method to match the state with wild-cards or a regular expression (e.g. --state="*Z*" or --state="m/.*Z.*/")