VMware Cloud Community
tconrad_hyperic
Contributor
Contributor

SQL Plugin returning a String

I'm new to Hyperic and am trying to write a plugin that makes sql queries. I need a couple of examples of plugins that return strings instead of a real number. My plugin is reproduced below. Everything works except the last sql query (select algorithmname from algorithm where algorithmid=3) because this returns a string. I wasn't able to get the script to print the string. Anyway, I think two or three good examples of plugins that print strings from sql queries will really help me. Thanks a million.


<!-- ***************** A sample plugin ***************** -->

<plugin>
<service name="Oracle Test">

<!-- config defined by the sqlquery-plugin -->
<!-- might be able to use the <config include="sql"/> tag
in place of the following -->
<config>
<option name="jdbcDriver" description="JDBC Driver Class Name" default="oracle.jdbc.driver.OracleDriver"/>
<option name="jdbcUrl" description="JDBC Connection URL" default="jdbc:oracle:thin://localhost:1521"/>
<option name="jdbcUser" description="JDBC UserName" default="NDE_B2P3"/>
<option name="jdbcPassword" type="hidden" optional="false" description="JDBC Password" default="welcome"/>
<option name="script" description="Print Script" default="/opt/hyperic/hq-plugins/printstuff"/>
</config>

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

<!-- template for printing
<filter name="print_template" value="exec:file=%script%"/> -->
<filter name="print_template" value="exec:file=%script%,args=%device%"/>

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

<metric name="Number of Product Descriptions"
query="${count} PRODUCTDESCRIPTION"
indicator="true"/>

<metric name="Number of Production Rules"
query="${count} PRODUCTIONRULE"
indicator="true"/>

<metric name="Number of Algorithms"
query="${count} ALGORITHM"
indicator="true"/>

<metric name="Return an Algorithm Name"
query="select algorithmname from algorithm where algorithmid=3"
indicator="true"
template="${print_template}"/>

</service>
</plugin>
0 Kudos
0 Replies