feat(template): remove ODBC template, move agent2 SQL, and track template directory

This commit is contained in:
Maksym Buz
2026-03-30 19:55:12 +00:00
parent d02a24ebd8
commit d8233d53d5
4 changed files with 120 additions and 1 deletions

35
template/README.md Normal file
View File

@@ -0,0 +1,35 @@
# Zabbix PostgreSQL Partitioning Monitoring
This directory contains an extremely efficient, production-ready Zabbix Native Agent 2 monitoring suite designed to track the health of your actively partitioned PostgreSQL database tables.
This template natively leverages the Zabbix Agent 2 backend. It uses a single, highly-optimized master payload query (`partitions.get_all.sql`) to pull all metrics in bulk over a single database connection, dynamically distributing the numbers to Zabbix using Dependent Items.
### Step-by-Step Setup
1. Copy the **one** SQL file (`template/partitions.get_all.sql`) into a secure directory on your Agent machine. E.g., `/etc/zabbix/zabbix_agent2.d/postgresql/`.
2. Secure the local Linux permissions so the Zabbix user can strictly read it:
```bash
chown -R zabbix:zabbix /etc/zabbix/zabbix_agent2.d/postgresql
chmod 644 /etc/zabbix/zabbix_agent2.d/postgresql/*.sql
```
3. Open your main `/etc/zabbix/zabbix_agent2.conf` file. Scroll to the absolute bottom and add these exact lines to safely establish your custom query module AND a secure named session (e.g., `AWS_RDS`):
```ini
# 1. Enable Loadable Custom Queries (Mandatory in Zabbix 7.4+)
Plugins.PostgreSQL.CustomQueriesPath=/etc/zabbix/zabbix_agent2.d/postgresql/
Plugins.PostgreSQL.CustomQueriesEnabled=true
# 2. Establish a Secure Backend Session
Plugins.PostgreSQL.Sessions.AWS_RDS.Uri=tcp://your-cluster-endpoint.amazonaws.com:5432
Plugins.PostgreSQL.Sessions.AWS_RDS.User=zabbix
Plugins.PostgreSQL.Sessions.AWS_RDS.Password=<YOUR_ZABBIX_PASSWORD>
Plugins.PostgreSQL.Sessions.AWS_RDS.TLSConnect=verify_full
Plugins.PostgreSQL.Sessions.AWS_RDS.TLSCAFile=/etc/zabbix/global-bundle.pem
```
4. Restart your agent to lock the session and SSL configurations into memory:
```bash
systemctl restart zabbix-agent2
```
5. Import the `zbx_pg_partitions_monitor_agent2.yaml` template directly into your Zabbix Frontend.
6. Attach the template to your Host, navigate to its "Macros" tab, and define strictly exactly this **one** macro:
* `{$PG.CONNSTRING.AGENT2}`: `AWS_RDS`
*(By pointing this macro to the Session name we built in Step 3, you are telling Zabbix to seamlessly abandon all plaintext frontend passwords and rely 100% on the encrypted local session parameters!)*