Tuesday, September 20, 2011

How to create an OS script based UDM to calculate “Network Packet Loss”?


To create OS script based UDM, following steps are needed:
1. Create the OS script
2. Create an OS script based UDM

Let’s look at these steps in detail:
1. Create the OS script (For details, look at http://download.oracle.com/docs/cd/E11857_01/em.111/e16790/udm.htm#CGDBACGA)
OS script can be created using any scripting language e.g. perl/shell scripting etc.
I have created a shell script (npl.sh) to calculate 'Network Packet Loss' as given below
================================================
#!/bin/sh
# Sample User Defined Event monitoring script.
export PATH="/bin:/usr/bin:/usr/sbin";
cmd=`mtr -c 1 -r`;

p=`echo $cmd|cut -d " " -f 9|cut -d '%' -f 1`

echo "em_result=${p}";
echo "em_message=Network Packet Loss is: ${p}"
================================================

You can create this script (npl.sh) at any location like in my case, I saved it as /u01/scripts/npl.sh
Ensure that you can run the script once as the required user and it should give you expected output on command prompt itself before you register the script for UDM.

This script uses "mtr" command that requires SUDO access, so I need to execute an additional step to ensure that SUDO access is given to the user while running this script. That additional step is to configure Privilege Delegation Providers (http://download.oracle.com/docs/cd/E11857_01/install.111/e16847/addnl_tasks.htm#BABDEADD)

Creating a Privilege Delegation Setting
a. Click on Setup link on the Enterprise Manager home page and then choose Manage Privilege Delegation Settings from the left menu panel.
b. It will show you list of target hosts. Click on Edit button against the target host where you want to run the script.
c. Select the SUDO privilege delegation type
d. Enter the privilege delegation command e.g. I entered "sudo -u %RUNAS% %COMMAND%" and click on Update to apply the settings to the host.
e. Confirm the setting

2. Create an OS script based UDM
Now that we have created the script (npl.sh), configured needed privilege and ensured that script g ves expected output. Next step is to register the script for UDM and create the UDM

a. From the home page of the target Host that has OS monitoring script (npl.sh), choose User-Defined Metrics link from Related Links at the page bottom. The User-Defined Metrics summary page appears.

b. Click Create.

Enter the Metric Name as "network_packet_loss"
Metric Type as Number
Command Line "/bin/sh /u01/scripts/npl.sh"
Provide Operating System Credentials to run the script. Do ensure to select Run Privilege as "Sudo" and Run as root"

Enter Thresholds
For Comparison Operator ">=" Warning as "5" and Critical as "10"

Let other values be default values for Consecutive Occurrences or Schedule etc.
By default, metric evaluation will happen every 5 minutes.

c. Click OK.
"network_packet_loss" metric is created and will appear in the User-Defined Metric summary page.

After 5 min. , you should start seeing data/charts against this user defined metric.

Thursday, September 01, 2011

EM11g ADP: How to resolve NoClassDefFoundError: oracle/adf/model/portlet/binding/PortletBinding error?

Problem: ADP manager is configured and setup successfully. ADP agent has been deployed successfully on 10.3.3 managed server. 10.3.3 WLS server has some ADF applications. After deploying adp agent, managed server comes up with following error in its log:
Root cause of ServletException.
java.lang.NoClassDefFoundError: oracle/adf/model/portlet/binding/PortletBinding
         at oracle.adfinternal.controller.engine.ControlFlowEngine.invokeTaskFlow(ControlFlowEngine.java:1)
         at oracle.adfinternal.controller.state.ChildViewPortContextImpl.invokeTaskFlow(ChildViewPortContextImpl.java:102)
         at oracle.adfinternal.controller.state.ControllerState.createChildViewPort(ControllerState.java:1302)
         at oracle.adfinternal.controller.ControllerContextImpl.createChildViewPort(ControllerContextImpl.java:76)
         at oracle.adf.controller.internal.binding.DCTaskFlowBinding.createRegionViewPortContext(DCTaskFlowBinding.java:409)
         at oracle.adf.controller.internal.binding.DCTaskFlowBinding.getViewPort(DCTaskFlowBinding.java:332)
         at oracle.adf.controller.internal.binding.TaskFlowRegionModel.doProcessBeginRegion(TaskFlowRegionModel.java:160)
         at oracle.adf.controller.internal.binding.TaskFlowRegionModel.processBeginRegion(TaskFlowRegionModel.java:108)
         at oracle.adf.controller.internal.binding.TaskFlowRegionController.doRegionRefresh(TaskFlowRegionController.java:197)
         at oracle.adf.controller.internal.binding.TaskFlowRegionController.refreshRegion(TaskFlowRegionController.java:119)

Solution: Add "–Xverify:none" to the JVM startup arguments

Cause: "–Xverify:none" JVM option turns off the class verifier.