X

Proactive insights, news and tips from Oracle WebLogic Server Support. Learn Oracle from Oracle.

Monitoring FAN Events

Stephen Felts
Manager

fanWatcher is a sample program to print the Oracle Notification Service (ONS) Fast Application Notification (FAN) event information. These events provide information regarding
load balancing, and service and instance up and down events. This information is automatically processed
by WebLogic Server Active GridLink and UCP on the mid-tier. For more information about FAN events, see this link.  The program described here is an enhancement of the earlier program described in that white paper  This program can be modified to work as desired to monitor
events and help diagnose problems with configuration. The code is available this link
.

To run this Java application, you need to be set up to run a
JDK and you need ons.jar and ojdbcN.jar in the CLASSPATH. The CLASSPATH is set differently depending on
whether you are running on the database server or on the mid-tier with WebLogic
Server or UCP. Make sure to use the
correct path separator for CLASSPATH on your platform (';' for Windows, ':'
otherwise).

The general format for the command line is

java fanWatcher config_type [eventtype … ]

Event Type Subscription

The event type sets up the subscriber to only return limited
events. You can run without specifying
the event type to see what types of events are returned. When you specify an event name on the command
line, the program sets up the subscriber to have a simple match on the
event. If the specified pattern occurs
anywhere in a notification's header, then the comparison statement evaluates
true. The most basic pattern match is an empty string (not null), which matches
all notifications. The pattern is
enclosed in double quotes (required) and prefixed with “%” to be case
insensitive.

Event processing is more complete than shown in this sample. The subscription string is generally composed
of one or more comparison statements, each logically related to another with
the boolean operators '|' for an OR relationship or '&' for an AND
relationship. Parentheses are used to
group these comparison statements, and the '!' operator placed before an
opening parenthesis negates the evaluated value within.

Each individual comparison statement must be enclosed within
double quotes ('"'), and can take one of two basic forms: "pattern" or "name=value". A "pattern" is a simple string
match of the notification header: if the
specified "pattern" occurs anywhere in a notification's header, then
the comparison statement evaluates true. The most basic pattern match is an empty string (not NULL)
which matches all notifications.

The "name=value" format compares the ONS
notification header or property name with the name against the specified value,
and if the values match, then the comparison statement evaluates true. If the
specified header or property name does not exist in the notification the
comparison statement evaluates false. A
comparison statement will be interpreted as a case insensitive when a percent
character ('%') is placed before the opening quote. Note that for
"name=value" comparison statements, only the value is treated as case
insensitive with this option: the name lookup will always be case sensitive. A comparison statement will be interpreted as
a regular expression when a dollar sign character ('$') is placed before the
opening quote. Standard POSIX regular expressions are supported. To specify a regular
expression that is also case insensitive, place the dollar sign and percent
sign together and in that order ("$%") before the opening quote.

A special case subscription string composed of only the
exclamation point character ('!') signifies that the subscription will not
match any notifications.

You might want to modify the event to select on a specific
service by using something like

%"eventType=database/event/servicemetrics/<serviceName>
"

Running with Database Server 10.2 or later

This approach runs on the database server and connects
directly to the local ONS daemon available in the Grid Infrastructure cluster. The FANwatcher utility must be run as a user
that has privilege to access the $CRS_HOME/opmn/conf/ons.config, which is used by the ons daemon to start and
accessed by this program. The configuration type on the command line is
set to “crs”.

# CRS_HOME should be set for your Grid infrastructure

echo $CRS_HOME

CRS_HOME=/mypath/scratch/12.1.0/grid/

CLASSPATH="$CRS_HOME/jdbc/lib/ojdbc6.jar:$CRS_HOME/opmn/lib/ons.jar:."

export CLASSPATH

javac fanWatcher.java

java -Doracle.ons.oraclehome=$CRS_HOME fanWatcher crs

Running with WLS 10.3.6 or later using an explicit node list

There are two ways to run in a client environment – with an
explicit node list and using auto-ONS. It’s necessary to have ojdbcN.jar and ons.jar that are available when
configured for WLS. If you are set up to
run with UCP directly, these should also be in your CLASSPATH.

In the first approach, it will work with Oracle driver and
database 11 and later (SCAN support came in later versions of Oracle including
the 11.2.0.3 jar files that shipped with WLS 10.3.6).

# Set the WLS environment using wlserver*/server/bin/setWLSEnv

