Module cloudi_service_health_check

Health Check CloudI Service

Each interval, do a DNS lookup of a hostname (if a hostname was provided) and check the health of each IP address.

.

Copyright © 2022 Michael Truog

Version: 2.0.5 Oct 11 2022 22:10:05 ------------------------------------------------------------------------

Behaviours: cloudi_service.

Authors: Michael Truog (mjtruog at protonmail dot com).

Description

Health Check CloudI Service

Each interval, do a DNS lookup of a hostname (if a hostname was provided) and check the health of each IP address.

Any DNS failure can have custom functions for the event with the dns_failure function and/or the dns_restored function. The DNS failure will only occur once for each hostname provided and old IP address information will still be used for the health check.

The health check uses either a TCP port number or a single ping request to each of the IP addresses associated with the hostname. If any of the IP addresses had a failure the host's health_failed boolean will be set to true. The availability and downtime of a host is based on whether all IP addresses pass the health check.

Any TCP health check failure can have custom functions for the event with the tcp_failure function and/or the tcp_restored function. A tcp_test function custom function can be provided if the TCP socket needs additional health check criteria.

Any ping health check failure can have custom functions for the event with the ping failure function and/or the ping_restored function.

All _failure custom functions are provided with the failure Reason as a parameter. All _restored custom functions are provided with the native monotonic time when the failure occurred (TimeFailure) and when the restore occurred (TimeRestored) to provide the event duration.

A dns_ip_added function can be provided for execution when an IP address is added after a successful DNS lookup response. A dns_ip_removed_healthy function and/or a dns_ip_removed_failed function can be provided for execution when an IP address is removed due to a successful DNS lookup response. DNS-based load balancing may cause excessive execution of these functions.

Data Types

dns_failure()

dns_failure() = fun((Name::hostname(), Reason::atom()) -> ok)

dns_ip_added()

dns_ip_added() = fun((Name::hostname(), IP::inet:ip_address()) -> ok)

dns_ip_removed_failed()

dns_ip_removed_failed() = fun((Name::hostname(), IP::inet:ip_address(), TimeFailure::cloudi_timestamp:native_monotonic(), TimeRemoved::cloudi_timestamp:native_monotonic()) -> ok)

dns_ip_removed_healthy()

dns_ip_removed_healthy() = fun((Name::hostname(), IP::inet:ip_address()) -> ok)

dns_restored()

dns_restored() = fun((Name::hostname(), TimeFailure::cloudi_timestamp:native_monotonic(), TimeRestored::cloudi_timestamp:native_monotonic()) -> ok)

hostname()

hostname() = nonempty_string()

dns name or ip address

interval()

interval() = 1..4294967

ping_failure()

ping_failure() = fun((Name::hostname(), IP::inet:ip_address(), Reason::string()) -> ok)

ping_restored()

ping_restored() = fun((Name::hostname(), IP::inet:ip_address(), TimeFailure::cloudi_timestamp:native_monotonic(), TimeRestored::cloudi_timestamp:native_monotonic()) -> ok)

tcp_failure()

tcp_failure() = fun((Name::hostname(), IP::inet:ip_address(), Port::tcp_port(), Reason::atom()) -> ok)

tcp_port()

tcp_port() = 1..65535

tcp_restored()

tcp_restored() = fun((Name::hostname(), IP::inet:ip_address(), Port::tcp_port(), TimeFailure::cloudi_timestamp:native_monotonic(), TimeRestored::cloudi_timestamp:native_monotonic()) -> ok)

tcp_test()

tcp_test() = fun((Socket::gen_tcp:socket(), Timeout::1..4294967295) -> ok | {error, atom()})

Function Index

cloudi_service_handle_info/3
cloudi_service_handle_request/11
cloudi_service_init/4
cloudi_service_terminate/3

Function Details

cloudi_service_handle_info/3

cloudi_service_handle_info(X1, State, Dispatcher) -> any()

cloudi_service_handle_request/11

cloudi_service_handle_request(RequestType, Name, Pattern, RequestInfo, Request, Timeout, Priority, TransId, Source, State, Dispatcher) -> any()

cloudi_service_init/4

cloudi_service_init(Args, Prefix, Timeout, Dispatcher) -> any()

cloudi_service_terminate/3

cloudi_service_terminate(Reason, Timeout, State) -> any()


Generated by EDoc