VMware Cloud Community
StevevandenBuys
Contributor
Contributor

Plugin development from scratch

Hello,

I was wondering if there is more documentation available regarding plugin development from scratch. I posted a similar question on the user forum (http://communities.vmware.com/thread/348910?tstart=0). I'm sorry for double-posting but it occurred to me (after my first post) that this was likely more of a development question than a user question. I'd like to write a completely new plugin that has the ability to track websphere event queues (connect to the queues, read the messages, ability to set alerts on these messages; similar to the log tracking plugin but on queues instead of on files).

I'm having a hard time however figuring out how everything fits together. I read the PDK documentation but it seems to only cover building plugins using xml. I can't find any documentation explaining the actual Java plugin architecture and how one would go about writing more complex Java/xml plugins.

Any help would be very much appreciated!
0 Kudos
8 Replies
StevevandenBuys
Contributor
Contributor

Ok,

I've been examining the source code and think that what I want to do is actually currently impossible. As far as I can tell I would need to write a subclass of GenericPlugin (eg: "EventQueueTrackPlugin") and a subclass of PluginManager (eg: "EventQueueTrackPluginManager") but the ability to plug custom managers into the framework does not seem to exist. I see the AgentDaemon instantiating and calling the init-method of the ProductPluginManager. That init-method has the initialisation of all available plugin managers hardcoded in its source. How then would I be able to add my custom plugin manager without needing to modify the existing ProductPluginManager class? Or is there some utility-method/class that allows me to add custom plugin managers?

Am I missing something here or is what I want to do really not currently supported?
0 Kudos
StevevandenBuys
Contributor
Contributor

Never mind the above post, I figured it out. I'm now in a stage where I can write my own custom plugin and plugin manager. Now I just need to get it to do what I want it to... 😉

Still: some more documentation would be very much appreciated!
0 Kudos
StevevandenBuys
Contributor
Contributor

Ok,

next problem/question: how does one add custom properties to a new plugin? For my event queue tracking plugin I need properties such as the MQ host, channel, port, queue manager and queue(s). Currently I have a hq-plugin.xml containing the following:

<plugin>
<service name="Websphere Event Queue Tracking">
<plugin type="event_queue_track"
class="org.hyperic.hq.product.EventQueueTrackPlugin"/>

<config name="eventqueues" type="global">
<option name="event.queue.track.host"
description="The MQ host machine"/>

<option name="event.queue.track.channel"
description="The MQ channel"/>

<option name="event.queue.track.port"
description="The MQ port"/>

<option name="event.queue.track.queuemanager"
description="The name of the queue manager"/>

<option name="event.queue.track.queue"
description="A comma-separated list of event queues you want to track"/>
</config>
</service>

<help name="Websphere Event Queue Tracking">
<![CDATA[
<p>
Some help information.
</p>
]]>
</help>
</plugin>

Looking at other plugins I think the idea is to override getConfigSchema so in my actual plugin class I have the following bit of code:

public ConfigSchema getConfigSchema(TypeInfo info, ConfigResponse config) {
log.info("Building config schema for EventQueueTrackPlugin");
ConfigSchema schema = super.getConfigSchema(info, config);
if (schema.getOptions().size() > 0) {
return schema; // from hq-plugin.xml
}

SchemaBuilder builder = new SchemaBuilder(config);
builder.add(PROP_HOST, "Websphere MQ host", "host");
builder.add(PROP_CHANNEL, "Websphere MQ channel", "channel");
builder.add(PROP_PORT, "Websphere MQ port", "port");
builder.add(PROP_QUEUEMANAGER, "Websphere MQ queue manager", "manager");
builder.add(PROP_QUEUE, "Websphere MQ event queue(s)", "eventqueue");

return builder.getSchema();
}

But this apparently isn't enough. I can deploy my plugin, register a new service of its type in the UI but I don't get to see my custom properties.

Any help?
0 Kudos
StevevandenBuys
Contributor
Contributor

We're again somewhat further now. I currently have a subclass of LogTrackPlugin and I've also created an empty subclass of ProductPlugin. The hq-plugin.xml ties these together as follows:

<?xml version="1.0"?>

<plugin name="eventqueuetrack" class="EventQueueTrackProductPlugin">
<classpath>
<include name="pdk/lib/mq/com.ibm.mqjms.jar"/>
<include name="pdk/lib/mq/com.ibm.mq.jar"/>
<include name="pdk/lib/mq/com.ibm.mq.pcf.jar"/>
<include name="pdk/lib/mq/com.ibm.mqbind.jar"/>
</classpath>

<server name="Websphere Event Queue Tracker" description="Dummy server for MQ event queue tracking">
<plugin type="log_track"
class="org.hyperic.hq.product.EventQueueTrackPlugin"/>

<config>
<option name="mqHost"
description="The MQ host machine"/>

<option name="mqChannel"
description="The MQ channel"/>

<option name="mqPort"
description="The MQ port"/>

<option name="mqQueuemanager"
description="The name of the queue manager"/>

<option name="mqQueue"
description="A comma-separated list of event queues you want to track"/>
</config>
</server>
</plugin>

When deploying this, I can successfully create a Server and set all the properties. However, when going back to the Monitor-view I keep getting the message that the configuration properties haven't been set and that I should set them. When I click on the provided link I'm taken to the edit properties page where my properties are already filled in! Looking at the source code I think that the InventoryHelper's isResourceConfigured-method returns false but I'm not sure why or how this can be corrected. The relevant code of my actual plugin is:

public class EventQueueTrackPlugin extends LogTrackPlugin {
private static Log log = LogFactory.getLog(EventQueueTrackPlugin.class.getName());

public static final String PROP_HOST = "mqHost";

public static final String PROP_CHANNEL = "mqChannel";

public static final String PROP_PORT = "mqPort";

public static final String PROP_QUEUEMANAGER = "mqQueuemanager";

public static final String PROP_QUEUE = "mqQueue";

public void configure(ConfigResponse config) throws PluginException {

super.configure(config);

// no concept of log levels in MQ events
setLogLevel(LOGLEVEL_INFO);

scanEventQueue();
}

public String getName() {
return "eventqueuetrack";
}

public ConfigSchema getConfigSchema(TypeInfo info, ConfigResponse config) {
ConfigSchema schema = super.getConfigSchema(info, config);

StringConfigOption option = new StringConfigOption(PROP_HOST, "The MQ host machine", "");
schema.addOption(option);

option = new StringConfigOption(PROP_CHANNEL, "The MQ channel", "");
schema.addOption(option);

option = new StringConfigOption(PROP_PORT, "The MQ port", "");
schema.addOption(option);

option = new StringConfigOption(PROP_QUEUEMANAGER, "The name of the queue manager", "");
schema.addOption(option);

option = new StringConfigOption(PROP_QUEUE, "A comma-separated list of event queues you want to trac", "");
schema.addOption(option);

return schema;
}
}
0 Kudos
dougm_hyperic
VMware Employee
VMware Employee

Hi Steve,

Looks like you're pretty far along.. regarding the Inventory Properties, which version of HQ are you developing against? You may just need to remove the getConfigSchema() method. The super.getConfigSchema call is pulling in the same properties (name="mq*") from hq-plugin.xml, could be the dups are throwing things off. Are there any metrics defined for your Event Queue Tracker?
0 Kudos
StevevandenBuys
Contributor
Contributor

Hello Doug,

I'm developing against version 3.1.0. I just removed the getConfigSchema() method but removal doesn't solve my problem (but neither does it have any additional side-effects so I guess it's not needed). There are no metrics for my tracker because I'm really only interested in the event queue messages. All I really want to do is create a custom subclass of LogTrackPlugin that can eventually be integrated in the Websphere plugin (seeing that my plugin would track the event queues of Websphere MQ that seems like the most logical place to put it). This means that the above hq-plugin.xml and EventQueueTrackProductPlugin are just there as a test harness to try and get the tracking plugin to work. Perhaps I should just try and put the EventQueueTrackPlugin in the Websphere plugin and see if that works better (because as far as I can tell my plugin is written in exactly the same style as for example the MxNotificationPlugin or the Log4JLogTrackPlugin or any of the other log tracking plugins).
0 Kudos
dougm_hyperic
VMware Employee
VMware Employee

Hi Steve,

On the Edit Configuration Properties page, do you see a checkbox to "Enable Log Tracking" ?
If not, you may just need to add the following even though your plugin does not provide any metrics:

<plugin type="measurement"
class="org.hyperic.hq.product.MeasurementPlugin"/>

You can also test your plugin from the command-line, see:
http://support.hyperic.com/confluence/display/DOCSHQ30/Invoking+Plugins+Standalone

For example:
java -jar pdk/lib/hq-product.jar -p eventqueuetrack -t "Websphere Event Queue Tracker" \
-m track -a log -DmqHost=localhost -DmqChannel=foo -DmqPort=nnnnn ...
0 Kudos
StevevandenBuys
Contributor
Contributor

Hello Doug,

thanks for the help but that didn't work either and due to time constraints and, honestly speaking, a serious lack of documentation (at least regarding plugin development) as well as an apparently relatively small community we have decided not to go forward with Hyperic HQ. Still, the product looks very promising so keep up the good work and perhaps we'll re-evaluate in a few years or so!
0 Kudos