PostgreSQL 插件

概述

配置参数可用于自定义 PostgreSQL 插件的行为。

建议将这些参数指定在它们自己的配置文件中(例如 postgresql.conf),而不是放在 agent 2 配置文件中。然后使用 Include 指令将此文件包含到 Zabbix agent 2 配置中。

PostgreSQL 插件是一个可加载插件,可在 PostgreSQL plugin repository 中获取并查看完整说明。

除非明确说明该参数为必填,否则所有参数均为可选

请注意:

  • 默认值反映的是进程默认值,而不是随软件提供的配置文件中的值。
  • 值支持 环境变量
  • Zabbix 仅支持 UTF-8 编码且不带 BOM 的配置文件。
  • 以 "#" 开头的注释仅在行首支持。

Parameter details

Plugins.PostgreSQL.CallTimeout

Set the maximum wait time in seconds for a request to be completed.

Default: global timeout
Range: 1-30

Plugins.PostgreSQL.CustomQueriesPath

Specify full pathname of the directory containing .sql files with custom queries.

Defaults:
/usr/local/share/zabbix/custom-queries/postgreSQL - for Unix systems,
*:\Program Files\Zabbix Agent 2\Custom Queries\PostgreSQL - for Windows systems (where * is the drive name from the ProgramFiles environment variable)

Example:

/etc/zabbix/oracle/sql
Plugins.PostgreSQL.CustomQueriesEnabled

Enable execution of the postgresql.custom.query item key.
If disabled, no queries will be loaded from the custom query directory path.

Default: false
Range: true/false

Plugins.PostgreSQL.Default.CacheMode

Specify the default cache mode for the PostgreSQL connection.

Default: prepare
Range:
prepare - create prepared statements on the PostgreSQL server;
describe - use the anonymous prepared statement to describe a statement without creating a statement on the server.

Note that describe is primarily useful when the environment does not allow prepared statements such as when running a connection pooler like PgBouncer.

Plugins.PostgreSQL.Default.Database

Specify the default database for connecting to PostgreSQL.
Used if no value is specified in an item key or named session.

Plugins.PostgreSQL.Default.Password

Specify the default password for connecting to PostgreSQL.
Used if no value is specified in an item key or named session.

Plugins.PostgreSQL.Default.TLSCAFile

Specify full pathname of the file containing the top-level CA(s) certificate for peer certificate verification for encrypted communications between Zabbix agent 2 and monitored databases.
Used if no value is specified in a named session.

Mandatory: yes, if Plugins.PostgreSQL.Default.TLSConnect is set to verify_ca or verify_full

Plugins.PostgreSQL.Default.TLSCertFile

Specify full pathname of the file containing the PostgreSQL certificate or certificate chain for encrypted communications between Zabbix agent 2 and monitored databases.
Used if no value is specified in a named session.

Mandatory: yes, if Plugins.PostgreSQL.Default.TLSKeyFile is specified

Plugins.PostgreSQL.Default.TLSConnect

Specify the default level of encryption for communications between Zabbix agent 2 and monitored databases.
Used if no value is specified in a named session.

Range:
required - connect using TLS as transport mode without identity checks;
verify_ca - connect using TLS and verify certificate;
verify_full - connect using TLS, verify certificate and verify that database identity (CN) specified by DBHost matches its certificate.

Undefined encryption type means unencrypted connection.

Plugins.PostgreSQL.Default.TLSKeyFile

Specify full pathname of the file containing the PostgreSQL private key for encrypted communications between Zabbix agent 2 and monitored databases.
Used if no value is specified in a named session.

Mandatory: yes, if Plugins.PostgreSQL.Default.TLSCertFile is specified

Plugins.PostgreSQL.Default.Uri

Specify the default URI for connecting to PostgreSQL.
Used if no value is specified in an item key or named session.
Embedded credentials will be ignored.
Must match the URI format.
Supported schemes: tcp, unix

Examples:

tcp://127.0.0.1:5432
tcp://localhost
unix:/var/run/postgresql/.s.PGSQL.5432
Plugins.PostgreSQL.Default.User

Specify the default username for connecting to PostgreSQL.
Used if no value is specified in an item key or named session.

Plugins.PostgreSQL.KeepAlive

Set the maximum time of waiting (in seconds) before unused plugin connections are closed.

Plugins.PostgreSQL.Sessions.<SessionName>.CacheMode

Specify the named session cache mode for the PostgreSQL connection.
<SessionName> - define name of a session for using in item keys.

Default: prepare
Range:
prepare - create prepared statements on the PostgreSQL server;
describe - use the anonymous prepared statement to describe a statement without creating a statement on the server.

Note that describe is primarily useful when the environment does not allow prepared statements such as when running a connection pooler like PgBouncer.

Plugins.PostgreSQL.Sessions.<SessionName>.Database

Specify the named session database for connecting to PostgreSQL.
<SessionName> - define name of a session for using in item keys.

Plugins.PostgreSQL.Sessions.<SessionName>.Password

