Sun Java System Application Server Enterprise Edition 8.2 管理指南

PetStore 使用示例

下例说明了如何将 asadmin 工具用于监视目的。

用户要检查将样例 PetStore 应用程序部署到 Application Server 之后在该应用程序中调用某个方法的次数。部署该应用程序的实例名称为 server。结合使用 listget 命令即可访问所需的方法统计信息。

  1. 启动 Application Server 和 asadmin 工具。

  2. 设置一些有用的环境变量,以避免使用每个命令时都输入这些变量:


    asadmin> export AS_ADMIN_USER=admin AS_ADMIN_PASSWORD=admin123
    asadmin>export AS_ADMIN_HOST=localhost AS_ADMIN_PORT=4849
  3. 列出实例 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-poolshttp-serviceresources 以及所有已部署(并已启用)的 applications

  4. 列出 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
  5. 列出 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
  6. 列出 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
  7. 列出 PetStore 应用程序的 EJB 模块 signon-ejb_jar 的实体 Bean UserEJB 所用方法 getUserName 中的可监视子组件:


    asadmin> list -m 
    server.applications.petstore.signon-ejb_jar.UserEJB.bean-methods.getUserName

    返回:


    在 server.applications.petstore.signon-ejb_jar.UserEJB.bean-methods.getUserName 没有内容可以列出。要获得以某个字符串开头的有效名称,请使用通配符 "*" 字符。例如,要列出以 "server" 开头的所有名称,请使用 "list server*"。
  8. 该方法没有可监视的子组件。获取方法 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
  9. 如果还需要获取执行时间等特定统计信息,请使用如下命令:


    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