[collectd] collectd for embedded, time tag

Denys Fedoryshchenko nuclearcat at nuclearcat.com
Thu Apr 23 12:14:37 CEST 2020

On 2020-04-23 12:21, Florian Forster wrote:
> Hi Denys,
> right now, the network plugin treats a zero time as an error and won't
> pass the metric on to the daemon. The "collectd.org/network" Go
> package doesn't appear to do this check.
> How does sleeping work on the ESP8266? Could you keep track of the
> time spent sleeping and increment the time accordingly, only
> synchronizing with an external time source every once in a while?

Unfortunately there is no reliable RTC onboard, the one exist doesn't 
well with deep sleep (it resets on wake up, probably chipset or SDK 
and even without deep_sleep it have a lot of problems with timekeeping,
it is drifting on cheap modules.
So only solution for timekeeping is NTP.
While not an issue on "mains" powered modules, on battery setup extra 
packets exchange causes significant drain in power budget.

And honestly, collectd protocol already looks way better for IP enabled 
than overhyped MQTT/CoAP, as they require not only time sync (for TLS),
but also TCP handshake, then TLS handshake, their own auth handshake and 
etc. etc.
While on collectd its easy to do "fire and forget" and it saves a lot of 
battery energy.

> I would in principle be open to changing (and documenting) the
> semantics so that "time == 0" means "fill in time when receiving". We
> might make this behavior a config option of the network plugin,
> though, as it may create consistency problems when using multiple
> servers.

I can try to write patch, for example:

Extending sockent_t by adding there uint8_t (or int) "options" 
where certain optional bits can be set.
So, for example bit 0 will be "ZERO_AS_CURRENT_TIME"

Then, maybe, it can be set in config as optional, third parameter for 
"Listen" socket.
Listen "ff18::efc0:4a42" "ZeroAsCurrentTime"

> Best regards,
> —octo
> On 2020-04-19 13:19, Denys Fedoryshchenko wrote:
>> Hi!
>> I wrote minimal collectd binary protocol implementation for
>> microcontroller ESP8266,
>> https://github.com/nuclearcat/collectd-embedded .
>> Whole point is to collect data from multiple battery sensors, and
>> collectd can save a lot of time, as it is udp and works as "fire and
>> forget".
>> But one problem remains, chip don't have RTC, so i have to NTP each
>> "wake up" to send "time" tag with timestamp.
>> Is there any hack to not send time, or send as zero or something, so
>> it will be marked by collectd automatically as N/NOW(), as in
>> plaintext protocol ?
>> I read wiki for binary protocol, checked sources, but quick search
>> didn't hinted me at anything.
>> Any help appreciated.
>> _______________________________________________
>> collectd mailing list
>> collectd at verplant.org
>> https://mailman.verplant.org/listinfo/collectd

More information about the collectd mailing list