以下範例說明如何將 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 |
列出實體 Bean UserEJB (位於 PetStore 應用程式的 EJB 模組 signon-ejb_jar 中) 之 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 |