Package: anycast-healthchecker
A healthchecker for Anycasted services.ContentsIntroductionWhat is AnycastHow anycast-healthchecker worksConfiguring anycast-healthcheckerIPv6 supportBird configurationbird.confmatch-route.confanycast-prefixes.confConfiguring anycast-healthcheckerDEFAULT sectionDaemon sectionPrometheus exporterHow to configure loggingJSON loggingConfiguring checks for servicesStarting anycast-healthcheckerSystemd and SysVinit integrationNagios checkInstallationReleaseDevelopmentTestingContributorsLicensingAcknowledgementContactsIntroductionanycast-healthcheckermonitors a service by doing periodic health checks and, based on the result, instructingBirddaemon to either advertise or withdraw the route to reach it. As a result Bird will only advertise routes for healthy services. Routes for both IPv4 and IPv6 addresses are supported.Bird must be configured in a certain way to interface properly with anycast-healthchecker. The configuration is detailed later in this document.anycast-healthchecker is a Python program, which runs in foreground and uses threading to run multiple service checks in parallel.
In older versions ( < 0.8.0 ), anycast-healthchecker used thedaemonlibrary to implement a well-behaved Unix daemon process. This changed when 0.8.0 was released and the daemonization of the process is now a task of systemd.What is AnycastAnycast is a network addressing scheme where traffic from a sender has more than one potential receivers, but only one of them receives it.
Routing protocols decide which one of the potential receivers will actually receive traffic, according to the topology of the network. The main attribute contributing to this decision is the cost of the network path between a sender and a receiver.Cost is a protocol specific value (usually an integer) that has meaning only within the domain of the protocol itself, and it is used as a metric of distance.
Routing protocols provide default values for common topologies (BGPassociates the cost of a path with the number of autonomous systems between the sender and the receiver,OSPFcalculates the default cost based on the bandwidth of links), but its main use is to allow administrative control over traffic flow by specifying a cost according to business needs.The closest receiver to a sender always receives the traffic; this changes only if something changes on the network, i.e. another receiver with a better path to the sender shows up or the current receiver disappears. If multiple receivers share the same distance from the sender, more than one might receive traffic, depending on how the routing protocol is configured.The three pictures below show how traffic is routed between a sender and multiple potential receivers when something changes on network. In this example BGP routing protocol is used:These potential receivers useBGPorOSPFand simultaneously announce the same destination IP address from different places on the network. Due to the nature of Anycast, receivers can be located on any location across a global
network infrastructure.Anycast doesn’t balance traffic, as only one receiver attracts traffic from senders. For instance, if there are two receivers announcing the same destination IP address in different locations, traffic will be distributed between these two receivers unevenly, as senders can be spread across the network in an uneven way.Anycast is being used as a mechanism to switch traffic between and within data-centers for the following main reasons:the switch of traffic occurs without the need to enforce a change on clientsIn case of a service failure in one location, traffic to that location will be switched to another data-center without any manual intervention and, most importantly, without pushing a change to clients, which you don’t have always
control on.the switch happens within few millisecondsThe same technology can be used for balancing traffic usingEqual-Cost Multi-Path.ECMP routing is a network technology where traffic can be routed over multiple paths. In the context of routing protocols, path is the route a packet has to take in order to be delivered to a destination. Because these multiple paths share the same cost, traffic is balanced across them.This grants the possibility to perform traffic load-balancing across multiple servers. Routers distribute traffic in a deterministic fashion, usually by selecting the next hop and looking at the following four properties of IP packets:source IPsource PORTdestination IPdestination PORTEach unique combination of these four properties is called network flow. For each different network flow a different destination is selected so that traffic is evenly balanced across all servers. These nodes run an Internet Routing software in the same way as in the Anycast case, but with the major difference that all servers receive traffic at the
same time.The main characteristic of this type of load-balancing is that it is stateless. Router balances traffic to a destination IP address based on the quadruple network flow without the need to understand and inspect protocols above Layer3.
As a result, it is very cheap in terms of resources and very fast at the same time. This is commonly advertised as traffic balancing at “wire-speed”.anycast-healthcheckercan be utilized in Anycast and ECMP environments.How anycast-healthchecker worksThe current release of anycast-healthchecker supports only the Bird daemon, which has to be configured in a specific way. Therefore, it is useful to explain very briefly how Bird handles advertisements for routes.Bird maintains a routing information base (RIB) and various protocols import/export routes to/from it. The diagram below illustrates how Bird advertises IP routes, assigned on the loopback interface, to the rest of the network using BGP protocol. Bird can also import routes learned via BGP/OSPF protocols, but this part of the routing process is irrelevant to the functionality of anycast-healthchecker.A route is always associated with a service that runs locally on the box. The Anycasted service is a daemon (HAProxy, Nginx, Bind etc) that processes incoming traffic and listens to an IP (Anycast Service Address) for which a route exists in the RIB and is advertised by Bird.As shown in the above picture, a route is advertised only when:The IP is assigned to the loopback interface.directprotocol from Bird imports a route for that IP in the RIB.BGP/OSPF protocols export that route from the RIB to a network peer.The route associated with the Anycasted service must be either advertised or withdrawn based on the health of the service, otherwise traffic will always be routed to the local node regardless of the status of the service.Bird providesfilteringcapabilities with the help of a simple programming language. A filter can be used to either accept or reject routes before they are exported from the RIB to the network.A list of IP prefixes (<IP>/<prefix length>) is stored in a text file. IP prefixes thatare notincluded in the list are filtered-out andare notexported from the RIB to the network. The white-list text file is sourced by Bird upon startup, reload and reconfiguration. The following diagram illustrates how this technique works:This configuration logic allows a separate process to update the list by adding or removing IP prefixes and trigger a reconfiguration of Bird in order to advertise or withdraw routes.anycast-healthcheckeris that separate process. It monitors Anycasted services and, based on the status of the health checks, updates the list of IP prefixes.Bird does not allow the definition of a list with no elements: if that happens Bird will produce an error and refuses to start. Because of this, anycast-healthchecker makes sure that there is always an IP prefix in the list, seedummy_ip_prefixanddummy_ip6_prefixsettings inDaemon section.Configuring anycast-healthcheckerBecause anycast-healthchecker is very tied with with Bird daemon, the configuration of Bird has been explained first. Next, the configuration of anycast-healthchecker (including the configuration for the health checks) is covered and, finally, the options for invoking the program from the command line will be described.IPv6 supportIPv4 and IPv6 addresses are supported by the Bird Internet Routing Daemon project by providing a different daemon per IP protocol version, bird for IPv4 and bird6 for IPv6. This implies that configuration files are split as well, meaning that you can’t define IPv6 addresses in a configuration and source it by the IPv4 daemon.Bird configurationThe logic described inHow anycast-healthchecker workscan be accomplished by configuring:anincludestatement to source other configuration files inbird.confa function,match_route, as an export filter for the routing
protocol (BGP or OSPF)a list of IP prefixes for routes which allowed to be exported by Birdanycast-healthcheckerdoes notinstall any of the aforementioned files.bird.confThe most important parts are the linesinclude"/etc/bird.d/*.conf";andexport wherematch_route();. The former statement causes inclusion of other configuration files while the latter forces all routes to pass from thematch_routefunction before they are exported. BGP protocol is used in the below example but OSPF protocol can be used as well:include "/etc/bird.d/*.conf";
protocol device {
    scan time 10;
}
protocol direct direct1 {
    interface "lo";
        export none;
        import all;
}
template bgp bgp_peers {
    import none;
    export where match_route();
    local as 64815;
}
protocol bgp BGP1 from bgp_peers {
    disabled no;
    neighbor 10.248.7.254 as 64814;
}match-route.confmatch-route.conffile configures thematch_routefunction, which performs the allow and deny of IP prefixes by looking at the IP prefix of the route in a list and exports it if it matches entry:function match_route()
{
    return net ~ ACAST_PS_ADVERTISE;
}This is the equivalent function for IPv6:function match_route6()
{
    return net ~ ACAST6_PS_ADVERTISE;
}anycast-prefixes.confanycast-prefixes.conffile defines a list of IP prefixes which is stored in a variable namedACAST_PS_ADVERTISE. The name of the variable can be anything meaningful butbird_variablesettingmustbe changed accordingly.define ACAST_PS_ADVERTISE =
    [
        10.189.200.255/32
    ];anycast-healthchecker removes IP prefixes from the list for which a service check is not configured. But, the IP prefix set indummy_ip_prefixdoes not need a service check configuration.This the equivalent list for IPv6 prefixes:define ACAST6_PS_ADVERTISE =
    [
        2001:db8::1/128
    ];anycast-healthchecker createsanycast-prefixes.conffile for both IP versions upon startup if those file don’t exist. After the launchno other process(es) shouldmodify those files.Use daemon settingsbird_confandbird6_confto control the location of the files.With the default settings those files are located under/var/lib/anycast-healthcheckerand/var/lib/anycast-healthchecker/6. Administrators must create those two directories with permissions755and user/group ownership to the account under which anycast-healthchecker runs.Bird daemon loads configuration files by using theincludestatement in the main Bird configuration (bird.conf). By default suchincludestatement points to a directory under/etc/bird.d, whileanycast-prefixes.conffiles are located under/var/lib/anycast-healthcheckerdirectories. Therefore,