CLASSPATH="$CLASSPATH:." # add
local directory for sample program

export CLASSPATH

javac fanWatcher.java

java fanWatcher "nodes=rac1:6200,rac2:6200" database/event/service

The node list is a string of one or more values of the form
name=value separated by a newline character (\n).

There are two supported formats for the node list.

The first format is available for all versions of ONS. The following names may be specified.

nodes – This is required. The format is one or more host:port pairs
separated by a comma.

walletfile – Oracle wallet file used for SSL communication
with the ONS server.

walletpassword – Password to open the Oracle wallet file.

The second format is available starting in database 12.2.0.2. It supports more complicated topologies with
multiple clusters and node lists. It has
the following names.

nodes.id—this value is a list of nodes representing a unique
topology of remote ONS servers. id specifies a unique identifier for the node
list. Duplicate entries are ignored. The list of nodes configured in any list
must not include any nodes configured in any other list for the same client or
duplicate notifications will be sent and delivered. The list format is a comma
separated list of ONS daemon listen addresses and ports pairs separated by
colon.

maxconnections.id— this value specifies the maximum number
of concurrent connections maintained with the ONS servers. id specifies the
node list to which this parameter applies. The default is 3.

active.id If true, the list is active and connections are
automatically established to the configured number of ONS servers. If false,
the list is inactive and is only be used as a fail over list in the event that
no connections for an active list can be established. An inactive list can only
serve as a fail over for one active list at a time, and once a single
connection is re-established on the active list, the fail-over list reverts to
being inactive. Note that only notifications published by the client after a
list has failed over are sent to the fail over list. id specifies the node list
to which this parameter applies. The default is true.

remotetimeout —The timeout period, in milliseconds, for a
connection to each remote server. If the remote server has not responded within
this timeout period, the connection is closed. The default is 30 seconds.

The walletfile and walletpassword may also be specified
(note that there is one walletfile for all ONS servers). The nodes attribute cannot be combined with
name.id attributes.

Running with WLS using auto-ONS

Auto-ONS is available starting in Database 12.1.0.1. Before that, no information is available. Auto-ONS only works with RAC configurations; it does not work with an Oracle Restart environment.  Since the first version of WLS that ships
with Database 12.1 is WLS 12.1.3, this approach will only work with upgraded
database jar files on versions of WLS earlier than 12.1.3. Auto-ONS works by
getting a connection to the database to query the ONS information from the
server. For this program to work, a
user, password, and URL are required. For the sample program, the values are
assumed to be in the environment (to avoid putting them on the command
line). If you want, you can change the
program to prompt for them or hard-code the values into the java code.

# Set the WLS environment using wlserver*/server/bin/setWLSEnv

# Set the credentials in the environment. If you don't like doing this,

# hard-code them into the java program

password=mypassword

url='jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=\

(ADDRESS=(PROTOCOL=TCP)(HOST=rac1)(PORT=1521))\

(ADDRESS=(PROTOCOL=TCP)(HOST=rac2)(PORT=1521)))\

(CONNECT_DATA=(SERVICE_NAME=otrade)))'

user=myuser

export password url user

CLASSPATH="$CLASSPATH:."

export CLASSPATH

javac fanWatcher.java

java fanWatcher autoons

fanWatcher Output

The output looks like the following. You can modify the program to change the
output as desired. In this short output
capture, there is a metric event and an event caused by stopping the service on
one of the instances.

** Event Header **

Notification Type: database/event/servicemetrics/otrade

Delivery Time: Fri Dec 04 20:08:10 EST 2015

Creation Time: Fri Dec 04 20:08:10 EST 2015

Generating Node: rac1

Event payload:

VERSION=1.0 database=dev service=otrade { {instance=inst2 percent=50 flag=U

NKNOWN aff=FALSE}{instance=inst1 percent=50 flag=UNKNOWN aff=FALSE} } timestam

p=2015-12-04 17:08:03

** Event Header **

Notification Type: database/event/service

Delivery Time: Fri Dec 04 20:08:20 EST 2015

Creation Time: Fri Dec 04 20:08:20 EST 2015

Generating Node: rac1

Event payload:

VERSION=1.0 event_type=SERVICEMEMBER service=otrade instance=inst2 database=dev
db_domain= host=rac2 status=down reason=USER timestamp=2015-12-04 17:

 

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha
Oracle

Integrated Cloud Applications & Platform Services