datalogd.plugins.heartbeat_datasource module

class datalogd.plugins.heartbeat_datasource.HeartbeatDataSource(sinks=[], interval=1.0, counter=True, message={'id': 'heartbeat', 'type': 'config'})[source]

Bases: DataSource

Generate a regular heartbeat message for failsafe or keep-alive type purposes.

A basic message will be generated at regular intervals (default 1.0 second), controlled by the interval parameter. By default an integer counter will be appended to the message as the value field. The initial value for the counter can be set using the counter paramter, or set counter=False to disable.

The message can be set with the message parameter. To use the counter functionality, the message should be of a dictionary type.

Parameters:
  • interval – Time interval between heartbeat messages, in seconds.

  • counter – Append an integer counter to the message data.

  • message – Message to use as the heartbeat data.

generate_heartbeat()[source]

Generate the heartbeat message and send to any connected sinks.