a link for each file must be created under/etc/bird.ddirectory. Administrators must also create those two links. Here is an example from a production server:% ls -ls /etc/bird.d/anycast-prefixes.conf
4 lrwxrwxrwx 1 root root 105 Dec  2 16:08 /etc/bird.d/anycast-prefixes.conf ->
/var/lib/anycast-healthchecker/anycast-prefixes.conf

% ls -ls /etc/bird.d/6/anycast-prefixes.conf
4 lrwxrwxrwx 1 root root 107 Jan 10 10:33 /etc/bird.d/6/anycast-prefixes.conf
-> /var/lib/anycast-healthchecker/6/anycast-prefixes.confConfiguring anycast-healthcheckeranycast-healthchecker uses the popularINIformat for its configuration files. This is an example configuration file(/etc/anycast-healthchecker.conf) for configuring anycast-healthchecker:[DEFAULT]
interface             = lo

[daemon]
pidfile               = /var/run/anycast-healthchecker/anycast-healthchecker.pid
ipv4                  = true
ipv6                  = false
bird_conf             = /var/lib/anycast-healthchecker/anycast-prefixes.conf
bird6_conf            = /var/lib/anycast-healthchecker/6/anycast-prefixes.conf
bird_variable         = ACAST_PS_ADVERTISE
bird6_variable        = ACAST6_PS_ADVERTISE
bird_reconfigure_cmd  = sudo /usr/sbin/birdc configure
bird6_reconfigure_cmd = sudo /usr/sbin/birdc6 configure
dummy_ip_prefix       = 10.189.200.255/32
dummy_ip6_prefix      = 2001:db8::1/128
bird_keep_changes     = false
bird6_keep_changes    = false
bird_changes_counter  = 128
bird6_changes_counter = 128
purge_ip_prefixes     = false
loglevel              = debug
log_maxbytes          = 104857600
log_backups           = 8
log_server_port       = 514
json_stdout           = false
json_log_file         = false
json_log_server       = false
prometheus_exporter   = false
prometheus_collector_textfile_dir = /var/cache/textfile_collector/
prometheus_exporter_interval      = 20The above settings are used as defaults when anycast-healthchecker is launched without a configuration file. anycast-healthcheckerdoes notneed to run as root as long as it has sufficient privileges to modify the Bird configuration set inbird_conforbird6_conf, and trigger a reconfiguration of Bird by running the command configured inbird_reconfigure_cmdorbird6_reconfigure_cmd. In the above examplesudois used for that purpose (sudoersfile has been modified for that purpose).DEFAULT sectionBelow are the default settings for all service checks, seeConfiguring checks for servicesfor an explanation of the parameters. Settings in this section can be overwritten in other sections.interface:locheck_interval:10check_timeout:2check_rise:2check_fail:2check_disabled:trueon_disabled:withdrawip_check_disabled:falsecustom_bird_reconfigure_cmd_timeout:2Daemon sectionSettings for anycast-healthchecker itselfpidfileDefaults to/var/run/anycast-healthchecker/anycast-healthchecker.pidFile to store the process id. The parent directory must be created prior the initial launch.ipv4Defaults totruetrueenables IPv4 support andfalsedisables it.
NOTE: anycast-healthcheckerwill notstart if IPv4 support is disabled while there is an service check configured for IPv4 prefix.ipv6Defaults tofalsetrueenables IPv6 support andfalsedisables it
NOTE: anycast-healthcheckerwill notstart if IPv6 support is disabled while there is an service check configured for IPv6 prefix.bird_confDefaults to/var/lib/anycast-healthchecker/anycast-prefixes.confFile with the list of IPv4 prefixes allowed to be exported. If this file is a symbolic link then the destination and the link itself must be on the same mounted filesystem.bird6_confDefaults to/var/lib/anycast-healthchecker/6/anycast-prefixes.confFile with the list of IPv6 prefixes allowed to be exported. If this file is a symbolic link then the destination and the link itself must be on the same mounted filesystem.bird_variableDefaults toACAST_PS_ADVERTISEThe name of the list defined inbird_confbird6_variableDefaults toACAST6_PS_ADVERTISEThe name of the list defined inbird6_confbird_reconfigure_cmdDefaults tosudo /usr/sbin/birdc configureCommand to trigger a reconfiguration of IPv4 Bird daemonbird6_reconfigure_cmdDefaults tosudo /usr/sbin/birdc6 configureCommand to trigger a reconfiguration of IPv6 Bird daemondummy_ip_prefixDefaults to10.189.200.255/32An IP prefix in the form <IP>/<prefix length> which will be always available in the list defined bybird_variableto avoid having an empty list. Thedummy_ip_prefixmust notbe used by any service or assigned to the interface set withinterfaceor configured anywhere on the network as anycast-healthcheckerdoes notperform any checks for it.dummy_ip6_prefixDefaults to2001:db8::1/128An IPv6 prefix in the form <IPv6>/<prefix length> which will be always available in the list defined bybird6_variableto avoid having an empty list. Thedummy_ip6_prefixmust notbe used by any service or assigned to the interface set withinterfaceor configured anywhere on the network as anycast-healthcheckerdoes notperform any checks for it.bird_keep_changesDefaults tofalseKeep a history of changes forbird_conffile by copying it to a directory. During the startup of anycast-healthchecker a directory with the namehistoryis created under the directory wherebird_conffile resides. The daemon has to have sufficient privileges to create that directory.bird6_keep_changesDefaults tofalseKeep a history of changes forbird6_conffile by copying it to a directory. During the startup of anycast-healthchecker a directory with the namehistoryis created under the directory wherebird6_conffile resides. The daemon has to have sufficient privileges to create that directory.
WARNING: When keeping a history of changes is enabled for both IP versions then configuration files set inbird_confandbird6_confsettingsmustbe stored on two different directories.bird_changes_counterDefaults to128How manybird_conffiles to keep in thehistorydirectory.bird6_changes_counterDefaults to128How manybird6_conffiles to keep in thehistorydirectory.purge_ip_prefixesDefaults tofalseDuring start-up purge IP-Prefixes from configuration files set inbird_confandbird6_conf, which don’t have a service check associated with them.NOTE: Those IP-Prefixes are always removed from the configuration files set inbird_confand inbird6_confsettings when anycast-healthchecker updates those files.purge_ip_prefixesis considered only during start-up and was introduced in order to be compatible with the behavior of previous releases, which didn’t remove those IP-Prefixes on start-up.loglevelDefaults todebugLog level to use, possible values are: debug, info, warning, error, criticallog_fileDefaults toSTDOUTFile to log messages to. The parent directory must be created prior the initial
launch.log_maxbytesDefaults to104857600(bytes)Maximum size in bytes for log files. It is only used iflog_fileis set to
a file.log_backupsDefaults to8Number of old log files to maintain. It is only used iflog_fileis set to
a file.stderr_fileDefaults toSTDERRFile to redirect standard error to. The parent directory must be created prior the initial launch.log_serverUnset by defaultEither the IP address or the hostname of an UDP syslog server to forward logging messages.log_server_portDefaults to514The port on the remote syslog server to forward logging messages over UDP.json_stdoutDefaults tofalsetrueenables structured logging for STDOUT.json_log_fileDefaults tofalsetrueenables structured logging whenlog_fileis set to a file.json_log_serverDefaults tofalsetrueenables structured logging whenlog_serveris set to a remote UDP
syslog server.prometheus_exporterDefaults tofalsetrueenables prometheus exporter.prometheus_collector_textfile_dirDefaults to/var/cache/textfile_collector/The directory to store the exported statistics.prometheus_exporter_intervalDefaults to20secondsHow often to export Prometheus metrics.splay_startupUnset by defaultThe maximum time to delay the startup of service checks. You can use either integer or floating-point number as a value.In order to avoid launching all checks at the same time, after anycast-healthchecker is started, we can delay the 1st check in random way. This can be useful in cases where we have a lot of service checks and launching all them at the same time can overload the system.  We randomize the delay of the 1st check for each service andsplay_startupsets the maximum time we can delay that 1st check.The interval of the check doesn’t drift, thanks to 9cbbeaff455c49b35670c, and as a result the service checks will be always launched in different times during the life time of anycast-healthchecker.Prometheus exporteranycast-healthchecker comes with a Prometheus exporter to expose various statistics. This functionality is not enabled by default and users need to setprometheus_exportersetting totrueand also adjustprometheus_collector_textfile_dirparameter according to their setup.Below is the exported metrics when there are three service checks configured:# HELP anycast_healthchecker_service_state The status of the service check: 0 = down, 1 = up
# TYPE anycast_healthchecker_service_state gauge
anycast_healthchecker_service_state{ip_prefix="fd12:aba6:57db:ffff::1/128",service_name="foo1IPv6.bar.com"} 0.0
anycast_healthchecker_service_state{ip_prefix="10.52.12.1/32",service_name="foo.bar.com"} 0.0
anycast_healthchecker_service_state{ip_prefix="10.52.12.2/32",service_name="foo1.bar.com"} 0.0
# HELP anycast_healthchecker_service_check_duration_milliseconds Service check duration in milliseconds
# TYPE anycast_healthchecker_service_check_duration_milliseconds gauge
anycast_healthchecker_service_check_duration_milliseconds{ip_prefix="10.52.12.1/32",service_name="foo.bar.com"} 5.141496658325195
# HELP anycast_healthchecker_service_check_ip_assignment Service IP assignment check: 0 = not assigned, 1 = assigned
# TYPE anycast_healthchecker_service_check_ip_assignment gauge
anycast_healthchecker_service_check_ip_assignment{ip_prefix="10.52.12.1/32",service_name="foo.bar.com"} 1.0
anycast_healthchecker_service_check_ip_assignment{ip_prefix="fd12:aba6:57db:ffff::1/128",service_name="foo1IPv6.bar.com"} 0.0
anycast_healthchecker_service_check_ip_assignment{ip_prefix="10.52.12.2/32",service_name="foo1.bar.com"} 1.0
# HELP anycast_healthchecker_service_check_timeout_total The number of times a service check timed out
# TYPE anycast_healthchecker_service_check_timeout_total counter
anycast_healthchecker_service_check_timeout_total{ip_prefix="10.52.12.2/32",service_name="foo1.bar.com"} 3.0
# HELP anycast_healthchecker_service_check_timeout_created The number of times a service check timed out
# TYPE anycast_healthchecker_service_check_timeout_created gauge
anycast_healthchecker_service_check_timeout_created{ip_prefix="10.52.12.2/32",service_name="foo1.bar.com"} 1.698693786243282e+09
# HELP anycast_healthchecker_service_check_exitcode The exit code of the check command
# TYPE anycast_healthchecker_service_check_exitcode gauge
anycast_healthchecker_service_check_exitcode{ip_prefix="10.52.12.2/32",service_name="foo1.bar.com"} 126.0
anycast_healthchecker_service_check_exitcode{ip_prefix="10.52.12.1/32",service_name="foo.bar.com"} 0.0
# HELP anycast_healthchecker_uptime Uptime of the process in seconds since the epoch
# TYPE anycast_healthchecker_uptime gauge
anycast_healthchecker_uptime 1.6986938162371802e+09
# HELP anycast_healthchecker_state The current state of the process: 0 = down, 1 = up
# TYPE anycast_healthchecker_state gauge
anycast_healthchecker_state 1.0
# HELP anycast_healthchecker_version_info Version of the software
# TYPE anycast_healthchecker_version_info gauge
anycast_healthchecker_version_info{version="0.9.1"} 1.0
# HELP anycast_healthchecker_service The configured service checks
# TYPE anycast_healthchecker_service gauge
anycast_healthchecker_service{ip_prefix="10.52.12.1/32",service_name="foo.bar.com"} 1.0
anycast_healthchecker_service{ip_prefix="fd12:aba6:57db:ffff::1/128",service_name="foo1IPv6.bar.com"} 1.0
anycast_healthchecker_service{ip_prefix="10.52.12.2/32",service_name="foo1.bar.com"} 1.0How to configure loggingBy default anycast-healtchecker logs messages to STDOUT, while messages related to unhandled exceptions or crashes go to STDERR. But it is possible to log such messages to a file and/or to a remote UDP syslog server.anycast-healthchecker doesn’t log to STDOUT/STDERR when either log file or a remote UDP syslog server is configured.You can configure it to use a log file and a remote UDP syslog server at the same time, so logging messages can be stored locally and remotely. This is convenient when remote log server is in trouble and loses log messages.The best logging configuration in terms of resiliency is to enable logging only to a remote UDP syslog server. Sending data over UDP protocol is done in no-blocking mode and therefore anycast-healthchecker isn’t blocked in any way
when it logs messages. Furthermore, when it logs to a log file and there isn’t any more space available on the filesystem, the software will crash. You can easily avoid this failure by using UDP syslog server.Last but not least, anycast-healthchecker handles the rotation of old log files, so you don’t need to configure any other tools(logrotate) for that.JSON loggingYou can configure anycast-healthchecker to send structured logging messages. This is quite important in environments with a lot of servers and Anycasted services.You can enable structured logging for STDOUT, log file and remote UDP syslog server. Currently, it isn’t possible to add/remove keys from the structured logging data. The followings are the keys that are present in the structure:asctime: Human-readable time when the log message was created, example value 2017-07-23 09:43:28,995.levelname: Text logging level for the message, example value WARNING.process: Process ID, example value 23579message: The logged message.prefix_length: The prefix length of the Anycast Address associated with the logged message, example value 128.
This key isn’t present for messages, which were logged by the parent thread.status: The status of the service when message was logged, possible values are down, up and unknown.
This key isn’t present for messages, which were logged by the parent thread.ip_address: The Anycast IP address of the monitored service for which the message was logged, example value fd12:aba6:57db:ffff::2
This key isn’t present for messages, which were logged by the parent thread.ip_check_disabled: Eithertruewhen the assignment check ofip_prefixto the interface is disabled, otherwisefalse.
This key isn’t present for messages, which were logged by the parent thread.version: The running version of anycast-healthchecker, example value 0.7.4.program: The process name, defaults to anycast-healthchecker.service_name: The name of the service defined in configuration for which the   message was logged, example value foo1IPv6.bar.com. Logging messages from the parent thread will have value “MainThread”.Configuring checks for servicesThe configuration for a single service check is defined in one section.
Here are few examples:[foo.bar.com]
check_cmd         = /usr/bin/curl --fail --silent http://10.52.12.1/
check_interval    = 10
check_timeout     = 2
check_fail        = 2
check_rise        = 2
check_disabled    = false
on_disabled       = withdraw
ip_prefix         = 10.52.12.1/32

