diff --git a/README b/README deleted file mode 100644 index e13bdcc..0000000 --- a/README +++ /dev/null @@ -1,80 +0,0 @@ -Nagios plugin to check Postgres Streaming replication -===================================================== - -This script could be used as Nagios check plugin to verify Postgres Streaming -replication state. - -This script : - -- check if Postgres is running (CRITICAL raise if not) -- check if Postgres is in recovery mode : - - if Postgres is in recovery mode : - - retreive from Postgres the last xlog file receive and the xlog file replay - - check if Postgres recovery configuration file is NOT present (CRITICAL - raise if present) - - retreive master connection informations from Postgres recovery configuration - file (UNKNOWN raise on error). Default Postgres master TCP port will be used - if port is not specify. - - retreive current xlog file from Postgres master server by making a connection - on master server (UNKNOWN raise on error). - - check if the last receive xlog file is the last replay xlog file (WARNING raise if not) - - Return OK state -- if Postgres is not in recovery mode : - - check if Postgres recovery configuration file is present (CRITICAL raise if present) - - check if stand-by client(s) is connected (WARNING raise if not) - - Return OK state with list and count of stand-by client(s) - -Note : This script was originally write for PostgreSQL 9.1 and test on 9.1 and 9.5 but it -could be compatible with other versions of PostgreSQL. Do not hesitate to tell me how this -script work with other versions and share some fix. All contributions are welcome ! - -Requirements ------------- - - * On master node : - - Slaves must be able to connect with user from recovery.conf to database with - the same name (or another specify with -D) as trust (or via md5 using password - specify in ~/.pgpass). - - * On standby node : - - PG_USER must be able to connect localy on the database with the same name - (or another specify with -D) as trust (or via md5 using password specify in - ~/.pgpass). - -Usage ------ - - Usage : ./check_pg_streaming_replication [-h] [-d] [options] - -u pg_user Specify Postgres user (Default : postgres) - -b psql_bin Specify psql binary path (Default : /usr/bin/psql) - -m pg_main Specify Postgres main directory path - (Default : /var/lib/postgresql/9.1/main) - -r recovery_conf Specify Postgres recovery configuration file path - (Default : /var/lib/postgresql/9.1/main/recovery.conf) - -p pg_port Specify default Postgres master TCP port (Default : 5432) - -D dbname Specify DB name on Postgres hosts to connect on (Default : postgres) - -d Debug mode - -h Show this message - -Copyright ---------- - -Copyright (c) 2017 Benjamin Renard - -License -------- - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License version 2 -as published by the Free Software Foundation. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. diff --git a/README.md b/README.md new file mode 100644 index 0000000..e8645e6 --- /dev/null +++ b/README.md @@ -0,0 +1,65 @@ +Nagios plugin to check Postgres Streaming replication +===================================================== + +This script could be used as Nagios check plugin to verify Postgres Streaming replication state. + +This script : + +- check if Postgres is running (CRITICAL raise if not) +- check if Postgres is in recovery mode : + - if Postgres is in recovery mode : + - retreive from Postgres the last xlog file receive and the xlog file replay + - check if Postgres recovery configuration file is NOT present (CRITICAL raise if present) + - retreive master connection informations from Postgres recovery configuration file (UNKNOWN raise on error). Default Postgres master TCP port will be used if port is not specify. + - retreive current xlog file from Postgres master server by making a connection on master server (UNKNOWN raise on error). + - check if the last receive xlog file is the last replay xlog file (WARNING raise if not) + - Return OK state + - if Postgres is not in recovery mode : + - check if Postgres recovery configuration file is present (CRITICAL raise if present) + - check if stand-by client(s) is connected (WARNING raise if not) + - Return OK state with list and count of stand-by client(s) + +**Note :** This script was originally write for PostgreSQL 9.1 and test on 9.1, 9.5 and 9.6 but it could be compatible with other versions of PostgreSQL. Do not hesitate to tell me how this script work with other versions and share some fix. All contributions are welcome ! + +Requirements +------------ + +* **On master node :** Slaves must be able to connect with user from recovery.conf to database with the same name (or another specify with -D) as trust (or via md5 using password specify in ~/.pgpass). + +* **On standby node :** PG_USER must be able to connect localy on the database with the same name (or another specify with -D) as trust (or via md5 using password specify in ~/.pgpass). + +Usage +----- + + Usage : ./check_pg_streaming_replication [-h] [-d] [options] + -u pg_user Specify Postgres user (Default : postgres) + -b psql_bin Specify psql binary path (Default : /usr/bin/psql) + -m pg_main Specify Postgres main directory path + (Default : /var/lib/postgresql/9.1/main) + -r recovery_conf Specify Postgres recovery configuration file path + (Default : /var/lib/postgresql/9.1/main/recovery.conf) + -p pg_port Specify default Postgres master TCP port (Default : 5432) + -D dbname Specify DB name on Postgres hosts to connect on (Default : postgres) + -d Debug mode + -h Show this message + +Copyright +--------- + +Copyright (c) 2014-2019 Benjamin Renard + +License +------- + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License version 2 +as published by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.