0

我对 Wildfly 很陌生,但我需要通过 API 设置对单个部署状态的自动监控。

就像我可以用 curl 查看服务器状态一样,例如:

curl --insecure --digest 'https://admin:password@localhost:9993/management' --header "Content-Type: application/json" -d '{"operation":"read-attribute","name":"server-state","json.pretty":1}'

将返回:

{
    "outcome" => "success",
    "result" => "running"
}

以与 jboss-cli 相同的方式,我发出:

:read-attribute(name=server-state)

并得到相同的结果。

因此,如果我从 CLI 发出以下命令来获取特定部署的状态:

/deployment=bob :read-attribute(name=status)

我得到以下结果:

{
    "outcome" => "success",
    "result" => "OK"
}

但我不知道 curl 命令会给我什么结果。我已经阅读了大量的文档,要么它不存在,要么我找错了地方。我试过了:

curl --insecure --digest 'https://password@localhost:9993/management' --header "Content-Type: application/json" -d '{"deployment":"bob","operation":"read-attribute","name":"status","json.pretty":1}'

但这没有用。有任何想法吗?

谢谢,马克J。

4

1 回答 1

0

您需要为address属性添加一个数组并"deployment":"bob"在数组中移动。

curl --insecure --digest 'https://password@localhost:9993/management' --header "Content-Type: application/json" -d '{"operation":"read-attribute", "address":[{"deployment":"bob"}],"name":"status","json.pretty":1}'

地址是您要读取的属性的路径的名称/值对对象。例如,如果您想查看与根记录器关联的所有处理程序,您可以执行以下操作。

curl --insecure --digest 'https://password@localhost:9993/management' --header "Content-Type: application/json" -d '{"operation":"read-attribute","address":[{"subsystem":"logging"},{"root-logger":"ROOT"}],"name":"handlers","json.pretty":1}
于 2016-04-23T00:27:04.757 回答