VMware Cloud Community
chen39yi
Contributor
Contributor

Could any one take a look at my custom plugin jar

I learned from several built-in jar plugin and created my own.

But It did not work

Here is my plugin: I just created some dummy services instead of creating it based on database query.

public class MyDetector extends DaemonDetector{
private Log log = LogFactory.getLog("MyDetector");
protected List discoverServices(ConfigResponse configResponse) throws PluginException {
log.error("=====discoverServices");
log.warn("=====discoverServices");
log.info("=====discoverServices");
log.fatal("=====discoverServices");
List services = new ArrayList();
ServiceResource service = new ServiceResource();
service.setType("type1");
service.setName("service1");
service.setDescription("description");

return services;
}
}

below is part of my xml

<!-- tell the server to auto detect the service in the server-->
<property name="HAS_BUILTIN_SERVICES" value="true"/>


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


<!-- DaemonDetecor plugin-->
<plugin type="autoinventory" class="org.hyperic.hq.plugin.alertserver.MyDetector"/>


<!-- config defined by the sqlquery-plugin -->
<config include="sql"/>

I packed the class and xml into a jar strutured like built-in plugin

in log, I read some exception which could confirm the discoverService method got invoked.

But I did not see the service I created in the inventory in my server, which could be seen in Hyperic server
0 Kudos
2 Replies
chen39yi
Contributor
Contributor

class in jar*********************************************

public class MyDetector3 extends DaemonDetector{
private static final Log log = LogFactory.getLog(DaemonDetector.class.getName());

protected List discoverServices(ConfigResponse configResponse) throws PluginException {

log.error("====discoverServices33");
log.debug("====discoverServices33");
log.info("====discoverServices33");
log.warn("====discoverServices33");

List services = new ArrayList();
for(int i = 0; i < 5; i++){
ServiceResource service = new ServiceResource();
service.setName("servicename" + i);
service.setType("servicetype" + i);
services.add(service);
}
return services;
}
}

plugin xml*********************************
<plugin>

<server name="alert_server3">

<!-- default properties -->
<property name="jdbcUrl"
value="jdbc:mysql://192.168.22.73:3306/culg"/>
<property name="jdbcDriver" value="com.mysql.jdbc.Driver"/>
<property name="jdbcUser" value="root"/>
<property name="jdbcPassword" value="aicent"/>
<!-- tell the server to auto detect the service in the server-->
<property name="HAS_BUILTIN_SERVICES" value="true"/>


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


<!-- DaemonDetecor plugin-->
<plugin type="autoinventory" class="org.hyperic.hq.plugin.alertserver.MyDetector3"/>


<!-- config defined by the sqlquery-plugin -->
<config include="sql"/>


<!-- "sql:" domain required to proxy through sqlquery-plugin -->
<filter name="template" value="sql:${query}:${name}"/>

<!-- use filters for common sql -->
<filter name="count"
value="SELECT COUNT(*) FROM"/>

<metric name="Availability"
query="${count} customerinfo WHERE 1=1"
indicator="true"/>

<metric name="Number of Customers"
query="select count(*) from customerinfo"
indicator="true"/>

</server>
</plugin>

the log*****************************************

2009-04-25 12:59:28,751 INFO [Thread-1] [AutoinventoryCommandsServer] Autoinventory report successfully sent to server.
2009-04-25 12:59:30,580 INFO [Thread-1] [RuntimeAutodiscoverer] Running runtime autodiscovery for alert_server3
2009-04-25 12:59:30,607 ERROR [Thread-1] [DaemonDetector] ====discoverServices33
2009-04-25 12:59:30,608 INFO [Thread-1] [DaemonDetector] ====discoverServices33
2009-04-25 12:59:30,608 WARN [Thread-1] [DaemonDetector] ====discoverServices33
2009-04-25 12:59:30,618 INFO [Thread-1] [RuntimeAutodiscoverer] alert_server3 discovery took 0.01
0 Kudos
chen39yi
Contributor
Contributor

the log told me my discoverService method got invoked by agent.

but I could not see the autodiscovered service in the hyperic server ui. do i need to configure?

I have added the custom server into the platform
0 Kudos