| Oracle® Fusion Middleware Oracle WebLogic Server診断フレームワークの構成と使い方 11g リリース1 (10.3.4) B60994-02 |
|
![]() 前 |
![]() 次 |
WebLogic診断フレームワーク(WLDF)のデータ・アクセサ・コンポーネントを使用すると、ログ・レコード、データ・イベント、収集されたメトリックなどの様々なソースからの診断データにアクセスできます。
データ・アクセサを使用すると、型、コンポーネント、属性を基準としてデータをルックアップできます。時間ベースのフィルタ処理を実行でき、イベントにアクセスする際には重大度、ソース、コンテンツを基準としたフィルタ処理が可能です。また、表形式の診断データにアクセスすることもできます。
次の項では、データ・アクセサについて説明し、オンライン(サーバーが実行中の状態)およびオフライン(サーバーが実行中でない状態)でデータ・アクセサを使用する方法について示します。
データ・アクセサでは、他のWLDFコンポーネントから診断情報を取得します。キャプチャされた情報は、診断データの種類別に分かれた複数の論理データ・ストア内に分類されます。たとえば、サーバー・ログ、HTTPログ、収集されたメトリックは、それぞれ別のデータ・ストアにキャプチャされます。
WLDFでは、診断データがサーバー単位で管理されます。そのため、データ・アクセサでは個々のサーバーのデータ・ストアにアクセスできます。
データ・ストアは表形式を取ることがあります。表の各レコードが1つの項目を表し、その項目の特性が複数の列で説明されます。様々なデータ・ストアに多様な列がありますが。データ項目が収集された時間などほとんどのデータ・ストアで共有される列もあります。
データ・アクセサでは、サーバーのWLDFで使用されるデータ・ストアについて以下のような情報を取得できます。
サポートされるデータ・ストアのタイプのリスト。以下のようなものがあります。
HTTP_LOG
HARVESTED_DATA_ARCHIVE
EVENTS_DATA_ARCHIVE
SERVER_LOG
DOMAIN_LOG
HTTP_ACCESS_LOG
WEBAPP_LOG
CONNECTOR_LOG
JMS_MESSAGE_LOG
CUSTOM_LOG
利用可能なデータ・ストアのインスタンスのリスト。
各データ・ストアのレイアウト(データ・ストアの列が記述された情報)
WLDFAccessRuntimeMBeanを使用すると、このようなデータ・ストアを検索したり、データ・ストアにあるデータの性質を判断したりできます。また、問合せを使用してそうしたデータに選択的にアクセスすることもできます。
WebLogicログの詳細は、『Oracle WebLogic Serverログ・ファイルの構成とログ・メッセージのフィルタ処理』を参照してください。
実行中のサーバーの診断データには、管理コンソール、JMX API群、またはWebLogic Scripting Tool (WLST)を使用してアクセスします。
管理コンソールでは、明示的にデータ・アクセサを使用しません。ただし、アクセサで収集された情報は管理コンソールに表示されます。たとえば、「ログ・ファイルのサマリー」ページがそれに該当します。Oracle WebLogic Server管理コンソール・ヘルプのログの表示と構成に関する項を参照してください。
データ・アクセサには、データ・ストアの検索とデータ・ストアからのデータ取得のために以下のランタイムMBeanが用意されています。
以下の処理にはWLDFAccessRuntimeMBeanを使用します。
サーバー上の利用可能なデータ・ストアの論理名を取得します。
特定のデータ・ソースのデータにアクセスするために、論理名を基にWLDFDataAccessRuntimeMBeanをルックアップします。様々なデータ・ストアは、各自の論理名によって一意に識別されます。
Oracle WebLogic Server MBeanリファレンスのWLDFAccessRuntimeMBeanに関する項を参照してください。
検索条件または問合せに基づいてデータ・ストアを取得するには、WLDFDataAccessRuntimeMBeanを使用します。問合せには任意で時間間隔を指定して、特定の時間内にデータ・レコードを取得するようにできます。このMBeanには、データ・セットの複数の列、およびデータ・ストア内のレコード群の最古と最新のタイムスタンプに関するメタデータが備わっています。
現在、データ・アクセサのランタイムMBeanが作成されて登録されるまでには時間がかかります。そのため、このようなMBeanにリモート・クライアントからアクセスしようとすると、MBeanが存在せずにInstanceNotFoundExceptionがスローされることがあります。
クライアントでは、WLDFAccessRuntimeのWLDFDataAccessRuntimes属性を取得して、認識されているすべてのデータ・アクセス・ランタイムMBeanを作成するようにできます。。例:
ObjectName objName =
new ObjectName("com.bea:ServerRuntime=" + serverName +
",Name=Accessor," +
"Type=WLDFAccessRuntime," +
"WLDFRuntime=WLDFRuntime");
rmbs.getAttribute(objName, "WLDFDataAccessRuntimes");
Oracle WebLogic Server MBeanリファレンスのWLDFDataAccessRuntimeMBeanに関する項を参照してください。
WLSTのexportDiagnosticDataFromServerコマンドを使用すると、実行中のサーバーの診断データにアクセスできます。このコマンドの構文とサンプルは、『WebLogic Scripting Toolコマンド・リファレンス』の診断コマンドに関する項を参照してください。
データ・ストアのデータを問い合わせるには、WLDF問合せ言語を使用します。データ・アクセサの問合せ言語の構文の詳細は、付録A「WLDF問合せ言語」を参照してください。
WLSTのexportDiagnosticDataコマンドを使用すると、オフライン状態にあるサーバーの診断データの履歴にアクセスできます。このコマンドの構文とサンプルは、『WebLogic Scripting Toolコマンド・リファレンス』の診断コマンドに関する項を参照してください。
|
注意: データが固持されるマシンだけから格納されたデータにアクセスするのにexportDiagnosticDataを使用できます。データ・アクセサのオフライン・モードでは、データ・ストア・インスタンスの検索はできません。インスタンスについてはあらかじめ認識しておく必要があります。 |
例13-1では、アクセサを使用して様々なアーカイブ・データ・ストアに問い合せるユーティリティのJavaソース・コードを示します。
例13-1 WLDFアクセサを使用するサンプル・コード
/*
* WLAccessor.java
*
* Demonstration utility that allows query of the different ARCV data stores
* via the WLDF Accessor.
*
*/
import javax.naming.Context;
import weblogic.jndi.Environment;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Properties;
import weblogic.management.ManagementException;
import weblogic.management.runtime.WLDFAccessRuntimeMBean;
import weblogic.management.runtime.WLDFDataAccessRuntimeMBean;
import weblogic.diagnostics.accessor.ColumnInfo;
import weblogic.diagnostics.accessor.DataRecord;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import javax.management.MBeanServerConnection;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
import javax.management.ObjectName;
import weblogic.management.mbeanservers.runtime.RuntimeServiceMBean;
import weblogic.management.runtime.ServerRuntimeMBean;
import weblogic.management.jmx.MBeanServerInvocationHandler;
import weblogic.management.configuration.ServerMBean;
/**
* Demonstration utility that allows query of the different ARCV data stores
* via the WLDF Accessor. The class looks up the appropriate accessor and
* executes the query given the specified query parameters.
*
* To see information about it's usage, compile this file and run
*
* java WLAccessor usage
*/
public class WLAccessor {
/** Creates a new instance of WLAccessor */
public WLAccessor(Properties p) {
initialize(p);
}
/**
* Retrieve the specfied WLDFDataAccessRuntimeMBean instance for querying.
*/
public WLDFDataAccessRuntimeMBean getAccessor(String accessorType)
throws Throwable
{
// Get the runtime MBeanServerConnection
MBeanServerConnection runtimeMBS = this.getRuntimeMBeanServerConnection();
// Lookup the runtime service for the connected server
ObjectName rtSvcObjName = new ObjectName(RuntimeServiceMBean.OBJECT_NAME);
RuntimeServiceMBean rtService = null;
rtService = (RuntimeServiceMBean)
MBeanServerInvocationHandler.newProxyInstance(
runtimeMBS, rtSvcObjName
);
// Walk the Runtime tree to the desired accessor instance.
ServerRuntimeMBean srt = rtService.getServerRuntime();
WLDFDataAccessRuntimeMBean ddar =
srt.getWLDFRuntime().getWLDFAccessRuntime().
lookupWLDFDataAccessRuntime(accessorType);
return ddar;
}
/**
* Execute the query using the given parameters, and display the formatted
* records.
*/
public void queryEventData() throws Throwable
{
String logicalName = "EventsDataArchive";
WLDFDataAccessRuntimeMBean accessor = getAccessor(accessorType);
ColumnInfo[] colinfo = accessor.getColumns();
inform("Query string: " + queryString);
int recordsFound = 0;
Iterator actualIt =
accessor.retrieveDataRecords(beginTime, endTime, queryString);
while (actualIt.hasNext()) {
DataRecord rec = (DataRecord)actualIt.next();
inform("Record[" + recordsFound + "]: {");
Object[] values = rec.getValues();
for (int colno=0; colno < values.length; colno++) {
inform("[" + colno + "] "
+ colinfo[colno].getColumnName() +
" (" + colinfo[colno].getColumnTypeName() + "): " +
values[colno]);
}
inform("}");
inform("");
recordsFound++;
}
inform("Found " + recordsFound + " results");
}
/**
* Main method that implements the tool.
* @param args the command line arguments
*/
public static void main(String[] args) {
try {
WLAccessor acsr = new WLAccessor(handleArgs(args));
acsr.queryEventData();
} catch (UsageException uex) {
usage();
} catch (Throwable t) {
inform("Caught exception, " + t.getMessage(), t);
inform("");
usage();
}
}
public static class UsageException extends Exception {}
/**
* Process the command line arguments, which are provided as name/value pairs.
*/
public static Properties handleArgs(String[] args) throws Exception
{
Properties p = checkForDefaults();
for (int i = 0; i < args.length; i++) {
if (args[i].equalsIgnoreCase("usage"))
throw new UsageException();
String[] nvpair = new String[2];
int token = args[i].indexOf('=');
if (token < 0)
throw new Exception("Invalid argument, " + args[i]);
nvpair[0] = args[i].substring(0,token);
nvpair[1] = args[i].substring(token+1);
p.put(nvpair[0], nvpair[1]);
}
return p;
}
/**
* Look for a default properties file
*/
public static Properties checkForDefaults() throws IOException {
Properties defaults = new Properties();
try {
File defaultprops = new File("accessor-defaults.properties");
FileInputStream defaultsIS = new FileInputStream(defaultprops);
//inform("loading options from accessor-defaults.properties");
defaults.load(defaultsIS);
} catch (FileNotFoundException fnfex) {
//inform("No accessor-defaults.properties found");
}
return defaults;
}
public static void inform(String s) {
System.out.println(s);
}
public static void inform(String s, Throwable t) {
System.out.println(s);
t.printStackTrace();
}
private MBeanServerConnection getRuntimeMBeanServerConnection()
throws IOException
{
// construct jmx service url
// "service:jmx:[url]/jndi/[mbeanserver-jndi-name]"
JMXServiceURL serviceURL =
new JMXServiceURL(
"service:jmx:" + getServerUrl() +
"/jndi/" + RuntimeServiceMBean.MBEANSERVER_JNDI_NAME
);
// specify the user and pwd. Also specify weblogic provide package
inform("user name [" + username + "]");
inform("password [" + password + "]");
Hashtable h = new Hashtable();
h.put(Context.SECURITY_PRINCIPAL, username);
h.put(Context.SECURITY_CREDENTIALS, password);
h.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES,
"weblogic.management.remote");
// get jmx connector
JMXConnector connector = JMXConnectorFactory.connect(serviceURL, h);
inform("Using JMX Connector to connect to " + serviceURL);
return connector.getMBeanServerConnection();
}
private void initialize(Properties p) {
serverUrl = p.getProperty("url","t3://localhost:7001");
username = p.getProperty("user","weblogic");
password = p.getProperty("pass","weblogic");
queryString = p.getProperty("query","SEVERITY IN
('Error','Warning','Critical','Emergency')");
accessorType = p.getProperty("type","ServerLog");
try {
beginTime = Long.parseLong(p.getProperty("begin","0"));
String end = p.getProperty("end");
endTime = (end==null) ? Long.MAX_VALUE : Long.parseLong(end);
} catch (NumberFormatException nfex) {
throw new RuntimeException("Error formatting time bounds", nfex);
}
}
private static void usage() {
inform("");
inform("");
inform("Usage: ");
inform("");
inform(" java WLAccessor [options]");
inform("");
inform("where [options] can be any combination of the following: ");
inform("");
inform(" usage Prints this text and exits");
inform(" url=<url> default: 't3://localhost:7001'");
inform(" user=<username> default: 'weblogic'");
inform(" pass=<password> default: 'weblogic'");
inform(" begin=<begin-timestamp> default: 0");
inform(" end=<end-timestamp> default: Long.MAX_VALUE");
inform(" query=<query-string> default: \"SEVERITY IN ('Error','Warning','Critical','Emergency')\"");
inform(" type=<accessor-type> default: 'ServerLog'");
inform("");
inform("Example:");
inform("");
inform(" java WLAccessor user=system pass=gumby1234 url=http://myhost:8000 \\");
inform(" query=\"SEVERITY = 'Error'\" begin=1088011734496 type=ServerLog");
inform("");
inform("");
inform("");
inform("All properties (except \"usage\") can all be specified in a file ");
inform("in the current working directory. The file must be named: ");
inform("");
inform(" \"accessor-defaults.properties\"");
inform("");
inform("Each property specified in the defaults file can still be ");
inform("overridden on the command-line as shown above");
inform("");
}
/** Getter for property serverUrl.
* @return Value of property serverUrl.
*
*/
public java.lang.String getServerUrl() {
return serverUrl;
}
/** Setter for property serverUrl.
* @param serverUrl New value of property serverUrl.
*
*/
public void setServerUrl(java.lang.String serverUrl) {
this.serverUrl = serverUrl;
}
protected String serverName = null;
protected String username = null;
protected String password = null;
protected String queryString = "";
private String serverUrl = "t3://localhost:7001";
private String accessorType = null;
private long endTime = Long.MAX_VALUE;
private long beginTime = 0;
private WLDFAccessRuntimeMBean dar = null;
}
診断データがWLDFアーカイブまたはログに書き込まれている間にシステム・クロックをより前の時間にリセットすると、タイムスタンプに基づいてデータを問い合わせる際に、予期しない結果が生じる可能性があります。たとえば、イベントのシーケンスが次のような場合を考えます。
2:00 PMに、診断イベントがRECORD_200として、2:00:00 PMのタイムスタンプでアーカイブされます。
2:30 PMに、診断イベントがRECORD_230として、2:30:00 PMのタイムスタンプでアーカイブされます。
3:00 PMに、システム・クロックを2:00 PMにリセットします。
2:15 PM(クロックのリセット後)に、診断イベントがRECORD_215として、2:15:00 PMのタイムスタンプでアーカイブされます。
2:00 PMと2:20 PMの間に生成されたレコードを取得する問合せを発行します。
問合せは、2:30:00 PMのタイムスタンプを持つRECORD_230によって終了するため、RECORD_215を取得しません。