ORACLE JAPAN Server Release 6.1

 

  |  

  WebLogic Server ホーム   |     JMX Service プログラマーズ ガイド   |   前へ   |   次へ   |   目次   |   索引   |   PDF 版

WebLogic Server MBean のモニタ

 

以下の節では、WebLogic Server MBean 属性をモニタする方法について概説します。

 


概要

WebLogic Server クライアントでは、モニタを設定して 1 つまたは複数の MBean 属性をモニタできます。JMX 仕様には、パッケージ javax.management.monitor のさまざまなタイプのモニタが定義されています。標準の JMX モニタは以下のとおりです。

JMX モニタは、多くの場合、特定の条件がモニタで満たされると、それを示すために、通知をブロードキャストします。このため、システムのモニタには通常、通知リスナや通知フィルタなど、標準の通知の構成概念が含まれており、それらはモニタに登録されています。

 


モニタの設定

ここでは、JMX 通知を受信するためのカウンタ モニタの設定方法の例を示します。この例でもモニタの通知を監視するのに通知リスナが使用されているので、情報の一部は「 MBean 通知の使い方」にある例から作成されています。

通知リスナの作成

この例ではまず、CounterListener という通知リスナが作成されています。この通知リスナは JMX モニタから送信される通知を受信します。

import java.rmi.Remote;

import javax.management.Notification;

import javax.management.monitor.MonitorNotification;

import weblogic.management.RemoteNotificationListener;

public class CounterListener implements RemoteNotificationListener {

String message;

public void handleNotification(Notification notification ,Object obj) {

System.out.println("\njavax.management.Notification");

System.out.println(" type = " +

notification.getType());

System.out.println(" sequenceNumber = " +

notification.getSequenceNumber());

System.out.println(" source = " +

notification.getSource());

System.out.println(" timestamp = " +

notification.getTimeStamp() + "\n");

if(notification instanceof MonitorNotification) {

MonitorNotification monitorNotification =

(MonitorNotification) notification;

System.out.println("\njavax.management.monitor.MonitorNotification");

System.out.println(" observed attr = " +

monitorNotification.getObservedAttribute() );

System.out.println(" observed obj =" +

monitorNotification.getObservedObject() );

System.out.println(" trigger value =" +

monitorNotification.getTrigger() + "\n");

message = "Mbean: " + monitorNotification.getObservedAttribute() +

"\n" +

"Attribute: " + monitorNotification.getObservedObject() +

"\n" +

"Trigger Value: " + monitorNotification.getTrigger();

}

}

}

リスナおよびモニタのインスタンス化

次の例のモニタ クラスでは、リスナおよびモニタ オブジェクトの両方がインスタンス化され、ServerSecurityRuntime.InvalidLoginAttemptsTotalCount 属性を監視するモニタが登録されています。この属性は、サーバへのログインの失敗数を示します。

無効なログインの試行回数がしきい値を超えた場合、通知リスナ CounterListener.handleNotification() によって handleNotification メソッドが呼び出されます。

モニタ コードの例は次のとおりです。

import java.rmi.RemoteException;

import java.util.Set;

import java.util.Iterator;

import javax.management.*;

import javax.management.AttributeChangeNotification;

import javax.management.AttributeChangeNotificationFilter;

import javax.management.monitor.CounterMonitor;

import javax.naming.*;

import weblogic.jndi.Environment;

import weblogic.management.*;

import weblogic.management.configuration.ServerMBean;

import weblogic.management.monitor.*;

import weblogic.management.runtime.ServerRuntimeMBean;

public class InvalidLoginMonitor {

public static void main (String args[]) {

// パスワードの引数があることを確認する

if (args.length != 3) {

System.out.println("Usage: java InvalidLoginMonitor " +

"<system password> " +

"<domain name> " +

"<server name>");

return;

}

String url = "t3://localhost:7001";

String username = "system";

String password = args[0];

MBeanHome home = null;

try {

Environment env = new Environment();

env.setProviderUrl(url);

env.setSecurityPrincipal(username);

env.setSecurityCredentials(password);

Context ctx = env.getInitialContext();

home = (MBeanHome) ctx.lookup(MBeanHome.ADMIN_JNDI_NAME);

System.out.println("Got the MBeanHome " + home);

RemoteMBeanServer rmbs = home.getMBeanServer();

CounterMonitor monitor = new CounterMonitor();

CounterListener listener = new CounterListener();

WebLogicObjectName monitorObjectName =

new WebLogicObjectName("MyCounter",

"CounterMonitor",

args[1],

args[2]);

WebLogicObjectName securityRtObjectName =

new WebLogicObjectName("myserver",

"ServerSecurityRuntime",

args[1],

args[2]);

Long t = new Long(2);

Long offset = new Long(0);

monitor.setThreshold((Number)t);

monitor.setNotify(true);

monitor.setOffset((Number)offset);

monitor.setObservedAttribute("InvalidLoginAttemptsTotalCount");

monitor.setObservedObject(securityRtObjectName);

monitor.addNotificationListener(listener, null, null);

monitor.preRegister(rmbs, monitorObjectName);

monitor.start();

} catch (Exception e) {

e.printStackTrace();

}

}

}

 


モニタ シナリオの例

この節では、パフォーマンスやリソース使用状況を監視するためにモニタする可能性のある、一部の典型的な MBean 属性について概説します。個々の MBean の属性またはメソッドに関する詳細については、適切な MBean の API ドキュメントを参照してください。

JDBC のモニタ

JDBCConnectionPoolRuntime MBean には、デプロイ済みの JDBC 接続プールへの接続状況を示すいくつかの属性があります。アプリケーションでは、これらの属性をモニタして、接続のリークだけでなく、接続の遅延および失敗を監視できます。次の表は、JDBC のモニタで通常使用される、これらの MBean 属性の概要を示しています。

JDBCConnectionPoolRuntime MBean の属性

アプリケーションによる一般的な
モニタ

LeakedConnectionCount

リークされた接続の総数があらかじめ指定されたしきい値に達すると、リスナに通知する。リークされた接続は、チェックアウト済みの接続だが、close() 呼び出しを通じて接続プールに返されない。リークされた接続はその後の接続要求の遂行に使用できないので、その総数をモニタすることは重要である。

ActiveConnectionsCurrentCount

指定された JDBC 接続プールに対する、現在のアクティブな接続数があらかじめ指定されたしきい値に達すると、リスナに通知する。

ConnectionDelayTime

接続プールに接続する平均時間があらかじめ指定されたしきい値を超えると、リスナに通知する。

FailuresToReconnect

接続プールがそのデータストアへの再接続に失敗すると、リスナに通知する。アプリケーションでは、この属性がインクリメントしたり、しきい値に達したりすると、許容できる中断時間のレベルに応じてリスナに通知できる。

 

back to top previous page