fftools.healthchecks

class fftools.healthchecks.HealthChecks(url: str, path: str, ping_key: str | None = None, user_agent: str | None = None, create: bool = False)[source]

Bases: object

ping healthchecks.

you can use <HOSTNAME> in the path for the formatted hostname of the device.

Parameters:
  • url (str)

  • path (str)

  • ping_key (str | None)

  • user_agent (str | None)

  • create (bool)

__init__(url: str, path: str, ping_key: str | None = None, user_agent: str | None = None, create: bool = False) None[source]

Init the healthchecks api.

Parameters:
  • url (str) – base url of the healthchecks instance.

  • path (str) – ping path. full path if ping_key is not used, else only the part after the ping_key.

  • ping_key (str | None) – ping key to use.

  • user_agent (str | None) – custom user-agent to set for requests.

  • create (bool) – set ?create=1 to the ping url parameters

Return type:

None

exit_code(exit_code: str | int, message: str | None = None) tuple[int, str][source]

Ping with status: exit_code.

send the exit code of the program to healthchecks.

Parameters:
  • exit_code (str | int) – exit code to report.

  • message (str | None) – message to add to ping body.

Returns:

A tuple with (http response code, http response body).

Return type:

tuple[int, str]

fail(message: str | None = None) tuple[int, str][source]

Ping with status: fail.

fails the current job.

Parameters:

message (str | None) – message to add to ping body.

Returns:

A tuple with (http response code, http response body).

Return type:

tuple[int, str]

log(message: str) tuple[int, str][source]

Ping with status: log.

sends a log to the current job. does not stop or fail the job.

Parameters:

message (str) – message to add to ping body.

Returns:

A tuple with (http response code, http response body).

Return type:

tuple[int, str]

start(message: str | None = None) tuple[int, str][source]

Ping with status: start.

starts the timer of the healthchecks job.

Parameters:

message (str | None) – message to add to ping body.

Returns:

A tuple with (http response code, http response body).

Return type:

tuple[int, str]

success(message: str | None = None) tuple[int, str][source]

Ping with status: success.

used to end the job or signal success.

Parameters:

message (str | None) – message to add to ping body.

Returns:

A tuple with (http response code, http response body).

Return type:

tuple[int, str]