3.6.6. 用管理 CLI 显示可用资源
必须具备的条件
概述
read-resource
操作是用来读取资源值的全局操作。它可以用来开放当前节点或子节点额资源的基本或完整的信息,以及扩展或限制操作结果的作用域的请求属性。请求属性包含下列参数。
请求属性
recursive
- 是否递归地包含子资源的完整信息。
recursive-depth
- 应该包含子节点资源信息的深度。
proxies
- 是否在递归查询里包含远程资源。例如,包含域控制器查询里从主机控制器的主机级别资源。
include-runtime
- 是否在响应里包含 runtime 属性,如不是来自持久性配置的属性值。这个请求属性默认是 false。
include-defaults
- 这是一个 boolean 型的请求属性,它启用或禁用默认属性的读取。当设置为 false 时,只返回用户设置的属性,忽略了那些未定义的属性。
过程 3.18. 在管理 CLI 里执行命令
运行
read-resource
操作在管理 CLI 里,请用read-resource
操作来显示可用的资源。[standalone@localhost:9999 /]
:read-resource
下面的例子展示了在独立服务器里如何使用read-resource
操作来开放普通资源信息。结果类似于standalone.xml
配置文件,显示系统资源、扩展、接口和为服务器实例安装和配置的子系统。它们可以进一步进行直接查询。例 3.11. 在根级别使用
read-resource
操作[standalone@localhost:9999 /]:read-resource { "outcome" => "success", "result" => { "deployment" => undefined, "deployment-overlay" => undefined, "management-major-version" => 1, "management-micro-version" => 0, "management-minor-version" => 4, "name" => "longgrass", "namespaces" => [], "product-name" => "EAP", "product-version" => "6.3.0.GA", "release-codename" => "Janus", "release-version" => "7.2.0.Final-redhat-3", "schema-locations" => [], "system-property" => undefined, "core-service" => { "management" => undefined, "service-container" => undefined, "server-environment" => undefined, "platform-mbean" => undefined }, "extension" => { "org.jboss.as.clustering.infinispan" => undefined, "org.jboss.as.connector" => undefined, "org.jboss.as.deployment-scanner" => undefined, "org.jboss.as.ee" => undefined, "org.jboss.as.ejb3" => undefined, "org.jboss.as.jaxrs" => undefined, "org.jboss.as.jdr" => undefined, "org.jboss.as.jmx" => undefined, "org.jboss.as.jpa" => undefined, "org.jboss.as.jsf" => undefined, "org.jboss.as.logging" => undefined, "org.jboss.as.mail" => undefined, "org.jboss.as.naming" => undefined, "org.jboss.as.pojo" => undefined, "org.jboss.as.remoting" => undefined, "org.jboss.as.sar" => undefined, "org.jboss.as.security" => undefined, "org.jboss.as.threads" => undefined, "org.jboss.as.transactions" => undefined, "org.jboss.as.web" => undefined, "org.jboss.as.webservices" => undefined, "org.jboss.as.weld" => undefined }, "interface" => { "management" => undefined, "public" => undefined, "unsecure" => undefined }, "path" => { "jboss.server.temp.dir" => undefined, "user.home" => undefined, "jboss.server.base.dir" => undefined, "java.home" => undefined, "user.dir" => undefined, "jboss.server.data.dir" => undefined, "jboss.home.dir" => undefined, "jboss.server.log.dir" => undefined, "jboss.server.config.dir" => undefined, "jboss.controller.temp.dir" => undefined }, "socket-binding-group" => {"standard-sockets" => undefined}, "subsystem" => { "logging" => undefined, "datasources" => undefined, "deployment-scanner" => undefined, "ee" => undefined, "ejb3" => undefined, "infinispan" => undefined, "jaxrs" => undefined, "jca" => undefined, "jdr" => undefined, "jmx" => undefined, "jpa" => undefined, "jsf" => undefined, "mail" => undefined, "naming" => undefined, "pojo" => undefined, "remoting" => undefined, "resource-adapters" => undefined, "sar" => undefined, "security" => undefined, "threads" => undefined, "transactions" => undefined, "web" => undefined, "webservices" => undefined, "weld" => undefined } } }
针对子节点运行
read-resource
操作read-resource
操作可以查询根节点的子节点。操作的结构首先定义要开放的节点,然后附加这个操作来运行。[standalone@localhost:9999 /]
/subsystem=web/connector=http:read-resource
在下面的例子里,通过指引read-resource
操作到专有的 Web 子系统节点来开放 Web 子系统组件的专有资源信息。例 3.12. 开放根结点的子节点资源
[standalone@localhost:9999 /] /subsystem=web/connector=http:read-resource { "outcome" => "success", "result" => { "configuration" => undefined, "enable-lookups" => false, "enabled" => true, "executor" => undefined, "max-connections" => undefined, "max-post-size" => 2097152, "max-save-post-size" => 4096, "name" => "http", "protocol" => "HTTP/1.1", "proxy-name" => undefined, "proxy-port" => undefined, "redirect-port" => 443, "scheme" => "http", "secure" => false, "socket-binding" => "http", "ssl" => undefined, "virtual-server" => undefined } }
相同的结果可以用cd
命令进入子节点并直接运行read-resource
操作获得。例 3.13. 通过修改目录开放子节点资源
[standalone@localhost:9999 /] cd subsystem=web
[standalone@localhost:9999 subsystem=web] cd connector=http
[standalone@localhost:9999 connector=http] :read-resource { "outcome" => "success", "result" => { "configuration" => undefined, "enable-lookups" => false, "enabled" => true, "executor" => undefined, "max-connections" => undefined, "max-post-size" => 2097152, "max-save-post-size" => 4096, "name" => "http", "protocol" => "HTTP/1.1", "proxy-name" => undefined, "proxy-port" => undefined, "redirect-port" => 443, "scheme" => "http", "secure" => false, "socket-binding" => "http", "ssl" => undefined, "virtual-server" => undefined } }
使用 recursive 参数在结果里包含活动的属性值。
recursive 参数可以用来开放所有属性的值,包括非持久性的值、在启动时传入的值或其他在 runtime 模型里活动的属性。[standalone@localhost:9999 /]
/interface=public:read-resource(include-runtime=true)
和之前的例子相比,include-runtime
请求属性会开放其他的活动属性,如发送的字节和 HTTP 连接器接收的字节。例 3.14. 用
include-runtime
参数开放其他活动的属性值。[standalone@localhost:9999 /] /subsystem=web/connector=http:read-resource(include-runtime=true) { "outcome" => "success", "result" => { "any" => undefined, "any-address" => undefined, "any-ipv4-address" => undefined, "any-ipv6-address" => undefined, "inet-address" => expression "${jboss.bind.address:127.0.0.1}", "link-local-address" => undefined, "loopback" => undefined, "loopback-address" => undefined, "multicast" => undefined, "name" => "public", "nic" => undefined, "nic-match" => undefined, "not" => undefined, "point-to-point" => undefined, "public-address" => undefined, "resolved-address" => "127.0.0.1", "site-local-address" => undefined, "subnet-match" => undefined, "up" => undefined, "virtual" => undefined } }