WebSphere Application Server, Version 6.0.x   
             オペレーティング・システム: AIX , HP-UX, Linux, Solaris, Windows

             目次と検索結果のパーソナライズ化

JMX インターフェースを使用した、独自のモニター・アプリケーションの開発

AdminClient API を使用して、PerfMBean または各 MBean を用いて Performance Monitoring Infrastructure (PMI) データを取得することができます。

始める前に

AdminClient Java Management Extension (JMX) インターフェースを使用して、MBeans でメソッドを 呼び出すことができます。 AdminClient API を使用して、PerfMBean または各 MBean を用いて Performance Monitoring Infrastructure (PMI) データを取得することができます。 各 MBean の使用に関する情報については、この項目の最後を ご覧ください。

個々の MBean には、PMI データを取得するための Stats 属性があります。 PerfMBean は、PMI 管理用の拡張メソッドと、PMI データにアクセスするためのより効果的な方法を提供します。 PMI モジュールのインスツルメンテーション・レベルを設定するには、PerfMBean でメソッドを呼び出す必要があります。 複数の MBean から PMI データを照会するには、 複数の個々の MBean から Stats 属性を取得するよりも、PerfMBean で getStatsArray メソッドを呼び出す方が高速です。Perf MBean は、 単一の JMX 呼び出しを使用して複数の MBeans から PMI データを提供することができますが、複数の JMX 呼び出しは、 個々の MBean を介して作成する必要があります。

AdminClient JMX について詳しくは、トピック『管理クライアント・プログラムの開発』を参照してください。

このタスクについて

パフォーマンス・モニター・サービスが使用可能で、 アプリケーション・サーバーが始動または再始動されると、 アプリケーション・サーバーごとに PerfMBean が配置され、PMI データへのアクセスを提供します。 PerfMBean を使用するには、以下のステップに従ってください。

