jasonw_hyperic
Contributor
Contributor

Beginners question: How to implement my own monitorring jar as a plugin

Hi, there,

We just started to use Hyperic to monitor our distributed applications. So far it seems Hyperic is doing very well. Currently, we are using our own java application to monitor hundrens of mail servers. The availability report is generated and converted into a web page available to administrators. By briefly looking through some documents, I found that Hyperic
surports SMTP protocol. I am wonderring if I could rewrite my server testing application into a plugin. Because we are using hyperic to do the monitoring, there is no point to leave a seperate application doing the same thing that hyperic may even do better. Could someone here please tell me how to write the plugin? Any hints will be greatly appreciated.

Cheers,
Jason
0 Kudos
5 Replies
john_hyperic
Hot Shot
Hot Shot

Check out the plugin development center:
http://support.hyperic.com/confluence/display/DOCSHQ27/Plugin+Development+Center

Not knowing much about your application, I would say maybe the script plugin would work for you:
http://support.hyperic.com/confluence/display/DOCSHQ27/Script+Plugin

That type of plugin will have HQ execute a script on a regular basis. The script will output custom metrics and values like:
MetricOne=1
MetricTwo=2
AnyMetricName=5551

And HQ will store those metrics, chart them, display them, etc.
jasonw_hyperic
Contributor
Contributor

Thanks for the links, John. You are right. I can write a script to grab mail server availabilities from my application and use the script plugin to display them on Hyperic. But the main shortage of this approach is inefficiency.

According to the io device plugin example, (If I understand it correctly), for every metric the plugin collects, the script will be executed once. As my application needs to test hundreds of hosts(which means there are hundreds of metrics), imagine how slowly the monitoring process would be. Another issue is that the metrics(the list of hosts) should be obtained from a database at runtime, rather than sucking up from a xml config file.

So, is there any other alternatives? I am really stuck. BTW, does the plugin framework support threads?

Many thanks though, john.

Jasonw
0 Kudos
jasonw_hyperic
Contributor
Contributor

Ideally, I expect that the plugin could bring a new server type "MailHosts" into HQ under which there is a service "SmtpRelayHosts". The MailHosts server should be able to configure using "JDBC URL", "ACCOUNT", "PASSWORD" (in order to retrieve a list of hosts from a databse). Once configured, all of hosts will be listed as services under "SmtpRelayHosts". As I only care about the availability, so it will be the only metric collected. Basically, the monitoring structure is the same with PostgreSQL 8.0:

(PostgreSQL 8.0 is a server type. Users can define some services attached to the server. Once configured successfully and "auto-detect tables" enabled, all the postgres tables will be shown. )

I guess I have to write at least 2 types of plugins : measurement and autodetect. It might suggest that I should extend/implement some abstract classes/ interfaces.

This task seems to be a bit chanllenging to me. Any hints will be greatly appreciated!
I will keep you guys posted about my progress.

Cheers,
J

Message was edited by: jasonw
0 Kudos
jasonw_hyperic
Contributor
Contributor

It has been done. Just for in case Someone ran into the same problem, I post a few hints here.
To assign values to certain metrics(if it is not directly supported by the Hyperic API ), you need to create a MeasurementPlugin. That means a class which subclasses the measurementPlugin or its descendants. Overriding the getVaule(Metric) method will take you there. For instance,

public class TestMeasurementPlugin
extends MeasurementPlugin{
public double getValue(Metric metric){
if(metric is of interets){
return the collected vaule;
else return super.getValue(metric);
}
}
}
If there is a subclass of MeasurementPlugin which has something you need, it is handy to extend that class rather than the measurementPlugin. Say, if you need to fetch some value from a database query, you should extend JDBCMeasurementPlugin, which has several useful methods to take advantage of.

In order to auto-discover all the underlying services, you need to create a AutoServerDetector class, if you need to dynamically scan the agent's machine for the server, you can implements a couple of interefaces, like
public class MailRelayHostsServerDetector
extends ServerDetector
implements FileServerDetector,
RegistryServerDetector,
AutoServerDetector{
}

If you need to add new discovered services dynamically, override
protected List discoverServices(ConfigResponse config)

do something like List services = .... services.add("ServiceName").

Note: here ServiceName has to be exactly the same with the one defined in the .xml file, otherwise, nothing will happen and you are unlikely to get any wrong message!

Cheers,

J
0 Kudos
jasonw_hyperic
Contributor
Contributor

Mark as answered.
0 Kudos