Specify the named session password for connecting to PostgreSQL.
<SessionName> - define name of a session for using in item keys.
Must match the password format.

Plugins.PostgreSQL.Sessions.<SessionName>.TLSCAFile

Specify full pathname of the file containing the top-level CA(s) certificate for peer certificate verification for encrypted communications between Zabbix agent 2 and monitored databases.
<SessionName> - define name of a session for using in item keys.

Mandatory: yes, if Plugins.PostgreSQL.Sessions.<SessionName>.TLSConnect is set to verify_ca or verify_full

Plugins.PostgreSQL.Sessions.<SessionName>.TLSCertFile

Specify full pathname of the file containing the PostgreSQL certificate or certificate chain for encrypted communications between Zabbix agent 2 and monitored databases.
<SessionName> - define name of a session for using in item keys.

Mandatory: yes, if Plugins.PostgreSQL.Sessions.<SessionName>.TLSKeyFile is specified

Plugins.PostgreSQL.Sessions.<SessionName>.TLSConnect

Specify the named session level of encryption for communications between Zabbix agent 2 and monitored databases.
<SessionName> - define name of a session for using in item keys.

Range:
required - connect using TLS as transport mode without identity checks;
verify_ca - connect using TLS and verify certificate;
verify_full - connect using TLS, verify certificate and verify that database identity (CN) specified by DBHost matches its certificate.

Undefined encryption type means unencrypted connection.

Plugins.PostgreSQL.Sessions.<SessionName>.TLSKeyFile

Specify full pathname of the file containing the PostgreSQL private key for encrypted communications between Zabbix agent 2 and monitored databases.
<SessionName> - define name of a session for using in item keys.

Mandatory: yes, if Plugins.PostgreSQL.Sessions.<SessionName>.TLSCertFile is specified.

Plugins.PostgreSQL.Sessions.<SessionName>.Uri

Specify the named session URI for connecting to PostgreSQL.
<SessionName> - define name of a session for using in item keys.
Embedded credentials will be ignored.
Must match the URI format.
Supported schemes: tcp, unix

Examples:

tcp://127.0.0.1:5432
tcp://localhost
unix:/var/run/postgresql/.s.PGSQL.5432
Plugins.PostgreSQL.Sessions.<SessionName>.User

Specify the named session username for connecting to PostgreSQL.
<SessionName> - define name of a session for using in item keys.

Plugins.PostgreSQL.System.Path

Specify path to the PostgreSQL plugin executable.

Mandatory: yes

Example:

Plugins.PostgreSQL.System.Path=/usr/libexec/zabbix/zabbix-agent2-plugin-postgresql
Plugins.PostgreSQL.Timeout

Set the request execution timeout (the duration, in seconds, to wait for a request to complete before shutting it down).

Default: global timeout
Range: 1-30

选项

Parameter Description
-V --version 打印插件版本和许可证信息。
-h --help 打印帮助信息(简写)。
-t, --test <item key> 启动插件进行测试(忽略插件配置)。

参数

Parameter Mandatory Range Default Description
Plugins.PostgreSQL.Default.CacheMode no prepare PostgreSQL 连接的缓存模式。
支持的值:
prepare(默认)- 会在 PostgreSQL 服务器上创建预处理语句;
describe - 将使用匿名预处理语句来描述语句,而不在服务器上创建语句。
请注意,"describe" 主要适用于环境不允许使用预处理语句的情况,例如运行 PgBouncer 之类的连接池器时。
Plugins.PostgreSQL.CallTimeout no 1-30 global timeout 请求完成的最大等待时间(秒)。
Plugins.PostgreSQL.CustomQueriesPath no Unix 系统为 /usr/local/share/zabbix/custom-queries/postgreSQL

Windows 系统为 *:\Program Files\Zabbix Agent 2\Custom Queries\PostgreSQL,其中 *ProgramFiles 环境变量中的驱动器名称
包含自定义查询 .sql 文件的目录完整路径。
Plugins.PostgreSQL.CustomQueriesEnabled no false 如果设置,则启用 postgresql.custom.query 监控项键的执行。如果禁用,则不会从自定义查询目录路径加载任何查询。
Plugins.PostgreSQL.Default.Database no 用于连接 PostgreSQL 的默认数据库;如果监控项键或命名会话中未指定值,则使用该值。
Plugins.PostgreSQL.Default.Password no 用于连接 PostgreSQL 的默认密码;如果监控项键或命名会话中未指定值,则使用该值。
Plugins.PostgreSQL.Default.TLSCAFile no
(yes, if Plugins.PostgreSQL.Default.TLSConnect is set to verify_ca or verify_full)
包含用于对等证书验证的顶级 CA 证书的文件完整路径,用于 Zabbix agent 2 与受监控数据库之间的加密通信;如果命名会话中未指定值,则使用该值。
Plugins.PostgreSQL.Default.TLSCertFile no
(yes, if Plugins.PostgreSQL.Default.TLSConnect is set to verify_ca or verify_full)
包含 PostgreSQL 证书或证书链的文件完整路径,用于 Zabbix agent 2 与受监控数据库之间的加密通信;如果命名会话中未指定值,则使用该值。
Plugins.PostgreSQL.Default.TLSConnect no Zabbix agent 2 与受监控数据库之间通信的加密类型;如果命名会话中未指定值,则使用该值。
支持的值:
required - 使用 TLS 作为传输模式连接,不进行身份检查;
verify_ca - 使用 TLS 连接并验证证书;
verify_full - 使用 TLS 连接,验证证书,并验证 DBHost 指定的数据库标识(CN)是否与其证书匹配。
未定义的加密类型表示未加密连接。
Plugins.PostgreSQL.Default.TLSKeyFile no
(yes, if Plugins.PostgreSQL.Default.TLSConnect is set to verify_ca or verify_full)
包含 PostgreSQL 私钥的文件完整路径,用于 Zabbix agent 2 与受监控数据库之间的加密通信;如果命名会话中未指定值,则使用该值。
Plugins.PostgreSQL.Default.Uri no 用于连接 PostgreSQL 的默认 URI;如果监控项键或命名会话中未指定值,则使用该值。

