MikeTkachuk / Ping_listener

0 stars 1 forks source link

Ping_listener

A backend that sends emails in case ping is not received within the specified time

Server config template

Frequency is refered to as a delay in seconds between processing loops.

{
'server_root':(str) Deprecated. Gets overwritten during initialization 'https://example.net' a prefix string
to insert into logs link in the alert emails;
'base_frequency': (scalar>=0) a delay between the steps of a ping absence listener;
'email_processing_frequency': (scalar>=0) a delay before the next processing of the emails queue;
'recipient': (str or list(str)) representing the recipient email or list of emails;
'users': a dict of pairs (username:(unique str),user config described below)
}

User config template

{
'monitor': (bool) if false never sends emails;
'max_sleep': (scalar>=0) max delay between pings in seconds;
'device_email': (str or list(str)) Optional. Represents a device-specific email or list of emails.
Defaults to the 'recipient' field of a server config; 'email_frequency': (scalar>=0) min delay between subsequent emails for a particular user; 'refresh_on_ping_restored' : (bool-like) Optional defaults to True. A ping made after the last email sent refreshes the email_frequency counter
}

Required environment variables


Requests

Ping

A ping should be made at /ping via GET request
Args:

Returns:
(str) datetime formated as '%y/%m/%d %H:%M:%S'.
For more info about the notation see https://docs.python.org/3/library/datetime.html?highlight=strf#strftime-strptime-behavior

Logs

A ping should be made at /logs via GET request
Args:

Returns:
A list of strings of format '%H:%M:%S', where each entry is the
time of a ping for a particular user on the specified date.