下例说明了如何将 asadmin 工具用于监视目的。
用户要检查将样例 PetStore 应用程序部署到 Application Server 之后在该应用程序中调用某个方法的次数。部署该应用程序的实例名称为 server。结合使用 list 和 get 命令即可访问所需的方法统计信息。
启动 Application Server 和 asadmin 工具。
设置一些有用的环境变量,以避免使用每个命令时都输入这些变量:
asadmin> export AS_ADMIN_USER=admin AS_ADMIN_PASSWORD=admin123 asadmin>export AS_ADMIN_HOST=localhost AS_ADMIN_PORT=4848 |
列出实例 server 的可监视组件:
asadmin> list --user adminuser --monitor server* |
返回结果(输出类似于以下内容):
server server.applications server.applications.CometEJB server.applications.ConverterApp server.applications.petstore server.http-service server.resources server.thread-pools |
可监视组件列表包括 thread-pools、http-service、resources 以及所有已部署(并已启用)的 applications。
列出 PetStore 应用程序中的可监视子组件(可以用 -m 代替 --monitor):
asadmin> list -m server.applications.petstore
返回:
server.applications.petstore.signon-ejb_jar server.applications.petstore.catalog-ejb_jar server.applications.petstore.uidgen-ejb_jar server.applications.petstore.customer-ejb_jar server.applications.petstore.petstore-ejb_jar server.applications.petstore.petstore\.war server.applications.petstore.AsyncSenderJAR_jar server.applications.petstore.cart-ejb_jar |
列出 PetStore 应用程序的 EJB 模块 signon-ejb_jar 中的可监视子组件:
asadmin> list -m server.applications.petstore.signon-ejb_jar |
返回:
server.applications.petstore.signon-ejb_jar.SignOnEJB server.applications.petstore.signon-ejb_jar.UserEJB |
列出 PetStore 应用程序的 EJB 模块 signon-ejb_jar 的实体 Bean UserEJB 中的可监视子组件:
asadmin> list -m server.applications.petstore.signon-ejb_jar.UserEJB |
返回(出于空间考虑,删除了带点的名称):
server.applications.petstore.signon-ejb_jar.UserEJB.bean-cache server.applications.petstore.signon-ejb_jar.UserEJB.bean-methods server.applications.petstore.signon-ejb_jar.UserEJB.bean-pool |
列出 PetStore 应用程序的 EJB 模块 signon-ejb_jar 的实体 Bean UserEJB 所用方法 getUserName 中的可监视子组件:
asadmin> list -m server.applications.petstore.signon-ejb_jar.UserEJB.bean-methods.getUserName |
返回:
Nothing to list at server.applications.petstore.signon-ejb_jar. UserEJB.bean-methods.getUserName. To get the valid names beginning with a string, use the wildcard "*" character. For example, to list all names that begin with "server", use "list server*". |
该方法没有可监视的子组件。获取方法 getUserName 的所有可监视统计信息。
asadmin> get -m server.applications.petstore.signon-ejb_jar.UserEJB.bean-methods.getUserName.* |
返回:
server.applications.petstore.signon-ejb_jar.UserEJB.bean-methods. getUserName.executiontime-count = 0 server.applications.petstore.signon-ejb_jar.UserEJB.bean-methods. getUserName.executiontime-description = Provides the time in milliseconds spent during the last successful/unsuccessful attempt to execute the operation. server.applications.petstore.signon-ejb_jar.UserEJB.bean-methods. getUserName.executiontime-lastsampletime = 1079981809259 server.applications.petstore.signon-ejb_jar.UserEJB.bean-methods. getUserName.executiontime-name = ExecutionTime server.applications.petstore.signon-ejb_jar.UserEJB.bean-methods. getUserName.executiontime-starttime = 1079980593137 server.applications.petstore.signon-ejb_jar.UserEJB.bean-methods. getUserName.executiontime-unit = count server.applications.petstore.signon-ejb_jar.UserEJB.bean-methods. getUserName.methodstatistic-count = 0 server.applications.petstore.signon-ejb_jar.UserEJB.bean-methods. getUserName.methodstatistic-description = Provides the number of times an operation was called, the total time that was spent during the invocation and so on. server.applications.petstore.signon-ejb_jar.UserEJB.bean-methods. getUserName.methodstatistic-lastsampletime = 1079980593137 server.applications.petstore.signon-ejb_jar.UserEJB.bean-methods. getUserName.methodstatistic-maxtime = 0 server.applications.petstore.signon-ejb_jar.UserEJB.bean-methods. getUserName.methodstatistic-mintime = 0 server.applications.petstore.signon-ejb_jar.UserEJB.bean-methods. getUserName.methodstatistic-name = ExecutionTime server.applications.petstore.signon-ejb_jar.UserEJB.bean-methods. getUserName.methodstatistic-starttime = 1079980593137 server.applications.petstore.signon-ejb_jar.UserEJB.bean-methods. getUserName.methodstatistic-totaltime = 0 server.applications.petstore.signon-ejb_jar.UserEJB.bean-methods. getUserName.methodstatistic-unit = server.applications.petstore.signon-ejb_jar.UserEJB.bean-methods. getUserName.totalnumerrors-count = 0 server.applications.petstore.signon-ejb_jar.UserEJB.bean-methods. getUserName.totalnumerrors-description = Provides the total number of errors that occured during invocation or execution of an operation. server.applications.petstore.signon-ejb_jar.UserEJB.bean-methods. getUserName.totalnumerrors-lastsampletime = 1079981809273 server.applications.petstore.signon-ejb_jar.UserEJB.bean-methods. getUserName.totalnumerrors-name = TotalNumErrors server.applications.petstore.signon-ejb_jar.UserEJB.bean-methods. getUserName.totalnumerrors-starttime = 1079980593137 server.applications.petstore.signon-ejb_jar.UserEJB.bean-methods. getUserName.totalnumerrors-unit = count server.applications.petstore.signon-ejb_jar.UserEJB.bean-methods. getUserName.totalnumsuccess-count = 0 server.applications.petstore.signon-ejb_jar.UserEJB.bean-methods. getUserName.totalnumsuccess-description = Provides the total number of successful invocations of the method. server.applications.petstore.signon-ejb_jar.UserEJB.bean-methods. getUserName.totalnumsuccess-lastsampletime = 1079981809255 server.applications.petstore.signon-ejb_jar.UserEJB.bean-methods. getUserName.totalnumsuccess-name = TotalNumSuccess server.applications.petstore.signon-ejb_jar.UserEJB.bean-methods. getUserName.totalnumsuccess-starttime = 1079980593137 server.applications.petstore.signon-ejb_jar.UserEJB.bean-methods. getUserName.totalnumsuccess-unit = count |
如果还需要获取执行时间等特定统计信息,请使用如下命令:
asadmin> get -m server.applications.petstore.signon-ejb_jar. UserEJB.bean-methods.getUserName.executiontime-count |
返回:
server.applications.petstore.signon-ejb_jar.UserEJB.bean-methods. getUserName.executiontime-count = 1 |