Control Plugin

Control Plugin

Control Plugin Introduction

The ControlPlugin defines control actions and implements the doAction() method used to control resources. Like the Measurement Plugin, the method of control is left entirely to the plugin. Support classes are provided to assist with certian types of control: JDBC, JMX, Script Execution and Windows Service Manager. Following are some examples of collection methods used by various plugins:

  • JMX - JBoss, WebLogic, WebSphere.
  • JDBC - Mysql, PostgreSQL
  • Script Execution - Apache, Tomcat
  • Windows Service Manager - IIS, Apache, Tomcat

ControlPlugin.doAction Method

Control actions are defined in the Plugin XML Descriptor. Server and Service resources can include an <actions> tag that will define the control actions that resource supports. Multiple control actions can be defined by separating the actions with a comma. For example:

Defining Control Actions
<actions include="start,stop,restart"/>

These actions are passed into doAction as a String argument. The plugin can then act accordingly. Each resource that supports control will have it's own ControlPlugin instance. Configuration parameters defined within the Plugin XML Descriptor <config> tags can be retrieved using the ControlPlugin.getConfig method.

An example using a JBoss JMS Destination, which uses JMX for it's control actions:

hq-plugin.xml
<!-- ObjectName properties used in the control plugins -->
  <property name="JMSQueue"
	    value="jboss.mq.destination:service=Queue,name=%jms.destination%"/>

  ...
  <service name="JMS Destination">
    <config>
      <option name="jms.destination"
                description="JMS Destination"
                default=""/>
    </config>

    <actions include="removeAllMessages"/>
    ...
  </service>
  ...
JBossJMSControlPlugin.java
public class JBossJMSControlPlugin extends ControlPlugin {

    public void doAction(String action) throws PluginException {

        // ObjectName to invoke the method on
        String oName = getProperty("JMSQueue"); //From hq-plugin.xml

        try {
            ... // Get a reference to the MBeanServer
            mBeanServer.invoke(oName, action, new Object[0], new String[0]);
            ...
        } catch (Exception e) {
            throw new PluginException("Unable to invoke method '" +
                                      action + "'", e);
        }
    }
}

Labels

 
(None)
System Monitoring Software
SourceForge.net Logo