I have a number of gearman clients sending a job, say job1.
$client = new GearmanClient();
$client->addServer();
$client->doBackground('job1', 'workload');
It takes, say 10 seconds to process this job. I want to track how many 'job1' jobs are waiting for a worker to work on them at any given time. How can I do that?
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".
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With