Question

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

Was it helpful?

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

OTHER TIPS

/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z,X

ps aux | grep 'X\|Z'

It should grep on X or Z

This can be achieved in multiple ways. I propose something like:

ps -eo stat,pid,cmd | grep ^Z 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top