【Postgresql】check_postgres插件安装和使用

这篇文章详细介绍了check_postgres脚本的安装、使用方法,以及其提供的各种数据库监控功能,如连接状态、大小、性能指标等,适合与Nagios、MRTG配合进行数据库健康检查。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

概述

check_postgres是一个用于监控数据库各种属性的脚本。它旨在与 Nagios、MRTG 或独立脚本一起使用。

官网: Check postgres

Git: GitHub - bucardo/check_postgres: Nagios check_postgres plugin for checking status of PostgreSQL databases

 完整安装

从官网下载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

使用帮助手册

本手册描述了一些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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值