概述
check_postgres是一个用于监控数据库各种属性的脚本。它旨在与 Nagios、MRTG 或独立脚本一起使用。
官网: Check postgres
完整安装
从官网下载tar包
[root@check_postgres ~]# mkdir -p /opt/check_postgres/bin
[root@check_postgres ~]# chown postgres:postgres /opt/check_postgres/ -R
[root@check_postgres ~]# su - postgres
# 上传安装包到/home/postgres
tar -xf check_postgres.tar.gz
cd /home/postgres/check_postgres-2.25.0
# check_postgres.pl是Perl脚本,可能需要安装perl的依赖
# yum install perl-Time-HiRes
apt-get install -y make
# 完整安装
perl Makefile.PL
make
env -i make test
# 用root执行
make install
su - postgres
cd /opt/check_postgres/bin
check_postgres.pl --symlinks
ls
# 使用举例,检查数据库连接
check_postgres_connection -db postgres
POSTGRES_CONNECTION OK: DB "postgres" version 14.5 | time=0.04s
更多检查脚本使用帮助,参考官方文档,或使用man check_postgres查看
使用帮助手册
本手册描述了一些check_postgres.pl(版本 2.25.0)的一些特性和使用说明。本文内容主要参考了官方说明文档:check_postgres.pl
check_postgres是一个监控脚本集合,使用时可以通过两种方式调用特定的功能,第一种是使用check_postgres --action=XXXX,action是监控的选项;另一种是调用check_postgres_XXXX的方式。
在开始前,可以通过下面方式先创建symlinks
#创建所有symlinks
cd /opt/check_postgres/bin
check_postgres.pl --symlinks
ls -ll
就能看到创建的所有监控脚本的symlinks
postgres@host22:/opt/check_postgres/bin$ ls -ll
total 0
8月 18 17:12 check_postgres_archive_ready -> /usr/local/bin/check_postgres.pl
8月 18 17:12 check_postgres_autovac_freeze -> /usr/local/bin/check_postgres.pl
8月 18 17:12 check_postgres_backends -> /usr/local/bin/check_postgres.pl
8月 18 17:12 check_postgres_bloat -> /usr/local/bin/check_postgres.pl
8月 18 17:12 check_postgres_checkpoint -> /usr/local/bin/check_postgres.pl
8月 18 17:12 check_postgres_cluster_id -> /usr/local/bin/check_postgres.pl
8月 18 17:12 check_postgres_commitratio -> /usr/local/bin/check_postgres.pl
8月 18 17:12 check_postgres_connection -> /usr/local/bin/check_postgres.pl
8月 18 17:12 check_postgres_custom_query -> /usr/local/bin/check_postgres.pl
8月 18 17:12 check_postgres_database_size -> /usr/local/bin/check_postgres.pl
8月 18 17:12 check_postgres_dbstats -> /usr/local/bin/check_postgres.pl
8月 18 17:12 check_postgres_disabled_triggers -> /usr/local/bin/check_postgres.pl
8月 18 17:12 check_postgres_disk_space -> /usr/local/bin/check_postgres.pl
8月 18 17:12 check_postgres_fsm_pages -> /usr/local/bin/check_postgres.pl
8月 18 17:12 check_postgres_fsm_relations -> /usr/local/bin/check_postgres.pl
8月 18 17:12 check_postgres_hitratio -> /usr/local/bin/check_postgres.pl
8月 18 17:12 check_postgres_hot_standby_delay -> /usr/local/bin/check_postgres.pl
8月 18 17:12 check_postgres_indexes_size -> /usr/local/bin/check_postgres.pl
8月 18 17:12 check_postgres_index_size -> /usr/local/bin/check_postgres.pl
8月 18 17:12 check_postgres_last_analyze -> /usr/local/bin/check_postgres.pl
8月 18 17:12 check_postgres_last_autoanalyze -> /usr/local/bin/check_postgres.pl
8月 18 17:12 check_postgres_last_autovacuum -> /usr/local/bin/check_postgres.pl
8月 18 17:12 check_postgres_last_vacuum -> /usr/local/bin/check_postgres.pl
8月 18 17:12 check_postgres_listener -> /usr/local/bin/check_postgres.pl
8月 18 17:12 check_postgres_locks -> /usr/local/bin/check_postgres.pl
8月 18 17:12 check_postgres_logfile -> /usr/local/bin/check_postgres.pl
8月 18 17:12 check_postgres_new_version_bc -> /usr/local/bin/check_postgres.pl
8月 18 17:12 check_postgres_new_version_box -> /usr/local/bin/check_postgres.pl
8月 18 17:12 check_postgres_new_version_cp -> /usr/local/bin/check_postgres.pl
8月 18 17:12 check_postgres_new_version_pg -> /usr/local/bin/check_postgres.pl
8月 18 17:12 check_postgres_new_version_tnm -> /usr/local/bin/check_postgres.pl
8月 18 17:12 check_postgres_pgagent_jobs -> /usr/local/bin/check_postgres.pl
8月 18 17:12 check_postgres_pgbouncer_backends -> /usr/local/bin/check_postgres.pl
8月 18 17:12 check_postgres_pgbouncer_checksum -> /usr/local/bin/check_postgres.pl
8月 18 17:12 check_postgres_pgb_pool_cl_active -> /usr/local/bin/check_postgres.pl
8月 18 17:12 check_postgres_pgb_pool_cl_waiting -> /usr/local/bin/check_postgres.pl
8月 18 17:12 check_postgres_pgb_pool_maxwait -> /usr/local/bin/check_postgres.pl
8月 18 17:12 check_postgres_pgb_pool_sv_active -> /usr/local/bin/check_postgres.pl
8月 18 17:12 check_postgres_pgb_pool_sv_idle -> /usr/local/bin/check_postgres.p