After reading through the documentation on the Hyperic website, I found it easy to get started writing custom scripts for monitoring, but not for writing custom plugins using Java. This posting will walk you through setting up your development environment and writing a plugin that will be auto-discovered by Hyperic. I assume that the reader is comfortable with Eclipse IDE, reading & writing Java code, and working with the Hyperic system.  You will need to have the Hyperic Agent and Server setup and configured correctly. Additionally, the Hyperic Agent will need to be unzipped on the local machine.
My Environment
Creating the Eclipse Project
From the Eclipse IDE, create a new “Java Project†with the Eclipse new Project wizard. Use the following options. Note: It is very important to use the J2SE1.4 execution environment. The Hyperic VMWare Open Source 3.1.0 Appliance and has Java 1.4 installed. You will get class version errors if you use J2SE1.5 or 1.6.

Once created, configure the build-path by right-clicking on the project name and choosing “Build Path†- “Add External Jarsâ€. Select the <local-hyperic-install-dir>\hyperic-hq-agent-3.1.1\pdk\lib directory and select both the hq-product.jar and hyperic-util.jar.
Creating the Auto-Discovery Plug-in class
Inside the Eclipse IDE, right-click on the src folder and choose “New” -> “Class.” Fill-in the the details to match the below screencap.

That gives us a new class with one method.
List getServerResources(ConfigResponse platformConfig) throws PluginException {
}
The getServerResources is called by Hyperic to enumerate the server resources for auto-discovery. The getServerResources method returns a List of ServerResources, one for each server. Below is a simple implementation that creates three hypothetical servers.  This doesn’t do very much as everything is hard-coded, but it is a good starting point for getting the plug-in integrated into Hyperic.
package com.citytechinc.articles.hyperic.plugin;
import java.util.ArrayList;
import java.util.List;
import org.hyperic.hq.product.AutoServerDetector;
import org.hyperic.hq.product.PluginException;
import org.hyperic.hq.product.ServerDetector;
import org.hyperic.hq.product.ServerResource;
import org.hyperic.util.config.ConfigResponse;
public class MyAutoDiscoveryServerDetector extends ServerDetector implements
AutoServerDetector {
public List getServerResources(ConfigResponse platformConfig)
throws PluginException {
List servers = new ArrayList();
for (int x=0; x<3; x++) {
ServerResource server = createServerResource("My Auto-Discovery Server -> " + (x+1));
ConfigResponse productConfig = new ConfigResponse();
productConfig.setValue("myTimeout", String.valueOf((x+1)*1000));
productConfig.setValue("myUrl", "http://127.0.0." + (x+1));
productConfig.setValue("Description", "Description - My Auto Discovery Description ->"+(x+1));
server.setProductConfig(productConfig);
servers.add(server);
}
return servers;
}
}
The only code worth mentioning from above is the ConfigResponse object. This object stores name/value pairs that will populate the configuration data for each server. The configuration properties are defined in the hq-plugin.xml file.
Creating the hq-plugin.xml file.
Create a directory called “etc” by right-clicking on the project and choosing “New” -> “Folder”. To create the hq-plugin.xml file, right-click on the newly created etc directory and choose “New” -> “File.” Paste the following code into the hq-plugin.xml file. Note: This file must be named hq-plugin.xml
<?xml version="1.0"?>
<plugin package="com.citytechinc.articles.hyperic.plugin">
<filter name="domain" value="My Auto Discovery"/>
<server name="MyAutoDiscoverServer" version="0.1c" platforms="Unix">
<plugin type="autoinventory" class="MyAutoDiscoveryServerDetector"/>
<config>
<option name="myUrl"
description="Enter the URL for this resource"
default="http://127.0.0.1"/>
<option name="Description"
description="Enter the description for this plug-in"
default="Default My Auto Discovery Description"/>
<option name="myTimeout"
description="Timeout for something in My plug-in"
default="0"/>
</config>
</server>
</plugin>
The above XML defines everything Hyperic needs to configure our plug-in. The <plugin> tag defines the package where our classes will reside. The <server> tag defines the name concatenated with the version that will appear for resource name on the Hyperic UI. The second <plugin> tag defines the type of our plug-in, which in this case is “autoinventory” and then our class name. The <config> tag defines the options that can be configured by a Hyperic user. The MyAutoDiscoveryServerDetector automatically configures all of the parameters listed above, but that is not a requirement.
Creating the Plug-in Jar File
To create the jar file, right-click on the project in the Eclipse UI and click the “Export” option. Choose “Jar File” from the menu. Fill in the options as described in the below screen capture. Note: The plug-in filename should end in “-plugin.jar”

Deploying the Plug-in
To deploy the plug-in, copy the jar file created above to both the Hyperic server and the agent. On the VMWare appliance, that is the following directories:
server - /home/hyperic/server-3.1.0/hq-engine/server/default/deploy/hq.ear/hq-plugins/
agent - /home/hyperic/agent-3.1.0/pdk/plugins/
For some reason, I couldn’t get the server to hot-deploy my jar file, so I had to restart both the server and the agent by running the following commands from the VMWare console:
/etc/init.d/hq-agent stop
/etc/init.d/hq-server restart
/etc/init.d/hq-agent start
Verifying the Plug-in Deployment
Once restarted, open the Hyperic website and you should see something similar to the following.

Notice under the Auto-Discovery section Hyperic found our three hard-coded servers. Click the “Add to Inventory” button to enable Hyperic to monitor our servers.
Configuring the My Auto Discovery Plug-in
Click on the “Server Total” link in the bottom left corner of the dashboard - you will then see a screen like below.

In the above screen capture, you see that our three hard-coded servers are deployed to Hyperic. All three have their availability listed as “?.” This is because we haven’t coded any functionality into our plug-in. This will be done in a separate posting.
Click on the “I” icon to the left of one of our servers and you will see a webpage that looks like below.

Here you can see that the plug-in was correctly configured in our java code. You can edit these settings by clicking on the Edit button in the webpage.
Conclusion
In this posting we successfully created an auto-deployment plug-in for Hyperic. An exercise for the reader is to write custom logic to find their own servers. There are plenty of examples of writing this logic in the source archive available on the Hyperic website. The plug-in source is available in the: C:\\hyperic-hq-src-3.1.1-490\hq\plugins directory.