Management Rules - observedmbean property
Tuesday Nov 06, 2007
My previous blog on selfmanagement and https://glassfish.dev.java.net/javaee5/selfmanagement/selfmanagement_example.html explain how to create management rules with an example.
Assumptions :
Same example as in the above link (memory rule) taken.
Custom Mbeans Memory (impl-class-name:com.sun.example.mbeans.Memory) and MemoryActionBean (impl-class-name:com.sun.example.action.MemoryAction) are deployed.
Problem :
In GUI, when a new management rule is created following the steps and with the values :
Observed Mbean : com.sun.examples.mbeans.Memory
Observed Attribute : FreeMemory
and other values as specified in the example,
the server.log shows an error message that the rule is not configured because of some errors. The log looks like
MemRule;monitor;|SGMT0017:
Error creating and configuring the rule : MemRule due to
IlegalArguments specified for its event type : monitor. Create the
rule with correct arugments for the configured event.|#]
Solution :
Modify the domain.xml under install_directory/domains/domain1/config/ directory - edit the management rule MemRule :
Change the line
property name="observedobject" value="com.sun.example.mbeans.Memory"
to
property name="observedmbean" value="Memory"
Restart the server after this change. And you will see that the error message goes away. Note here that "observedobject" is changed to "observedmbean" and the new value is the name of the custom mbean deployed with the impl-class-name : com.sun.example.mbeans.Memory.
Explanation :
In GUI, the Observed Mbean takes values like
"user:impl-class-name=com.sun.example.mbeans.Memory,name=Memory,server=server".
This value is translated into "observedobject" property in domain.xml. Hence if you specify "com.sun.example.mbeans.Memory", in domain.xml you will see this value against the property "observedobject".
Very few know that there is another property called "observedmbean" that accepts the mbean name directly. But in GUI, there is no explicit way of specifying this observedmbean property. One has to enter the whole object name for the input "Observed Mbean" in GUI, which will get translated into "observedobject" in domain.xml. Alternatively, domain.xml can be modified with observedmbean property.
Whereas in CLI, you could just specify the parameter "observedmbean"
with value "Memory" in the command line, without even specifying the "observedobject" property.
Ex: asadmin create-management-rule --port 4848 --user admin_user
--action MemoryActionBean --eventtype monitor --eventloglevel WARNING --eventproperties
<blah-blah>:observedmbean=Memory:<blah-blah> rule_name
This is an advantage CLI has over GUI.
Tags: glassfishv2 selfmanagement










