JdbcCollector can't handle multiple columns with the same name in a single jdbc-collection

Description

When configuring a jdbc-collection for the JdbcCollector, column names must be unique over all queries.

Thus, for queries of this type (needed for MySQL 5.0.x), the values are always persisted in the last mentiones jrb-file (jdbc-datacollection-config.xml):

<queries>
<query name="Uptime" ifType="all" >
<statement>
<queryString>show global status like 'Uptime'</queryString>
</statement>
<columns>
<column name="Value" data-source-name="Uptime" alias="MyUptime" type="GAUGE"/>
</columns>
</query>
<query name="Bytes_received" ifType="all" >
<statement>
<queryString>show global status like 'Bytes_received'</queryString>
</statement>
<columns>
<column name="Value" data-source-name="Bytes_received" alias="MyBytesReceived" type="COUNTER"/>
</columns>
</query>

The Uptime value will be tried to persist in Bytes_received.jrb, along with the real Bytes_received value.

I realize the JdbcCollector is not a part of the "normal" distribution of OpenNMS but it find it very useful and would like to propose the patch I am using to make it work for us. Also, the Component I selected for this Bug is obviously wrong, I had to choose one and chose the one I considered most closely related.

It consists in storing the configuration for the attribType configuration with the data-source-name as a key, falling back to the column name when no data-source-name is specified in the configuration. Part of the code was already in place and seemed to be intended for this use, I just made a small addition.

If this does not contradict intended use for the JdbcCollector, please do consider including the patch for source/features/jdbc-collector/src/main/java/org/opennms/netmgt/collectd/JdbcCollector.java . I made the patch against 1.8.3, but 1.9.1-1 of today seems to give the same result.

Environment

Operating System: Linux Platform: HP

Acceptance / Success Criteria

None

Attachments

1
  • 20 Sep 2010, 11:36 AM

Lucidchart Diagrams

Activity

Michael Michael September 20, 2010 at 11:36 AM

Created an attachment (id=1092)
Proposed patch using the dsname as attribTypeList key instead of the column name, when avaliable

Details

Assignee

Reporter

Labels

Affects versions

Priority

PagerDuty

Created September 20, 2010 at 11:35 AM
Updated September 21, 2021 at 6:24 PM

Flag notifications