プロシージャー

  1. AdminClient のインスタンスを作成します。 AdminClient API を使用する場合は、最初にホスト名、ポート番号、コネクター・タイプを渡して、 AdminClient のインスタンスを作成する必要があります。
    サンプル・コードは以下のとおりです。
            AdminClient ac = null;
            java.util.Properties props = new java.util.Properties();
            props.put(AdminClient.CONNECTOR_TYPE, connector);
            props.put(AdminClient.CONNECTOR_HOST, host);
            props.put(AdminClient.CONNECTOR_PORT, port);
            try {
                ac = AdminClientFactory.createAdminClient(props);
            }
            catch(Exception ex) {
                failed = true;
                new AdminException(ex).printStackTrace();
                System.out.println("getAdminClient: exception");
            }
    
  2. AdminClient を使用して、MBean ObjectName を照会します。 AdminClient のインスタンスを取得したら、queryNames を呼び出して 照会ストリングに応じた MBean ObjectName のリストを取得します。すべての ObjectName を取得する場合は、以下のサンプル・コードを使用できます。 照会ストリングを指定する場合は、ObjectName のサブセットを取得します。
    		javax.management.ObjectName on = new javax.management.ObjectName("WebSphere:*");
         Set objectNameSet= ac.queryNames(on, null);
    	// you can check properties like type, name, and process to find a specified ObjectName	    
    すべての ObjectName を取得した後は、以下のサンプル・コードを使用してすべてのノード名を取得できます。
    		HashSet nodeSet = new HashSet();
           	for(Iterator i = objectNameSet.iterator(); i.hasNext(); on = (ObjectName)i.next()) {
    String type = on.getKeyProperty("type");
                if(type != null && type.equals("Server")) {
    		nodeSet.add(servers[i].getKeyProperty("node"));
                }
    	}
    	
    : これは、始動済みのノードだけを戻します。 ノードで稼働しているサーバーをリストするには、 すべての ObjectName のノード名とタイプを検査するか、 以下のサンプル・コードを使用してください。
         StringBuffer oNameQuery= new StringBuffer(41);
            oNameQuery.append("WebSphere:*");
            oNameQuery.append(",type=").append("Server");
            oNameQuery.append(",node=").append(mynode);
    
            oSet= ac.queryNames(new ObjectName(oNameQuery.toString()), null);
           	Iterator i = objectNameSet.iterator ();
    				while (i.hasNext ()) {
    				on=(objectName) i.next();
    		String process= on[i].getKeyProperty("process");
    		serversArrayList.add(process);
    		}
    	
  3. PMI データの取得元であるアプリケーション・サーバーの PerfMBean ObjectName を取得します。 以下のサンプル・コードを使用します。
    		for(Iterator i = objectNameSet.iterator(); i.hasNext(); on = (ObjectName)i.next()) {
    	    // First make sure the node name and server name is what you want
    	    // Second, check if the type is Perf
                String type = on.getKeyProperty("type");
    	    String node = on.getKeyProperty("node");
    	    String process= on.getKeyProperty("process");
                if (type.equals("Perf") && node.equals(mynode) &
    & server.equals(myserver)) {
    		perfOName = on;
                }
    	}
  4. AdminClient を使用して PerfMBean にオペレーションを呼び出してください。 PMI データの取得元となるアプリケーション・サーバーの PerfMBean を取得したら、 AdminClient API を通じて PerfMBean に以下のオペレーションを呼び出すことができます。
     - setStatisticSet: 事前定義済み統計セットを使用した PMI データを使用可能にします。
    	Object[] params = new Object[] { com.ibm.websphere.pmi.stat.StatConstants.STATISTIC_SET_EXTENDED};
    	String[] signature = new String[] {"java.lang.String"};
    	ac.invoke (perfOName, "setStatisticSet", params, signature);
    
     - getStatisticSet: 現行の統計セットを戻します。
    	String setname = (String) ac.invoke (perfOName, "getStatisticSet", null, null);
    
     - setCustomSetString: 細分化された制御を使用できるように、PMI データをカスタマイズします。
    このメソッドによって、統計の使用可能または使用不可を選択できます。カスタム・セット仕様ストリングのフォーマットは、
    「:」で区切られた STATS_NAME=ID1,ID2,ID3 です。ここで、STATS_NAME および ID は、
    com.ibm.websphere.pmi.stat パッケージの WS*Stat インターフェースで定義されます。	params[0] = new String (WSJVMStats.NAME + "=" + WSJVMStats.HeapSize);
    	params[1] = new Boolean (false);
    	signature = new String[] {"java.lang.String", "java.lang.Boolean"};
    	ac.invoke (perfOName, "setCustomSetString", params, signature);
    
      注: セット・ストリングにリストされていない統計は変更されません。
     
     - getCustomSetString: ストリングとして現行のカスタム・セット仕様を戻します。
    	String setstring = (String) ac.invoke (perfOName, "getCustomSetString", null, null);
    
    
     - setInstrumentationLevel: 計測レベルの設定
                params[0] = new MBeanLevelSpec(objectName, new int[]{WSJVMStats.HEAPSIZE});
                params[1] = new Boolean(true);
                signature= new String[]{ "com.ibm.websphere.pmi.stat.MBeanLevelSpec", "java.lang.Boolean"};
    ac.invoke(perfOName, "setInstrumentationLevel", params, signature);
    
    - getInstrumentationLevel: 計測レベルの取得
                params[0] = objectName;
                params[1] = new Boolean(recursive);
                String[] signature = new String[] { "javax.management.ObjectName", "java.lang.Boolean"};
    MBeanLevelSpec[] mlss = (MBeanLevelSpec[])ac.invoke(perfOName, "getInstrumentationLevel", params, signature);
     - setInstrumentationLevel: 計測レベルの設定 (V6.0 では推奨されません)
                params[0] = new MBeanLevelSpec(objectName, optionalSD, level);
                params[1] = new Boolean(true);
                signature= new String[]{ "com.ibm.websphere.pmi.stat.MBeanLevelSpec", "java.lang.Boolean"};
    ac.invoke(perfOName, "setInstrumentationLevel", params, signature);
    
     - getInstrumentationLevel: 計測レベルの取得 (V6.0 では推奨されません)
                Object[] params    = new Object[2];
                params[0] = new MBeanStatDescriptor(objectName, optionalSD);
                params[1] = new Boolean(recursive);
                String[] signature= new String[]{ "com.ibm.websphere.pmi.stat.MBeanStatDescriptor", "java.lang.Boolean"};
    MBeanLevelSpec[] mlss = (MBeanLevelSpec[])ac.invoke(perfOName, "getInstrumentationLevel", params, signature);
    - getConfigs: すべての MBean に PMI 静的構成情報を指定
                configs = (PmiModuleConfig[])ac.invoke(perfOName, "getConfigs", null, null);
    
    - getConfig: 特定の MBean に PMI 静的構成情報を指定
    	    ObjectName[] params = {objectName};
    	    String[] signature= { "javax.management.ObjectName" };
                config = (PmiModuleConfig)ac.invoke(perfOName, "getConfig", params, signature);
    - getStatsObject: ObjectName または MBeanStatDescriptor を使用
                Object[] params    = new Object[2];
                params[0] = objectName;  // either ObjectName or or MBeanStatDescriptor
                params[1] = new Boolean(recursive);
                String[] signature = new String[] { "javax.management.ObjectName", "java.lang.Boolean"};
    Stats stats  = (Stats)ac.invoke(perfOName, "getStatsObject", params, signature);
    注: 戻されるデータは動的情報 (値とタイム・スタンプ) のみです。
    構成情報と戻されるデータをリンクさせる追加コードについては
    PmiJmxTest.java を参照してください。
    - getStatsArray: ObjectName または MBeanStatDescriptor を使用
                ObjectName[] onames = new ObjectName[]{objectName1, objectName2};
                Object[] params = new Object[]{onames, new Boolean(true)};
                String[] signature = new String[]{"[Ljavax.management.ObjectName;", "java.lang.Boolean"};
    Stats[] statsArray = (Stats[])ac.invoke(perfOName, "getStatsArray", params, signature);
    注: 戻されるデータは動的情報 (値とタイム・スタンプ) のみです。
    構成情報と戻されるデータをリンクさせる追加コードについては
    PmiJmxTest.java を参照してください。
    - listStatMembers: PMI モジュール・ツリーをナビゲート
    
                Object[] params = new Object[]{mName};
                String[] signature= new String[]{"javax.management.ObjectName"};
                MBeanStatDescriptor[] msds = (MBeanStatDescriptor[])ac.invoke(perfOName, "listStatMembers", params, signature);
    または、
                Object[] params = new Object[]{mbeanSD};
                String[] signature= new String[]{"com.ibm.websphere.pmi.stat.MBeanStatDescriptor"};
    MBeanStatDescriptor[] msds = (MBeanStatDescriptor[])ac.invoke
    (perfOName, "listStatMembers", params, signature);
    
    非推奨クラスについては API 文書を参照してください。
    
    注: PMI データを取得するために呼び出しを繰り返すと、参照が同じオブジェクトに 戻される場合があります。時間経過に応じて値を比較する場合、 データが含まれる PMI オブジェクトへの参照ではなく、実際のデータを保管する 必要があります。例えば、WSCountStatistic オブジェクトがある場合、getCount() を 呼び出し、そのオブジェクトへの参照を保管する代わりに、後の比較の結果を 保管します。
    • 各 MBean の使用: AdminClient インスタンスと 各 MBean 向けの ObjectName を取得する必要があります。 これにより、容易に MBean 上で Stats 属性を取得することができます。



サブトピック
例: Java Management Extension ベースのインターフェースの管理
関連タスク
管理クライアント・プログラムの開発
タスク・トピック    

ご利用条件 | フィードバック

最終更新: Jan 22, 2008 12:07:38 AM EST
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r0/index.jsp?topic=/com.ibm.websphere.base.doc/info/aes/ae/tprf_pmijmx.html