WebLogic and DevOps Monitoring: WLSDM JMX MBeans
An MBean is similar to a Java Bean component.It consists of some variables with getter/setter methods (Arguments) and some custom methods (Operations). We can register an MBean in WebLogic server, its arguments and operations are exposed like WebService. After that, we can access these operations and variables from an external Java class or other applications. For example, We can expose a DB table CRUD operation in Java MBean and registered in WebLogic server., then any deployed WebLogic application or external Java class can access this MBean.
Creating MBean is little costly, we need to write an Interface, a JMBean ava class with attributes and methods and need to register it into WebLogic server so others can use it.
WLSDM has a feature called ‘Generic DevOps‘. Using this, we can register a Mbean using a shell/batch commands or SQL Queries. Any Unix/Windows administrator or a DBA can register an MBean in WebLogic server without knowing Java & Deployment. Another feature WLSDM has the smart dashboard. The Smart Dashboard is useful to monitor metrics (any Integer type values). We can assign any MBean metric attribute to the Smart dashboard so a WebLogic Administrator can monitor. Below I summarise the above text
- Create an MBean dynamically using WLSDM Generic DevOps Means using a Shell/Batch script or SQL Query
- Apply this MBean attributes to a smart dashboard so the WebLogic administrator can monitor it
Also, any deployed WebLogic application (war or jar file) or external application can access this dynamic MBean. Here below I have mentioned some of metrics we can create it in WLSDM using Genetic DevOps
- Measure web service or application response time
- Measure CPU performance like utilization, memory
- WebLogic Admin/Managed server consumption, no of threads
- An SQL query output, example Salary of an employee
- Deployed application business data, example: number of request the web application received or the total number of users currently logged in.
As I wrote many above, you may think to create this MBean in WLSDM takes much time. I say no you can create it in.
Time to create an MBean and Smart Dashboard (2-3 minutes) + Time you are writing the shell (OR) batch script (OR) SQL, Query
Let’s create an example of MBean in WLSDM and create a dashboard. We create it using the following two points
- Create an MBean using Windows batch command. (A simple windows command output CPU and MEMORY usage)
- Assign the CPU and MEMORY usage to a WLSDM smart dashboard
WLSDM Generic MBean Example:
1.Log in to the WebLogic console >> Click on the Smart Dashboard Console. This will navigate you to the WLSDM dashboard.
2.Click on the Monitoring & Diagnostics as shown below. This will take you to the page where we can create and register the MBean and deploy it in a smart dashboard
3.Click on the Generic DevOps MBeans tab. Here we can see all the existing MBeans. Click on the New Generic DevOps MBean on the right-hand side as shown below to create and register a custom MBean.
4.This will open a screen as shown below. Here we can select the type (Shell / SQL ) and WebLogic server where the MBean is registered
- Select the Embedded Script; It allows us to write a shell script or batch script; If the WebLogic server is installed on the Unix flavors then we can write a shell script, On windows then we can write batch commands. WLSDM will take care of executing the commands on the server.
- Move the WebLogic server instance from Target servers to the Applied Servers. The MBean we are going to create will be deployed only to the Applied Servers
Other Supported Types=> Embedded Script OR Load From Executable File OR SQL SCRIPT
5.This screen is important.; Input your batch/shell commands here and click Transform. This will generate MBeans from the script output. Once MBeans are generated then click Next
The first Arrow mark is pointing to a text area where we can write our custom shell/batch commands. The Output of the commands must be KEY=VALUE pair, where the KEY must be string and VALUE must be Integer/Long type. (Click on the Transform button once the script entered)
The seconds Arrow is pointing to Script Execution Timeout. Here we can specify a maximum time the script can run. Minimum is 0 seconds, and the maximum is 30 seconds. The default value is 5 second.
The third Arrow is pointing to Generated JMX MBean Attributes. These MBean attributes are generated from the Shell script output (KEY=VALUE), where KEY is the Attribute Name & Value type is the Attribute type. For example, if the script output is TOTALMEMORY=700000 then the attributename is TOTALMEMORY and INTEGER is ATTRIBUTETYPE. The value will be generated dynamically at the run time.This batch script returns output like below, now look at the Generated JMX MBean Attribute
FreePhysicalMemory=7152820 LoadPercentage=86 TotalPhysicalMemory=17071976448
6.In this screen, we can create and assign the above generated DevOps MBean attributes to a WLSDM dashboard so that we can see these metrics on the WLSDM screen.
In the first BOX, I have created a dashboard & moved it to the applied dashboard so the MBeans will be applied to that dashboard.
In the second BOX, I input an MBean name. WLSDM will register this MBean in WebLogic
In the third BOX, I selected Attributes in Different Chart, that means each of the above attribute value will be displayed in a separate chart instead of all in one chart.
7.The above created MBean ( Box -2 ) will be displayed under the Generic DevOps MBeans tab. We can edit it later if we want by click on the pencil icon as shown below
8.We can view the dashboard by click on the Dashboard >>
9.The dashboard will display as below. As you see, each attribute is displayed in a separated chart(See BOX-3 in step 6). It shows the memory and CPU consumptions in a line chart, where TIME as x-axis and the corresponding value as Y-Axis
We can access the above registered MBean attributes in an external application or from a Java program. For example, we can write a Java class that connects to WebLogic server and access these MBean attributes values. WLSDM provides an MBean search console where we can look all the registered MBean in WebLogic server.
As shown below, I navigated to MBean Search console and searched for DevOps; This results in me all the DevOps MBean attributes.
Here I am accessing the same above MBean attribute in the JConsole which is available under JAVA_HOME\bin\Jconsole.bat:
In my Next post, I will post the following topics
- Create an MBean from an SQL query & assign it to a dashboard
- Create a dashboard using existing DevOps MBeans
There are wonderful tutorials available on the WLSDM website about Generic DevOps which is shown below:
Author: Govindan Padmanaban
Original Post: http://www.catgovind.com/weblogic/how-to-create-a-wlsdm-generic-devops-mbean/