[foo6.bar.com]
check_cmd         = /usr/bin/curl --fail 'http://[fd12:aba6:57db:ffff::1]:8888'
check_timeout     = 5
check_rise        = 2
check_fail        = 2
check_disabled    = false
on_disabled       = withdraw
ip_prefix         = fd12:aba6:57db:ffff::1/128
ip_check_disabled = falseThe name of the section becomes the name of the service check and appears in the log files for easier searching of error/warning messages.check_cmdUnset by defaultThe command to run to determine the status of the service basedon the return code. Complex health checking should be wrapped in a script. When check command fails, the stdout and stderr appears in the log file.check_intervalDefaults to2(seconds)How often to run the checkcheck_timeoutDefaults to2(seconds)Maximum time in seconds for the check command to complete. anycast-healthchecker will try kill the check if it doesn’t return aftercheck_timeoutseconds. Ifcheck_cmdruns under another user account (root) via sudo then it won’t be killed.  anycast-healthchecker could run as root to overcome this problem, but it is highly recommended to run it as normal user.check_failDefaults to2A service is considered DOWN after these many consecutive unsuccessful health checkscheck_riseDefaults to2A service is considered HEALTHY after these many consecutive successful health checkscheck_disabledDefaults tofalsetruedisables the check,falseenables iton_disabledDefaults towithdrawWhat to do when check is disabled, eitherwithdraworadvertiseip_prefixUnset by defaultIP prefix associated with the service. Itmust beassigned to the interface set ininterfaceparameter unlessip_check_disabledis set totrue. Prefix length is optional and defaults to 32 for IPv4 addresses and to 128 for IPv6 addresses.ip_check_disabledDefaults tofalsetruedisables the assignment check ofip_prefixto the interface set ininterface,falseenables it.If thecheck_cmdchecks the availability of the service by sending a request to the Anycasted IP address then this request may be served by another node that advertises the same IP address on the network. This usually happens
when the Anycasted IP address is not assigned to loopback or any other interface on the local node.Therefore, it should be only enabled in environments where the network or the network configuration of the local node prevents the request fromcheck_cmdto be forwarded to another node.interfaceDefaults toloThe name of the interface thatip_prefixis assigned tocustom_bird_reconfigure_cmdUnset by defaultA custom command to trigger a reconfiguration of Bird daemon. This overwrites the value ofbird_reconfigure_cmdandbird6_reconfigure_cmdsettings. This setting allows the use of a custom command to trigger a reconfiguration of Bird daemon after an IP prefix is either added to or removed from Bird configuration. If return code is not a zero value then an error is logged together with STDERR of the command, if there is any. anycast-healthchecker passes one argument to the command, which isupwhen IP prefix is added ordownwhen is removed, so the command can perform different things depending the status of the service.custom_bird_reconfigure_cmd_timeoutDefaults to2(seconds)Maximum time in seconds for thecustom_bird_reconfigure_cmdto complete. anycast-healthchecker will try kill the command if it doesn’t return aftercustom_bird_reconfigure_cmd_timeoutseconds. Ifcustom_bird_reconfigure_cmdruns under another user account (root) via sudo then it won’t be killed.  anycast-healthchecker could run as root to overcome this problem, but it is highly recommended to run it as normal user.Multiple sections may be combined in one file or provide one file per section. File must be stored under one directory and their name should use.confas suffix (foo.bar.com.conf).Starting anycast-healthcheckerCLI usage:anycast-healthchecker --help
A simple healthchecker for Anycasted services.

