This section details built in Lua functions that are meant to be used for host health checks. Note that these functions rely on data supplied by metric agents detailed in Cache hardware metrics: monitoring and routing. Make sure cache hardware metrics are supplied to the router before using any of these functions.
cpu_load_ok()
The function accepts an optional argument table with the following keys:
hostname
: The name of the host. Defaults to the hostname of the
selected host if not provided.cpu_load5_limit
: The acceptable limit for the 5-minute CPU
load. Defaults to 0.9 if not provided.The function returns 1 if the five minute CPU load average is below their respective limits, and 0 otherwise.
cpu_load_ok()
cpu_load_ok({hostname = "custom_host"})
cpu_load_ok({cpu_load5_limit = 0.8})
cpu_load_ok({hostname = "custom_host", cpu_load5_limit = 0.8})
memory_usage_ok()
The function accepts an optional argument table with the following keys:
hostname
: The name of the host. Defaults to the hostname of the
selected host if not provided.memory_usage_limit
: The acceptable limit for the memory usage.
Defaults to 0.9 if not provided.The function returns 1 if the memory usage is below the limit, and 0 otherwise.
memory_usage_ok()
memory_usage_ok({hostname = "custom_host"})
memory_usage_ok({memory_usage_limit = 0.7})
memory_usage_ok({hostname = "custom_host", memory_usage_limit = 0.7})
interfaces_online()
The function accepts an argument table with the following keys:
interfaces
: A string or a table of strings representing the
network interfaces to check.hostname
: The name of the host. Defaults to the hostname of the
selected host if not provided.The function returns 1 if all the specified interfaces are online, and 0 otherwise.
interfaces_online({interfaces = "eth0"})
interfaces_online({interfaces = {"eth0", "eth1"}})
interfaces_online({hostname = "custom_host", interfaces = "eth0"})
interfaces_online({hostname = "custom_host", interfaces = {"eth0", "eth1"}})
health_check()
The function accepts an optional argument table with the following keys:
interfaces
: A string or a table of strings representing the
network interfaces to check.hostname
: The name of the host. Defaults to the hostname of the
selected host if not provided.cpu_load5_limit
: The acceptable limit for the 5-minute CPU
load. Defaults to 0.9 if not provided.memory_usage_limit
: The acceptable limit for the memory usage.
Defaults to 0.9 if not provided.The function returns 1 if all the specified interfaces are online, and 0 otherwise.
health_check({interfaces = "eths0"})
health_check({hostname = "custom_host", interfaces = "eths0"})
health_check({cpu_load5_limit = 0.7, memory_usage_limit = 0.8, interfaces = "eth0"})
health_check({hostname = "custom_host", cpu_load5_limit = 0.7, memory_usage_limit = 0.8, interfaces = {"eth0", "eth1"}})