From mem0z at outlook.com Sun Jul 14 16:38:07 2024 From: mem0z at outlook.com (Bowen Jiang) Date: Sun, 14 Jul 2024 14:38:07 +0000 Subject: [collectd] Two newbie questions using the Lua plugin Message-ID: Hi, all I’m brand new to collectd, RRDtool, and mailing lists. If you don’t mind newbie questions, here I come. 1. How best to dispatch multiple values using the Lua plugin? The documentation I could find only gave an example of dispatching 1 value at a time, so to parse the following readings on an OpenWrt device, +QTEMP:"qfe_wtr_pa0","58" +QTEMP:"qfe_wtr_pa1","59" +QTEMP:"qfe_wtr_pa2","55" +QTEMP:"qfe_wtr_pa3","54" +QTEMP:"aoss0-usr","56" +QTEMP:"mdm-q6-usr","58" +QTEMP:"ipa-usr","57" +QTEMP:"cpu0-a7-usr","56" +QTEMP:"mdm-5g-usr","56" +QTEMP:"mdm-vpe-usr","56" +QTEMP:"mdm-core-usr","56" +QTEMP:"xo-therm-usr","57" +QTEMP:"sdx-case-therm-usr","57" OK I pieced together this Lua script: function read() serial = io.open("/dev/ttyUSB3", "a+") serial:write("AT+QTEMP\r\n") local result = { plugin = 'lua', plugin_instance = 'rm500q-gl', type = 'temperature', } while true do local line = serial:read() if string.match(line, "^OK") or string.match(line, "^ERROR") or line == nil then break end local sensor, temp = string.match(line, "^\+QTEMP:\"(.+)\",\"(.+)\"") if sensor ~= nil then result['type_instance'] = sensor result['values'] = { temp } collectd.dispatch_values(result) end end serial:close() return 0 end collectd.register_read(read) Is there a way to send all of them at once since the plugin expects a "values" field? 2. The above code works, but should the numbers in the RRD database be off by a bit? An example dumped from temperature-cpu0-a7-usr.rrd shows that integers are not integers anymore: 0001 30 1720966705 value GAUGE 60 NaN NaN UNKN 1.3250000000e+03 0 AVERAGE 1 1.0000000000e-01 NaN 0 ... 5.3000000000e+01 5.3333333333e+01 5.5000000000e+01 5.5000000000e+01 5.4833333333e+01 5.4000000000e+01 5.3833333333e+01 5.3000000000e+01 5.3000000000e+01 5.3166666667e+01 5.4333333333e+01 5.6000000000e+01 5.6166666667e+01 ... The RRDtool documentation explained normalizing and consolidating. What can I do to skip them in this case? Best Regards, Bowen -------------- next part -------------- An HTML attachment was scrubbed... URL: