Search code examples
linuxubuntumonitoringzombie-processzabbix

Monitoring Zombie processes


Currently Nagios monitors zombie processes with this command:

$USER1$/check_nrpe -H $HOSTADDRESS$ -c check_procs_status -a $ARG1$ $ARG2$ $ARG3$

It checks for zombie processes with state = X,Z. From a Linux or Ubuntu machine, I can run this command to view Zombie processes:

ps aux | grep 'X'

How to do I get both 'X' and 'Z' state in one line. I want to configure same monitor in Zabbix


Solution

  • You can use grep -E or egrep for multiple matches:

    ps aux | grep -E 'X|Z'
    

    As per your suggested review I see that you want the 8th column to be either "X" or "Y". For that, you can do:

    ps aux | awk '$8=="X" || $8=="Y"'
    

    Example

    $ cat a
    hello
    bye
    blabla bye
    other things
    $ grep -E 'bye|hello' a
    hello
    bye
    blabla bye