不应包含嵌入式凭据(它们将被忽略)。
必须符合 URI 格式。
支持的方案:tcpunix
示例:tcp://127.0.0.1:5432
tcp://localhost
unix:/var/run/postgresql/.s.PGSQL.5432
Plugins.PostgreSQL.Default.User no 用于连接 PostgreSQL 的默认用户名;如果监控项键或命名会话中未指定值,则使用该值。
Plugins.PostgreSQL.KeepAlive no 60-900 300 关闭未使用的插件连接前的最长等待时间(秒)。
Plugins.PostgreSQL.Sessions.<SessionName>.CacheMode no prepare PostgreSQL 连接的缓存模式。
<SessionName> - 定义用于监控项键中的会话名称。
支持的值:
prepare(默认)- 会在 PostgreSQL 服务器上创建预处理语句;
describe - 将使用匿名预处理语句来描述语句,而不在服务器上创建语句。
请注意,"describe" 主要适用于环境不允许使用预处理语句的情况,例如运行 PgBouncer 之类的连接池器时。
Plugins.PostgreSQL.Sessions.<SessionName>.Database no 会话连接所用的数据库。
<SessionName> - 定义用于监控项键中的会话名称。
Plugins.PostgreSQL.Sessions.<SessionName>.Password no Must match the password format. 会话连接的密码。
<SessionName> - 定义用于监控项键中的会话名称。
Plugins.PostgreSQL.Sessions.<SessionName>.TLSCAFile no
(yes, if Plugins.PostgreSQL.Sessions.<SessionName>.TLSConnect is set to verify_ca or verify_full)
包含顶级 CA 证书的文件完整路径,用于对等证书验证。
<SessionName> - 定义用于监控项键中的会话名称。
Plugins.PostgreSQL.Sessions.<SessionName>.TLSCertFile yes, if Plugins.PostgreSQL.Sessions.<SessionName>.TLSKeyFile is specified 包含 PostgreSQL 证书或证书链的文件完整路径。
<SessionName> - 定义用于监控项键中的会话名称。
Plugins.PostgreSQL.Sessions.<SessionName>.TLSConnect no PostgreSQL 连接的加密类型。
<SessionName> - 定义用于监控项键中的会话名称。

支持的值:
required - 使用 TLS 作为传输模式连接,不进行身份检查;
verify_ca - 使用 TLS 连接并验证证书;
verify_full - 使用 TLS 连接,验证证书,并验证 DBHost 指定的数据库标识(CN)是否与其证书匹配。
未定义的加密类型表示未加密连接。
Plugins.PostgreSQL.Sessions.<SessionName>.TLSKeyFile yes, if Plugins.PostgreSQL.Sessions.<SessionName>.TLSCertFile is specified 包含 PostgreSQL 私钥的文件完整路径。
<SessionName> - 定义用于监控项键中的会话名称。
Plugins.PostgreSQL.Sessions.<SessionName>.Uri no 命名会话的连接字符串。
<SessionName> - 定义用于监控项键中的会话名称。

不应包含嵌入式凭据(它们将被忽略)。
必须符合 URI 格式。
支持的方案:tcpunix
示例:tcp://127.0.0.1:5432
tcp://localhost
unix:/var/run/postgresql/.s.PGSQL.5432
Plugins.PostgreSQL.Sessions.<SessionName>.User no 命名会话用户名。
<SessionName> - 定义用于监控项键中的会话名称。
Plugins.PostgreSQL.System.Path yes PostgreSQL 插件可执行文件的路径。
示例用法:Plugins.PostgreSQL.System.Path=/usr/libexec/zabbix/zabbix-agent2-plugin-postgresql
Plugins.PostgreSQL.Timeout no 1-30 global timeout 请求执行超时(即在关闭请求之前等待其完成的时长,单位为秒)。

另请参见: