使用curl / API查看Wildfly中的各个部署状态

时间:2016-04-21 07:12:53

标签: jboss wildfly wildfly-10

我是Wildfly的新手,但我需要通过API设置个人部署状态的自动监控。

与使用curl查看服务器状态的方式相同,例如:

        from dateutil import relativedelta
        from datetime import  datetime
        datetime_fomat = '%Y-%m-%d %H:%M:%S'
        end="any  future date in string"##########
        current =datetime.now().replace(microsecond=0)
        end = datetime.strptime(str(end), datetime_fomat)
        diff = relativedelta.relativedelta(end, current)

        day=diff.days >=1 and diff.days or 0
        hour=diff.hours >=1 and diff.hours or 0
        minute=diff.minutes>=1 and diff.minutes or 0
        second=diff.seconds>=1 and diff.seconds or 0
        print "{day}days:{hour}hours:{minute}minutes: {second}seconds".format(day=day,hour=hour,minute=minute,second=second)

将返回:

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

以同样的方式来自jboss-cli,我发出:

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

得到相同的结果。

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

:read-attribute(name=server-state)

我得到以下结果:

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

但是我无法弄清楚curl命令会给我什么结果。我已经阅读了大量的文档,要么它不存在,要么我正在寻找错误的位置。我试过了:

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

但这不起作用。有什么想法吗?

谢谢, Mark J。

1 个答案:

答案 0 :(得分: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}