|
| 1 | +# Keepalived |
| 2 | + |
| 3 | +forked from [keepalived-exporter](https://github.com/mehdy/keepalived-exporter) |
| 4 | + |
| 5 | +## Configuration |
| 6 | + |
| 7 | +请参考配置[示例](../../conf/input.keepalived/keepalived.toml) |
| 8 | + |
| 9 | +``` |
| 10 | +# # collect interval |
| 11 | +# interval = 15 |
| 12 | +
|
| 13 | +# Send SIGJSON and decode JSON file instead of parsing text files, defaults to `false`. |
| 14 | +sig_json = false |
| 15 | +
|
| 16 | +# A path for Keepalived PID, defaults to `/var/run/keepalived.pid` |
| 17 | +pid_path = "" |
| 18 | +
|
| 19 | +# Health Check script path to be execute for each VIP. |
| 20 | +# Check Script Example: |
| 21 | +#!/usr/bin/env bash |
| 22 | +#ping $1 -c 1 -W 1 |
| 23 | +check_script_path = "" |
| 24 | +
|
| 25 | +#This is when the keepalived is running with PID 1 in the container so we can use the standard docker API to send signal to the keepalived process. |
| 26 | +# Keepalived container name to export metrics from Keepalived container. |
| 27 | +container_name = "" |
| 28 | +
|
| 29 | +# In case the keepalived process is not running with PID 1, this method will exec to the container and use the provided PID path to send the signal. |
| 30 | +container_pid_path = "" |
| 31 | +
|
| 32 | +# Keepalived container tmp volume path, defaults to `/tmp`. |
| 33 | +container_tmp = "" |
| 34 | +``` |
| 35 | + |
| 36 | +#### Using Docker Signal |
| 37 | + |
| 38 | +This is when the keepalived is running with PID 1 in the container so we can use the standard docker API to send signal to the keepalived process. |
| 39 | + |
| 40 | +```bash |
| 41 | +docker run -v keepalived-data:/tmp/ ... $KEEPALIVED_IMAGE |
| 42 | +``` |
| 43 | + |
| 44 | +#### Exec to container with PID path |
| 45 | + |
| 46 | +In case the keepalived process is not running with PID 1, this method will exec to the container and use the provided PID path to send the signal. |
| 47 | + |
| 48 | +```bash |
| 49 | +docker run -v keepalived-data:/tmp/ -v keepalived-pid:/var/run/ ... $KEEPALIVED_IMAGE |
| 50 | +``` |
| 51 | + |
| 52 | +## Metrics |
| 53 | + |
| 54 | +| Metric | Notes |
| 55 | +|-------------------------------------------------|------------------------------------ |
| 56 | +| keepalived_up | Status of Keepalived service |
| 57 | +| keepalived_vrrp_state | State of vrrp |
| 58 | +| keepalived_vrrp_excluded_state | State of vrrp with excluded VIP |
| 59 | +| keepalived_check_script_status | Check Script status for each VIP |
| 60 | +| keepalived_gratuitous_arp_delay_total | Gratuitous ARP delay |
| 61 | +| keepalived_advertisements_received_total | Advertisements received |
| 62 | +| keepalived_advertisements_sent_total | Advertisements sent |
| 63 | +| keepalived_become_master_total | Became master |
| 64 | +| keepalived_release_master_total | Released master |
| 65 | +| keepalived_packet_length_errors_total | Packet length errors |
| 66 | +| keepalived_advertisements_interval_errors_total | Advertisement interval errors |
| 67 | +| keepalived_ip_ttl_errors_total | TTL errors |
| 68 | +| keepalived_invalid_type_received_total | Invalid type errors |
| 69 | +| keepalived_address_list_errors_total | Address list errors |
| 70 | +| keepalived_authentication_invalid_total | Authentication invalid |
| 71 | +| keepalived_authentication_mismatch_total | Authentication mismatch |
| 72 | +| keepalived_authentication_failure_total | Authentication failure |
| 73 | +| keepalived_priority_zero_received_total | Priority zero received |
| 74 | +| keepalived_priority_zero_sent_total | Priority zero sent |
| 75 | +| keepalived_script_status | Tracker Script Status |
| 76 | +| keepalived_script_state | Tracker Script State |
| 77 | + |
| 78 | +## Check Script |
| 79 | + |
| 80 | +You can specify a check script like Keepalived script check to check if all the things is okay or not. |
| 81 | +The script will run for each VIP and gives an arg `$1` that contains VIP. |
| 82 | + |
| 83 | +**Note:** The script should be executable. |
| 84 | + |
| 85 | +```bash |
| 86 | +chmod +x check_script.sh |
| 87 | +``` |
| 88 | + |
| 89 | +### Sample Check Script |
| 90 | + |
| 91 | +```bash |
| 92 | +#!/usr/bin/env bash |
| 93 | +ping $1 -c 1 -W 1 |
| 94 | +``` |
| 95 | + |
| 96 | +## Example Output |
| 97 | + |
| 98 | +```text |
| 99 | +keepalived_up agent_hostname=zy-wh-fat-utils-test-06 1 |
| 100 | +keepalived_advertisements_received_total agent_hostname=zy-wh-fat-utils-test-06 iname=VI_1 intf=ens3 vrid=51 0 |
| 101 | +keepalived_advertisements_sent_total agent_hostname=zy-wh-fat-utils-test-06 iname=VI_1 intf=ens3 vrid=51 8869 |
| 102 | +keepalived_become_master_total agent_hostname=zy-wh-fat-utils-test-06 iname=VI_1 intf=ens3 vrid=51 1 |
| 103 | +keepalived_release_master_total agent_hostname=zy-wh-fat-utils-test-06 iname=VI_1 intf=ens3 vrid=51 0 |
| 104 | +keepalived_packet_length_errors_total agent_hostname=zy-wh-fat-utils-test-06 iname=VI_1 intf=ens3 vrid=51 0 |
| 105 | +keepalived_advertisements_interval_errors_total agent_hostname=zy-wh-fat-utils-test-06 iname=VI_1 intf=ens3 vrid=51 0 |
| 106 | +keepalived_ip_ttl_errors_total agent_hostname=zy-wh-fat-utils-test-06 iname=VI_1 intf=ens3 vrid=51 0 |
| 107 | +keepalived_invalid_type_received_total agent_hostname=zy-wh-fat-utils-test-06 iname=VI_1 intf=ens3 vrid=51 0 |
| 108 | +keepalived_address_list_errors_total agent_hostname=zy-wh-fat-utils-test-06 iname=VI_1 intf=ens3 vrid=51 0 |
| 109 | +keepalived_authentication_invalid_total agent_hostname=zy-wh-fat-utils-test-06 iname=VI_1 intf=ens3 vrid=51 0 |
| 110 | +keepalived_authentication_mismatch_total agent_hostname=zy-wh-fat-utils-test-06 iname=VI_1 intf=ens3 vrid=51 0 |
| 111 | +keepalived_authentication_failure_total agent_hostname=zy-wh-fat-utils-test-06 iname=VI_1 intf=ens3 vrid=51 0 |
| 112 | +keepalived_priority_zero_received_total agent_hostname=zy-wh-fat-utils-test-06 iname=VI_1 intf=ens3 vrid=51 0 |
| 113 | +keepalived_priority_zero_sent_total agent_hostname=zy-wh-fat-utils-test-06 iname=VI_1 intf=ens3 vrid=51 0 |
| 114 | +keepalived_gratuitous_arp_delay_total agent_hostname=zy-wh-fat-utils-test-06 iname=VI_1 intf=ens3 vrid=51 5 |
| 115 | +keepalived_vrrp_state agent_hostname=zy-wh-fat-utils-test-06 iname=VI_1 intf=ens3 ip_address=172.20.84.253/24 vrid=51 2 |
| 116 | +keepalived_script_status agent_hostname=zy-wh-fat-utils-test-06 name=chk_nginx 1 |
| 117 | +keepalived_script_state agent_hostname=zy-wh-fat-utils-test-06 name=chk_nginx 0 |
| 118 | +keepalived_scrape_use_seconds agent_hostname=zy-wh-fat-utils-test-06 0.000381182 |
| 119 | +``` |
0 commit comments