Usage:
    anycast-healthchecker [ -f <file> -c -p -P ] [ -d <directory> | -F <file> ]

Options:
    -f, --file=<file>          read settings from <file>
                               [default: /etc/anycast-healthchecker.conf]
    -d, --dir=<dir>            read settings for service checks from files
                               under <dir> directory
                               [default: /etc/anycast-healthchecker.d]
    -F, --service-file=<file>  read <file> for settings of a single service
                               check
    -c, --check                perform a sanity check on configuration
    -p, --print                show default settings for anycast-healthchecker
                               and service checks
    -P, --print-conf           show running configuration with default settings
                               applied
    -v, --version              show version
    -h, --help                 show this screenYou can launch it by supplying a configuration file and a directory with configuration files for service checks:anycast-healthchecker -f ./anycast-healthchecker.conf -d ./anycast-healthchecker.dAt the root of the project there is System V init and a Systemd unit file for proper integration with OS startup tools.Systemd and SysVinit integrationUnder contrib/systemd and contrib/SysVinit directories there are the necessary startup files that can be used to start anycast-healthchecker on boot.IMPORTANT:Version 0.8.0 dropped support for daemonization and therefore you can’t use the System V init script stored under contrib/SysVinit directory with newer versions. If you want to use version 0.8.0 and higher on Operating Systems that don’t support Systemd then you have to use a tool like supervisord.Nagios checkUnder contrib/nagios directory there is a nagios plugin to check if the program is up and if all threads are running.InstallationUse pip:pip install anycast-healthcheckerFrom Source:sudo python -m pip install .Build a python wheel for manual installation:python -m pip install build; python -m build --wheelReleaseBump version in anycast_healthchecker/__init__.pyCommit above change with:git commit -av -m'RELEASE 0.1.3 version'Create a signed tag, pbr will use this for the version number:git tag -s 0.1.3 -m 'bump release'Create the package wheel (the whl file will be placed in thedistdirectory):python -m pip install build; python -m build --wheelpbr will update ChangeLog file and we want to squeeze them to the previous commit thus we run:git commit -av --amendMove current tag to the last commit:git tag -fs 0.1.3 -m 'bump release'Push changes:git push; git push --tagsDevelopmentI would love to hear what other people think aboutanycast_healthcheckerand provide feedback. Please post your comments, bug reports and wishes on myissues page.TestingAt the root of the project there is alocal_run.shscript which you can use
for testing purposes. It does the following:Creates the necessary directory structure under $PWD/var to store
configuration and log filesGenerates configuration for the daemon and for 2 service checksGenerates bird configuration(anycast-prefixes.conf)Installs anycast-healthchecker withpython3-mpip install .Assigns 4 IPv4 addresses and 2 IPv6 addresses to loopback interfaceChecks if bird daemon runs but it does not try to start if it is downStarts the daemon as normal user and not as rootRequirements for runninglocal_run.shpython3 installationA working python virtual environment, use the excellent tool virtualenvwrapperBird installed and configured as it is mentioned inBird configurationsudo access to runbirdc configureandbirdc6 configuresudo access to assign IPs on the loopback interface usingiptoolContributorsThe following people have contributed to project with feedback, commits and code reviewsKároly Nagy (@charlesnagy)Nick Demou (@ndemou)Ralf Ertzinger (@alufu)Carlo Rengo (@sevencastles)LicensingApache 2.0AcknowledgementThis program was originally developed for Booking.com.  With approval from Booking.com, the code was generalised and published as Open Source on github, for which the author would like to express his gratitude.ContactsProject website:https://github.com/unixsurfer/anycast_healthcheckerAuthor: Pavlos Parissis <pavlos.parissis@gmail.com>