VMware Cloud Community
roger_symonds
Enthusiast
Enthusiast

Hyperic Plugin that reads data from a CSV file?

Hi Guys,

I'm relatively new to Hyperic plugins and am trying to get my head around the whole thing.

I have written a basic plug-in that just executes the "Ping" command on windows or Unix, for the sake of witting a simple plug-in shell eg. the casing of a plug-in without much logic.

The current aim is to write a plug-in for a webapp, running in a Tomcat 5.5 container.
I considered writing a JMX MBean but this looks quite complicated, and above my understanding at this stage. So I would like to try writing a Hyperic plug-in that can read statistics from a CSV file (which I will get the webapp to generate and update at scheduled intervals eg. 5 min intevals etc.)

To start out I was hoping to find an example somewhere to help me out, and I managed to get a copy of the Zimbra plugin from here:
http://svn.hyperic.com/trunk/plugins/zimbra/?root=Hyperic+HQ

Looking through the plug-in's "hq-plugin.XML" file I noticed the line:
"<plugin type="collector" class="org.hyperic.hq.plugin.zimbra.ZimbraCollector"/>"

Looking at the page below:
http://support.hyperic.com/confluence/display/DOCSHQ31/Plugin+XML+Descriptor

I can only see 4 types of plug-in types available eg.
<config> Tag Attributes:
* type - The plugin type.
o product
o measurement
o control
o responsetime


Are there other plugin types that can be written that aren't documented? eg. collector etc.
Is this just a name that can be called anything, as long as it points to a java class that does something?

Can anyone help me out by providing comments, suggestions, tips, pointers, or links to useful documentation?

All help is really appreciated.

Regards,
Roger
0 Kudos
6 Replies
roger_symonds
Enthusiast
Enthusiast

I guess I am aiming to write a Product Plug-in eg.
http://support.hyperic.com/confluence/display/DOCSHQ31/Product+Plugin

Has anyone had any experience with writing one of these?
Can you point me to some examples?
0 Kudos
roger_symonds
Enthusiast
Enthusiast

Hi Guys,

Has anyone had any experience with writing one of these?
Can you point me to some examples?

What are the methods that are expected in a collector class?

XML defining the class to use
<plugin type="collector" class="org.hyperic.hq.plugin.zimbra.ZimbraCollector"/>

Does it just require a collect() method?
public void collect()


Any help or pointers are appreciated.

TIA,
Roger
0 Kudos
excowboy
Virtuoso
Virtuoso

Hi Roger,

if you write your values out to a CSV-file, you can use a script to parse the entries from it and convert them into Hyperic key-value format.
So I advise you to read this document:
http://support.hyperic.com/confluence/display/DOC/Script+Plugin

Cheers,
Mirko
roger_symonds
Enthusiast
Enthusiast

Thanks Mirko, I'll check it out!

I was thinking of trying a Measurement plugin using a custom ApplicationMeasurementPlugin.class file referenced from my hq-plugin.xml file.

In the ApplicationMeasurementPlugin.class file I would need a getValue() method to collect the metrics, which could read in the CSV file and parse it.

In the hq-plugin file I would define all the metrics I'm looking to get into HQ.


Would this also work? Or am I heading down the wrong path?
What are the advantages/disadvantages of Measurement vs Script plugins?

Thanks again,
Roger

Message was edited by: roger.symonds
0 Kudos
roger_symonds
Enthusiast
Enthusiast

I've created a Script Plugin (see below), but can't get it to work, I keep getting the error below. Can anyone help?


2008-01-21 20:39:22,921 ERROR [CommandDispatcher] Error while processing request
java.lang.IllegalArgumentException: File '%script%' does not exist
at org.hyperic.hq.product.ExecutableProcess.init(ExecutableProcess.java:154)
at org.hyperic.hq.product.Collector.getValue(Collector.java:460)
at org.hyperic.hq.product.MeasurementPlugin.getValue(MeasurementPlugin.java:442)
at org.hyperic.hq.product.MeasurementPluginManager.getPluginValue(MeasurementPluginManager.java:176)
at org.hyperic.hq.product.MeasurementPluginManager.getValue(MeasurementPluginManager.java:274)
at org.hyperic.hq.product.MeasurementPluginManager.getValue(MeasurementPluginManager.java:135)
at org.hyperic.hq.product.MeasurementPluginManager.getValue(MeasurementPluginManager.java:127)
at org.hyperic.hq.measurement.agent.server.MeasurementCommandsServer.getMeasurements(MeasurementCommandsServer.java:289)
at org.hyperic.hq.measurement.agent.server.MeasurementCommandsServer.dispatchCommand(MeasurementCommandsServer.java:467)
at org.hyperic.hq.agent.server.CommandDispatcher.processRequest(CommandDispatcher.java:112)
at org.hyperic.hq.agent.server.CommandListener.listenLoop(CommandListener.java:191)
at org.hyperic.hq.agent.server.AgentDaemon.start(AgentDaemon.java:679)
at org.hyperic.hq.agent.server.AgentDaemon$RunnableAgent.run(AgentDaemon.java:743)
at java.lang.Thread.run(Unknown Source)
2008-01-21 20:39:22,921 WARN [CommandListener] Error invoking method
org.hyperic.hq.agent.AgentRemoteException: java.lang.IllegalArgumentException: File '%script%' does not exist
at org.hyperic.hq.agent.server.CommandDispatcher.processRequest(CommandDispatcher.java:119)
at org.hyperic.hq.agent.server.CommandListener.listenLoop(CommandListener.java:191)
at org.hyperic.hq.agent.server.AgentDaemon.start(AgentDaemon.java:679)
at org.hyperic.hq.agent.server.AgentDaemon$RunnableAgent.run(AgentDaemon.java:743)
at java.lang.Thread.run(Unknown Source)
2008-01-21 20:39:36,625 INFO [CollectorThread] CollectorThread started
2008-01-21 20:40:01,703 ERROR [ScheduleThread] Metric Value not found: Query failed for n_tup_ins: An I/O error has occured while flushing the output - Exception: java.net.SocketException: Connection reset by peer: socket write error
Stack Trace:

java.net.SocketException: Connection reset by peer: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(Unknown Source)
at java.net.SocketOutputStream.write(Unknown Source)
at java.io.BufferedOutputStream.flushBuffer(Unknown Source)
at java.io.BufferedOutputStream.flush(Unknown Source)
at org.postgresql.core.PGStream.flush(PGStream.java:411)
at org.postgresql.core.QueryExecutor.sendQueryV3(QueryExecutor.java:337)
at org.postgresql.core.QueryExecutor.executeV3(QueryExecutor.java:121)
at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:100)
at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:43)
at org.postgresql.jdbc1.AbstractJdbc1Statement.execute(AbstractJdbc1Statement.java:517)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:50)
at org.postgresql.jdbc1.AbstractJdbc1Statement.executeQuery(AbstractJdbc1Statement.java:233)
at org.hyperic.hq.product.JDBCMeasurementPlugin.getQueryValue(JDBCMeasurementPlugin.java:249)
at org.hyperic.hq.product.JDBCMeasurementPlugin.getValue(JDBCMeasurementPlugin.java:135)
at org.hyperic.hq.product.MeasurementPluginManager.getPluginValue(MeasurementPluginManager.java:176)
at org.hyperic.hq.product.MeasurementPluginManager.getValue(MeasurementPluginManager.java:228)
at org.hyperic.hq.measurement.agent.server.ScheduleThread.getValue(ScheduleThread.java:297)
at org.hyperic.hq.measurement.agent.server.ScheduleThread.run(ScheduleThread.java:392)
at java.lang.Thread.run(Unknown Source)
End of Stack Trace



Used the following as a reference:
http://support.hyperic.com/confluence/display/DOC/Script+Plugin


Below are my files, hq-plugin.xml which runs a script (Windows bat file), all the bat file does, is reads a data file. My aim is to plot what is in the data file in Hyperic HQ.

NOTE: There is also a plugin service which will ping a URL (this part works successfully)


Do I need to get the availability of the something for the measurement plugin to work?
I tried to get the availability of the hq-server and use this as it will always be running when my plugin is 🙂

Any ideas why I get this error: File '%script%' does not exist??

If you have any questions, please feel free to let me know and I will provide more information.

TIA,
Roger



hq-plugin.xml
---------------------

<?xml version="1.0"?>

<!-- Define the type of plugin this is, and which classes implement each plugin type -->
<plugin>
<server name="Script Reader">

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

<property name="service_name" value="hq-server.exe"/>

<config>
<option name="script" description="Data Collector script" default="C:\Hyperic\script.bat"/>
</config>

<filter name="template" value="exec:file=%script%"/>
<metric name="Script Data" category="PERFORMANCE" indicator="true" template="${template}:w/s"/>
<metric name="Availability" template="win32:Service=${service_name}:Availability" indicator="true"/>



<service name="Ping Service">
<config>
<option name="ping" description="Ping program" default="C:\WINDOWS\system32\ping.exe"/>
<option name="hostname" description="Hostname" default="localhost"/>
<option name="switch" description="Count switch" default="-n"/>
<option name="count" description="Count" default="3" type="int"/>
</config>


<filter name="templatePing" value="exec:file=%ping%,args=%switch% %count% %hostname%:${alias}"/>
<metric name="Availability" indicator="true"/>
<metric name="Response Time" units="ms" indicator="true"/>

</service>


</server>
</plugin>



C:\Hyperic\script.bat
---------------------------------

TYPE datafile.csv


C:\Hyperic\datafile.csv
---------------------------------

rrqm/s=0.02
0 Kudos
roger_symonds
Enthusiast
Enthusiast

I fixed this by putting the script in the directory C:\Program Files\Hyperic\agent-3.2.0\ as I found it seemed to have trouble if I specified a different path to the script.

Not sure why though? 🙂
0 Kudos