2021-08-12 12:47:48 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2021-08-26 15:31:47 +02:00
|
|
|
if ! command -v check_patroni &>/dev/null; then
|
|
|
|
echo "check_partroni must be installed to generate the documentation"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2022-07-11 12:12:26 +02:00
|
|
|
top_srcdir="$(readlink -m "$0/../..")"
|
|
|
|
README="${top_srcdir}/README.md"
|
2021-08-12 12:47:48 +02:00
|
|
|
function readme(){
|
|
|
|
echo "$1" >> $README
|
|
|
|
}
|
|
|
|
|
|
|
|
function helpme(){
|
|
|
|
readme
|
2021-08-13 11:13:33 +02:00
|
|
|
readme '```'
|
2021-08-12 12:47:48 +02:00
|
|
|
check_patroni $1 --help >> $README
|
2021-08-13 11:13:33 +02:00
|
|
|
readme '```'
|
2021-08-12 12:47:48 +02:00
|
|
|
readme
|
|
|
|
}
|
|
|
|
|
2021-08-13 11:13:33 +02:00
|
|
|
cat << '_EOF_' > $README
|
2021-08-12 12:47:48 +02:00
|
|
|
# check_patroni
|
2021-08-13 12:12:08 +02:00
|
|
|
|
2022-07-11 11:53:00 +02:00
|
|
|
A nagios plugin for patroni.
|
2021-08-13 12:12:08 +02:00
|
|
|
|
2022-07-11 11:53:00 +02:00
|
|
|
## Features
|
2021-08-13 12:12:08 +02:00
|
|
|
|
2022-07-11 11:53:00 +02:00
|
|
|
- Check presence of leader, replicas, node counts.
|
|
|
|
- Check each node for replication status.
|
2021-08-13 14:43:07 +02:00
|
|
|
|
2022-07-11 11:53:00 +02:00
|
|
|
_EOF_
|
|
|
|
helpme
|
|
|
|
cat << '_EOF_' >> $README
|
|
|
|
## Install
|
2021-08-13 14:43:07 +02:00
|
|
|
|
2022-07-11 11:53:00 +02:00
|
|
|
check_patroni is licensed under PostgreSQL license.
|
2022-02-07 11:03:12 +01:00
|
|
|
|
|
|
|
```
|
2022-07-11 11:53:00 +02:00
|
|
|
$ pip install git+https://github.com/dalibo/check_patroni.git
|
2022-02-07 11:03:12 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
Links:
|
2021-08-13 14:43:07 +02:00
|
|
|
* [pip & centos 7](https://linuxize.com/post/how-to-install-pip-on-centos-7/)
|
|
|
|
* [pip & debian10](https://linuxize.com/post/how-to-install-pip-on-debian-10/)
|
|
|
|
|
2022-07-11 11:53:00 +02:00
|
|
|
## Support
|
|
|
|
|
|
|
|
If you hit a bug or need help, open a [GitHub
|
|
|
|
issue](https://github.com/dalibo/check_patroni/issues/new). Dalibo has no
|
|
|
|
commitment on response time for public free support. Thanks for you
|
|
|
|
contribution !
|
|
|
|
|
2022-02-07 11:03:12 +01:00
|
|
|
## Config file
|
2021-08-13 11:13:33 +02:00
|
|
|
|
|
|
|
All global and service specific parameters can be specified via a config file has follows:
|
|
|
|
|
|
|
|
```
|
|
|
|
[options]
|
|
|
|
endpoints = https://10.20.199.3:8008, https://10.20.199.4:8008,https://10.20.199.5:8008
|
2022-07-11 08:57:14 +02:00
|
|
|
cert_file = ./ssl/my-cert.pem
|
|
|
|
key_file = ./ssl/my-key.pem
|
2021-08-13 11:13:33 +02:00
|
|
|
ca_file = ./ssl/CA-cert.pem
|
|
|
|
timeout = 0
|
|
|
|
|
|
|
|
[options.node_is_replica]
|
|
|
|
lag=100
|
|
|
|
```
|
2022-02-07 11:03:12 +01:00
|
|
|
## Thresholds
|
2021-08-26 15:31:47 +02:00
|
|
|
|
2022-07-11 08:57:14 +02:00
|
|
|
The format for the threshold parameters is `[@][start:][end]`.
|
2021-08-26 15:31:47 +02:00
|
|
|
|
2022-07-11 08:57:14 +02:00
|
|
|
* `start:` may be omitted if `start == 0`
|
|
|
|
* `~:` means that start is negative infinity
|
2021-08-26 15:31:47 +02:00
|
|
|
* If `end` is omitted, infinity is assumed
|
2022-07-11 08:57:14 +02:00
|
|
|
* To invert the match condition, prefix the range expression with `@`.
|
2021-08-26 15:31:47 +02:00
|
|
|
|
2022-07-11 08:57:14 +02:00
|
|
|
A match is found when: `start <= VALUE <= end`.
|
2021-08-26 15:31:47 +02:00
|
|
|
|
2022-07-11 08:57:14 +02:00
|
|
|
For example, the following command will raise:
|
2021-08-26 15:31:47 +02:00
|
|
|
|
2021-12-31 11:30:17 +01:00
|
|
|
* a warning if there is less than 1 nodes, wich can be translated to outside of range [2;+INF[
|
|
|
|
* a critical if there are no nodes, wich can be translated to outside of range [1;+INF[
|
2021-08-26 15:31:47 +02:00
|
|
|
|
|
|
|
```
|
2021-12-31 11:30:17 +01:00
|
|
|
check_patroni -e https://10.20.199.3:8008 cluster_has_replica --warning 2: --critical 1:
|
2021-08-26 15:31:47 +02:00
|
|
|
```
|
2023-03-12 19:43:06 +01:00
|
|
|
## SSL
|
|
|
|
|
2023-03-14 18:02:53 +01:00
|
|
|
Several options are available:
|
2023-03-12 19:43:06 +01:00
|
|
|
|
2023-03-14 18:02:53 +01:00
|
|
|
* the server's CA certificate is not available or trusted by the client system:
|
2023-03-12 19:43:06 +01:00
|
|
|
* `--ca_cert`: your certification chain `cat CA-certificate server-certificate > cabundle`
|
2023-03-14 18:02:53 +01:00
|
|
|
* you have a client certificate for authenticating with Patroni's REST API:
|
2023-03-12 19:43:06 +01:00
|
|
|
* `--cert_file`: your certificate or the concatenation of your certificate and private key
|
|
|
|
* `--key_file`: your private key (optional)
|
|
|
|
```
|
2021-08-13 11:13:33 +02:00
|
|
|
_EOF_
|
|
|
|
readme
|
2022-02-07 11:03:12 +01:00
|
|
|
readme "## Cluster services"
|
|
|
|
readme
|
2021-08-12 12:47:48 +02:00
|
|
|
readme "### cluster_config_has_changed"
|
|
|
|
helpme cluster_config_has_changed
|
|
|
|
readme "### cluster_has_leader"
|
|
|
|
helpme cluster_has_leader
|
|
|
|
readme "### cluster_has_replica"
|
|
|
|
helpme cluster_has_replica
|
|
|
|
readme "### cluster_is_in_maintenance"
|
|
|
|
helpme cluster_is_in_maintenance
|
|
|
|
readme "### cluster_node_count"
|
|
|
|
helpme cluster_node_count
|
2022-02-07 11:03:12 +01:00
|
|
|
readme "## Node services"
|
|
|
|
readme
|
2021-08-12 12:47:48 +02:00
|
|
|
readme "### node_is_alive"
|
|
|
|
helpme node_is_alive
|
|
|
|
readme "### node_is_pending_restart"
|
|
|
|
helpme node_is_pending_restart
|
|
|
|
readme "### node_is_primary"
|
|
|
|
helpme node_is_primary
|
|
|
|
readme "### node_is_replica"
|
|
|
|
helpme node_is_replica
|
|
|
|
readme "### node_patroni_version"
|
|
|
|
helpme node_patroni_version
|
|
|
|
readme "### node_tl_has_changed"
|
|
|
|
helpme node_tl_has_changed
|
|
|
|
cat << _EOF_ >> $README
|
|
|
|
|
|
|
|
_EOF_
|