Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Is it possible to use monit to count the number of instances of a process (in my case Celery) and take an action accordingly.

For example if there are 4 instances of celery daemon, then take action

share|improve this question

1 Answer 1

up vote 4 down vote accepted

This should be doable using a short shell script, and program status testing. Something like

check program countCelery with path /usr/local/bin/ with timeout 600 seconds:
if status != 0 alert

with a shell script like:

celery_count=$(pgrep -c Celery)
if [[ $celery_count -gt 4 ]]; then
  exit 1
  exit 0
share|improve this answer
cool. i will test this right away and let u know – aqs May 22 '13 at 13:25
This worked, thanks a lot – aqs May 23 '13 at 10:18
In the version of Monit we use, the syntax is -- check program countCelery with path /usr/local/bin/ with timeout 30 seconds if status != 0 then alert – tgharold Jun 16 '14 at 20:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.