[collectd] Queries with `sum(something) as this' don't work on dbi plugin (SQLServer)
danielhilst at gmail.com
Tue Apr 2 21:41:28 CEST 2013
On 02-04-2013 16:31, Daniel Hilst wrote:
> On 02-04-2013 12:19, Daniel Hilst Selli wrote:
>> I'm facing this error
>> [2013-04-02 12:13:21] [error] dbi plugin: Column `log_reads': Don't know
>> how to handle source type 4.
>> [2013-04-02 12:13:21] [error] dbi plugin: cdbi_read_database_query
>> (MSSQLServer, teste_query): cdbi_result_get_field (1) failed.
>> While using this dbi block
>> <Plugin dbi>
>> <Query "teste_query">
>> Statement "select sum(total_logical_reads) as log_reads
>> from sys.dm_exec_query_stats"
>> Type "gauge"
>> ValuesFrom "log_reads"
>> <Database "MSSQLServer">
>> Driver "freetds"
>> Hostname "orisnet.verzani.com.br"
>> DriverOption "host" "192.168.5.18"
>> DriverOption "username" "SA"
>> DriverOption "password" "Paxazx01"
>> Query "teste_query"
>> The problem is with things like this `sum(something) as this' I just
>> can't get it working.. The query works fine on SSMS and retruns only one
>> line and one column, Any idea?
>> PS: I'm trying to monitor the reads/writes and worker time on MS
> I track the problem...
> This message
> 'dbi plugin: Column `log_reads': Don't know how to handle source type 4'
> Comes from here . Seems that libdbi is returning something unexpected
> by dbi plugin.
> The type for stands for DBI_TYPE_BINARY here  line 114
>  https://github.com/collectd/collectd/blob/master/src/dbi.c#L132
> line 114
> So, I think, SUM() would return integer types, but for libdbi, don't,
> I'm digging deeper on this..
Yeap, the problem is on SQLServer returning binary for SUM().. so.. the
solution is use CAST(), urgh..
select cast(sum(total_logical_reads) as int) as log_reads from
Follow the white rabbit!
More information about the collectd