SNMP

WebLogic SNMP Monitoring for Server Health State

Hi,

Jay SenSharma

Jay SenSharma

This post was created as one of our subscriber Shashi.rsb was facing an issue in creating a SNMP trap for server health state, hence I have created this post. Here is a very simple demonstration and configuration to receive the SNMP traps for the health state of a Managed Server running as part of our WebLogic Domain. In this demo we will see how we can configure the SNMP Trap and SNMP Agent to provide us the  Health State Information of a WebLogic Server. Usually if the Server’s Health state is HEALTH_OK,

At any point of time our WebLogic server may have in any of the following Health States:

public static final int HEALTH_OK;
public static final int HEALTH_WARN;
public static final int HEALTH_CRITICAL;
public static final int HEALTH_FAILED;
public static final int HEALTH_OVERLOADED;

So based on your requirement you can choose any Health State for SNMP monitoring … I am using HEALTH_OK for this demo.

Also Notice a kind of BUG:  http://middlewaremagic.com/weblogic/?p=6149#comment-3264

Step1). Start WeLogic Admin Server and login to Admin Console and then create a SNMP Agent like following:

SNMP_HealthState_1

SNMP_HealthState_1

Step2). Now create a String Monitor  By Clicking on   “Diagnostics —> SNMP—> ServerSNMPAgent-0—-> String Monitors”

SNMP_HealthState_2

SNMP_HealthState_2

Step3). Now create a Trap Destination “Diagnostics —> SNMP—> ServerSNMPAgent-0—-> Trap Destinations”

SNMP_HealthState_3

SNMP_HealthState_3

Step4). After making all the above configurations  your “”  file will look ike following:

  <snmp-agent-deployment>
    <name>ServerSNMPAgent-0</name>
    <enabled>true</enabled>
    <send-automatic-traps-enabled>true</send-automatic-traps-enabled>
    <snmp-port>1161</snmp-port>
    <snmp-trap-version>1</snmp-trap-version>
    <community-prefix>public</community-prefix>
    <snmp-trap-destination>
      <name>TrapDestination-0</name>
      <host>10.10.10.10</host>
      <port>1165</port>
      <community>public</community>
      <security-level>noAuthNoPriv</security-level>
    </snmp-trap-destination>
    <snmp-string-monitor>
      <name>SNMPStringMonitor-1</name>
      <enabled-server>AdminServer,MS-1</enabled-server>
      <monitored-m-bean-type>ServerRuntime</monitored-m-bean-type>
      <monitored-m-bean-name>MS-1</monitored-m-bean-name>
      <monitored-attribute-name>HealthState</monitored-attribute-name>
      <polling-interval>10</polling-interval>
      <string-to-compare>HEALTH_OK</string-to-compare>
      <notify-differ>false</notify-differ>
      <notify-match>false</notify-match>
    </snmp-string-monitor>
    <community-based-access-enabled>true</community-based-access-enabled>
    <snmp-engine-id>ServerSNMPAgent-0</snmp-engine-id>
    <authentication-protocol>noAuth</authentication-protocol>
    <privacy-protocol>noPriv</privacy-protocol>
    <inform-retry-interval>10000</inform-retry-interval>
    <max-inform-retry-count>1</max-inform-retry-count>
    <localized-key-cache-invalidation-interval>3600000</localized-key-cache-invalidation-interval>
    <snmp-access-for-user-m-beans-enabled>false</snmp-access-for-user-m-beans-enabled>
    <inform-enabled>false</inform-enabled>
    <master-agent-x-port>1705</master-agent-x-port>
    <target>AdminServer</target>
  </snmp-agent-deployment>

Step5). Restart your AdminServer.

Step6). Now start the  ”SnmpTrapMonitor like following: (Make Sure to run the “. ./setWLSEnv.sh” to set the environment in the same shell prompt where you are planning to run the following command)

java   weblogic.diagnostics.snmp.cmdline.Manager   SnmpTrapMonitor   -p   1165

Step7). Now as soon as you will start your Managed Server you will get the following kind of Trap in the above Shell/Command prompt  once the ManagedServer (MS-1) have the HEALTH_OK state:

java weblogic.diagnostics.snmp.cmdline.Manager SnmpTrapMonitor -p 1165
Listening on port:1165
--- Snmp Trap Received ---
    Version        : v1
    Source         : UdpEntity:10.10.10.10:1161
    Community      : public
    Enterprise     : enterprises.140.625
    TrapOID        : enterprises.140.625.0.65
    RawTrapOID     : 1.3.6.1.4.1.140.625.0.65
    Trap Objects   : {
   { enterprises.140.625.100.5=Mon Mar 21 20:17:02 IST 2011 }
   { enterprises.140.625.100.10=MS-1 }
}
    Raw VarBinds   : {
   { enterprises.140.625.100.5=Mon Mar 21 20:17:02 IST 2011 }
   { enterprises.140.625.100.10=MS-1 }
}
--- Snmp Trap Received ---
    Version        : v1
    Source         : UdpEntity:10.10.10.10:1161
    Community      : public
    Enterprise     : enterprises.140.625
    TrapOID        : enterprises.140.625.0.75
    RawTrapOID     : 1.3.6.1.4.1.140.625.0.75
    Trap Objects   : {
   { enterprises.140.625.100.5=Mon Mar 21 20:17:11 IST 2011 }
   { enterprises.140.625.100.10=MS-1 }
   { enterprises.140.625.100.55=jmx.monitor.error.type }
   { enterprises.140.625.100.60=null }
   { enterprises.140.625.100.65=null }
   { enterprises.140.625.100.70=com.bea:Location=MS-1,Name=MS-1,Type=ServerRuntime }
   { enterprises.140.625.100.75=ServerRuntime }
   { enterprises.140.625.100.80=HealthState }
}
    Raw VarBinds   : {
   { enterprises.140.625.100.5=Mon Mar 21 20:17:11 IST 2011 }
   { enterprises.140.625.100.10=MS-1 }
   { enterprises.140.625.100.55=jmx.monitor.error.type }
   { enterprises.140.625.100.60=null }
   { enterprises.140.625.100.65=null }

.
.
Thanks
Jay SenSharma


Stuck Thread Alert using WebLogic SNMP Agent

Hi,
Jay SenSharma

Jay SenSharma

Based on a requirement of a  user named Shashi_sr on Oracle Forums we have created this post. Getting Alert is one of the most important  requirement in production environments. We can use many techinques to get alerts regarding the behaviour and scenario of WebLogic Server. WLST, JMX and WLDF are the most common techniques to monitor our WebLogic server resources and the health check of these resources.

Here we are going to see a very simple example of creating  a STUCK THREAD alert using SNMP Log Filters.  So that as soon as any thread will be declared by WebLogic  as STUCK we will immediately get an SNMP Alert.

You can also do the same thing using WLST script have a look at the post –  Sending Email Alert For Stuck Threads With Thread Dumps

Step1). Login to AdminConsole and then nevigate to “Diagnostics————> SNMP”

Step2). Now create an SNMP Agent like following:

Name: StuckThreadSNMPAgent
Enabled: true
Targeted Servers: AdminServer
UDP Port : 161
Community Prefix: public
Send Automatic Traps Enabled : true
Community Based Access Enabled : true
Inform Retry Interval : 10000
Maximum Inform Retry Count : 1
Credential Cache Invalidation Interval : 3600000
LogFilter_StuckThread_1

LogFilter_StuckThread_1

Step3). Now create a Log Filter  By clicking on

“Diagnostics—->SNMP—–>StuckThreadSNMPAgent—–>Configuration (Tab)—–>Log Filters”
like following:
Name: StuckThreadLogFilter
Enabled Servers: AdminServer
Severity Level: Error
Subsystem Names: WebLogicServer
Message IDs : 000337
Message Substring : [STUCK] ExecuteThread
Like following:
LogFilter_StuckThread_2

LogFilter_StuckThread_2

Step4). Now  Create a Trap Destination like following:

“Diagnostics—->SNMP—–>StuckThreadSNMPAgent—–>Configuration (Tab)—–>Trap Destinations”
Name: StuckThreadTrapDest
Community: public
Host: localhost
Port : 165
as following:
LogFilter_StuckThread_3

LogFilter_StuckThread_3

Step5). Now restart your Server  Just to make sure that every thing is OK.

Step6). Now open a command prompt and then run “setWLSEnv.cmd”/ setWLSEnv.sh  then start the

java weblogic.diagnostics.snmp.cmdline.Manager SnmpTrapMonitor -p 165

LogFilter_StuckThread_4

LogFilter_StuckThread_4

As soon as you will get any STUCK THREAD you will get an alert immediately as following:

LogFilter_StuckThread_5

LogFilter_StuckThread_5

.
.
Thank
Jay SenSharma

Steps to Configure SNMP agent on Weblogic Server

Ravish Mody

Simple Network Management Protocol (SNMP) is a type of an application layer protocol which governs the exchange of management information between network devices. Now in webLogic server SNMP agents can be configured to collect data  from the webLogic server management system and communicate the results over the SNMP protocol. In this example we will see “How to Configure SNMP Agent in WebLogic Server?”

This could be a very useful tool for the administrators to keep a watch of what exactly is going on with the servers and take an actions accordingly. As weblogic server supports SNMP protocol like SNMPv1, SNMPv2 and SNMPv3 from weblogic server version 10 MP-3 we can do lot of things with it.

.

Some Advantages of Weblogic  SNMP Agents

  • Send notifications when any servers starts or has been shuts down.
  • Monitor any specific log messages or error message and send notifications when weblogic server generates them.
  • You can even use JMX monitors to poll weblogic server MBeans periodically and send notifications when the MBean attributes change in what ever way you want.
  • And lot more can be done with it.

Steps to Configure SNMP agent

1.  Start your WebLogic Server and Login to the Admin Console.

2.  Create a SNMP agent from the following console path

Domain Structure -> expand “Diagnostics” -> “SNMP”

SNMP-1

Creating SNMP Agent

SNMP-2

Giving SNMP Name

SNMP-3

Selecting SNMP Agent

SNMP-4

Configuring SNMP Agent

SNMP_5

Targeting SNMP Agent

3. Once you target the SNMP agent on the running server then you will get the following output on the prompt which makes sure that our configuration is taken properly.

SNMP

Output After SNMP is Targeted

4.  Now we will configure an Attribute changes on our SNMP agent to keep an eye on the changes done at an applications deployment order.

SNMP-3

Selecting SNMP Agent

AppDp

Creating Attribute Changes

AppDp-1

Giving Attribute Changes Name

AppDp-2

Selecting MBean Attribute - DeploymentOrder

AppDp-3

Selecting Attribute Changes

AppDp-4

Configuring Attribute Changes

AppDp-5

Targeting Attribute Changes

5. After configuring Attribute changes now we will configure Trap destinations on our SNMP agent to send the notifications.

SNMP-3

Selecting SNMP Agent

SNMP-11

Configuring Trap Destination

SNMP-12

Configuring Trap Destination

6.  Now open a new command prompt/shell and run the following command after running setDomainEnv.cmd / setDomainEnv.sh


java weblogic.diagnostics.snmp.cmdline.Manager SnmpTrapMonitor -p 165

Where -p is having the post given to the Trap Destination

7.  SNMP side configuration has been completed, now its time to test if everything is working fine as it should be. So from the Deployment  page go the application which you have chosen in the step 4 and from the configuration tab change the deployment order as shown below.

Console Path:

Deployment –> (YOUR APPLICATION) –> Configuration tab –> change Deployment Order

AppDp-6

Deployment Page

8.  You can now notice that if you change the deployment order parameter you get the following output, which would indicate the the order has been change as shown in the below snap-shot.

AppDp-7

Trap Result

You can monitor lot more by using the same steps and also configure log filtering, monitor particular string and many more things. Hence this way you can get alerts and keep knowing what is going on in your production environment.

Regards,

Ravish Mody


Copyright © 2010-2012 Middleware Magic. All rights reserved. |