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