How can I get the number of queued jobs of a particular type in gearman?

To expand on d5ve's answer, add a -w parameter to "time out" your netcat connection, otherwise you never get back to a command prompt.

$ (echo status ; sleep 0.1) | sudo netcat 127.0.0.1 4730 -w 1

For quick checking, I use this bash one-liner:

(echo status ; sleep 0.1) | netcat 127.0.0.1 4730

This opens a connection to a gearman instance running on localhost, and sends the status query. This contains the name and number of jobs on that instance. The information can then be processed with grep/awk/wc etc. for reporting and alerting.

I also do the same with the workers query which shows all connected workers.

(echo workers ; sleep 0.1) | netcat 127.0.0.1 4730

The sleep is to keep the connection open long enough for the reply.

The full list of administrative commands, and what the output means is at http://gearman.org/protocol/. Just search for "Administrative Protocol".

Tags:

Php

Gearman