有什么方法可以访问 Gearman 管理吗?
我希望能够查询 gearman 服务器以确定我正在运行的工作线程的实例数(基本上我想确保 RunTaskA
可用并且 RunTaskB
可用如果没有工作人员处理这些任务,我希望能够发送警报。
有什么方法可以做到这一点吗?
另外:如果你知道查询 gearman 服务器的 PHP 方法,那就太疯狂了
。 /strong>:我知道本机可用的 PHP gearman 扩展,但我不是在寻找任务提交扩展,我需要一些允许我查询 gearman 服务器并查看有多少工作人员正在执行特定任务的东西。
I want to be able to query a gearman server to determine how many instances of a worker I have running (basically I want to make sure that RunTaskA
is available and RunTaskB
is available if there are no workers handling those tasks, I want to be able to send an alert out.
Is there any way to do this?
Also: Mad props if you know of a PHP way to query the gearman server.
Edit: I know about the PHP gearman extension that is available natively, but I am not looking for a task submission extension, I need something that allows me to query the gearman server and see how many workers are serving a specific task.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
为了快速检查,我使用了这个 bash 单行代码:
这将打开与本地主机上运行的 gearman 实例的连接,并发送“状态”查询。其中包含该实例上作业的名称和数量。然后可以使用 grep/awk/wc 等处理该信息以进行报告和警报。
我也对“workers”查询执行相同的操作,该查询显示所有连接的工作人员。
睡眠是为了保持连接打开足够长的时间以进行回复。
管理命令的完整列表以及输出的含义位于 http://gearman.org/index .php?id=protocol 只需搜索“管理协议”
For quick checking, I use this bash one-liner:
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.
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/index.php?id=protocol Just search for "Administrative Protocol"
为了扩展 d5ve 的答案,由于 netcat 将坐在套接字上等待,因此您可以添加一个 -w 参数以及运行的最大秒数。因此,如果您正在查询 localhost:
...,否则您将永远不会回到命令提示符。
To expand on d5ve's answer, since netcat will sit and wait on the socket, you can add a -w parameter with a maximum number of seconds to run. So if you're querying localhost:
... otherwise you never get back to a command prompt.
据我所知,gearman 中没有这样的扩展,管理和监视工作脚本是您的责任,您可以为此目的尝试其中一个 -
Supervisord 是一个 python 应用程序,用于在后台运行应用程序并监视它们。
或者您可以使用 brian Moon 的 gearman manager
As far as i know there are no such extension in gearman, Managing and monitoring worker script is your responsibility you can try one of these for this purpose -
Supervisord is a python appliation for running application in background and monitoring them.
OR you can use brian moon's gearman manager
我想你需要这个
http://github.com/liorbk/php
I think you need this
http://github.com/liorbk/php
Gearman 有一个 php 扩展。你调查过了吗?
PHP 链接
Gearman has a php extension. Have you looked into that yet?
PHP Link
今天偶然发现它,我自己还没有测试过,但看起来很有希望。
https://github.com/yugene/Gearman-Monitor
Stumbled on it today, haven't tested it myself but it looks promising.
https://github.com/yugene/Gearman-Monitor
在 Python 中,您可以执行以下操作:
注意:您必须使用 pip 或 easy_install 安装名为“gearman”的软件包,以避免运行上述代码时出现任何异常。
另外,请检查以下管理客户端,它们总体上简化了 gearman 的管理。
In Python you could do the following:
Note: you have to install package named "gearman" using pip or easy_install to avoid any exceptions running the above code.
Also, Check the following admin clients that is simplifying administering gearman in general.
当其他一切都失败时,您可以使用 Ubuntu 中
gearman-tools
包中的gearadmin
工具,通过调用exec()
来执行它新流程。这是对其输出格式的参考。这假设 PHP 和 Gearman 在同一服务器上运行。
When everything else fails, you can use the
gearadmin
tool found in thegearman-tools
package in Ubuntu by callingexec()
to execute it in the new process. Here is a reference to its output format.This assumes PHP and Gearman are running on the same server.