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:

<!-- Round Robin Database Dump -->
<rrd>
        <version> 0001 </version>
        <step> 30 </step> <!-- Seconds -->
        <lastupdate> 1720966705 </lastupdate> <!-- 2024-07-14 22:18:25 CST -->

        <ds>
                <name> value </name>
                <type> GAUGE </type>
                <minimal_heartbeat> 60 </minimal_heartbeat>
                <min> NaN </min>
                <max> NaN </max>

                <!-- PDP Status -->
                <last_ds> UNKN </last_ds>
                <value> 1.3250000000e+03 </value>
                <unknown_sec> 0 </unknown_sec>
        </ds>

<!-- Round Robin Archives -->
        <rra>
                <cf> AVERAGE </cf>
                <pdp_per_row> 1 </pdp_per_row> <!-- 30 seconds -->
                <xff> 1.0000000000e-01 </xff>

                <cdp_prep>
                        <ds><value> NaN </value>  <unknown_datapoints> 0 
</unknown_datapoints></ds>
                </cdp_prep>
                <database>
...
                        <!-- 2024-07-14 22:18:00 CST / 1720966680 --> <row><v> 
5.3000000000e+01 </v></row>
                        <!-- 2024-07-14 22:18:30 CST / 1720966710 --> <row><v> 
5.3333333333e+01 </v></row>
                        <!-- 2024-07-14 22:19:00 CST / 1720966740 --> <row><v> 
5.5000000000e+01 </v></row>
                        <!-- 2024-07-14 22:19:30 CST / 1720966770 --> <row><v> 
5.5000000000e+01 </v></row>
                        <!-- 2024-07-14 22:20:00 CST / 1720966800 --> <row><v> 
5.4833333333e+01 </v></row>
                        <!-- 2024-07-14 22:20:30 CST / 1720966830 --> <row><v> 
5.4000000000e+01 </v></row>
                        <!-- 2024-07-14 22:21:00 CST / 1720966860 --> <row><v> 
5.3833333333e+01 </v></row>
                        <!-- 2024-07-14 22:21:30 CST / 1720966890 --> <row><v> 
5.3000000000e+01 </v></row>
                        <!-- 2024-07-14 22:22:00 CST / 1720966920 --> <row><v> 
5.3000000000e+01 </v></row>
                        <!-- 2024-07-14 22:22:30 CST / 1720966950 --> <row><v> 
5.3166666667e+01 </v></row>
                        <!-- 2024-07-14 22:23:00 CST / 1720966980 --> <row><v> 
5.4333333333e+01 </v></row>
                        <!-- 2024-07-14 22:23:30 CST / 1720967010 --> <row><v> 
5.6000000000e+01 </v></row>
                        <!-- 2024-07-14 22:24:00 CST / 1720967040 --> <row><v> 
5.6166666667e+01 </v></row>
...

The RRDtool documentation explained normalizing and consolidating. What can I 
do to skip them in this case?

Best Regards,
Bowen
_______________________________________________
collectd mailing list
collectd@verplant.org
https://mailman.verplant.org/listinfo/collectd

Reply via email to