MongoDB 插件

概述

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

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

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

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

请注意:

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

Parameter details

Plugins.MongoDB.Default.AuthMechanism

Specify the default authentication mechanism for connecting to MongoDB server.
<SessionName> - define name of a session for using in item keys.

Range: SCRAM-SHA-1, SCRAM-SHA-256, or MONGODB-X509

Plugins.MongoDB.Default.AuthSource

Specify the default database for authenticating connection to MongoDB server.
<SessionName> - define name of a session for using in item keys.

Default: admin

If MONGODB-X509 authentication mechanism is used, this parameter is automatically set to $external; modifying it to any other value will cause an error when launching.

Plugins.MongoDB.Default.Direct

Disable automatic discovery of MongoDB replica set nodes.
<SessionName> - define name of a session for using in item keys.

Default: false Range: true - connect only to the specified server, ignoring other members of the replica set, false - automatically discover all nodes in the replica set.

If the tcp:// (deprecated) scheme is used, the parameter is set to true by default.

Plugins.MongoDB.Default.Password

Specify the default password.
<SessionName> - define name of a session for using in item keys.

Plugins.MongoDB.Default.ReplicaSet

Specify the default replica set name, used for automatic discovery of MongoDB replica set nodes.
<SessionName> - define name of a session for using in item keys.
If this parameter is used with the mongodb+srv:// scheme, it will behave as if multiple URLs have been provided; a DNS server may have a TXT record that can override this (or any other) parameter.
Unavailable if the Plugins.MongoDB.Sessions.<SessionName>.Direct parameter is set to true; the agent will fail to start.

Plugins.MongoDB.Default.ReadPreference

Specify the default order for connecting to MongoDB replica set nodes or fallback.
<SessionName> - define name of a session for using in item keys.
Unavailable if the Plugins.MongoDB.Sessions.<SessionName>.Direct parameter is set to true; the agent will fail to start.

Range: PrimaryMode, PrimaryPreferredMode, SecondaryMode, SecondaryPreferredMode, or NearestMode

Plugins.MongoDB.Default.TLSConnect

Specify the level of encryption required for communications between Zabbix agent 2 and monitored databases.
<SessionName> - define name of a session for using in item keys.
Supported since plugin version 1.2.1.

Range: required - require TLS connection, verify_ca - verify certificates, verify_full - verify certificates and IP address

Plugins.MongoDB.Default.TLSCAFile

Specify full pathname of the file containing the top-level CA(s) certificates for peer certificate verification, used 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.MongoDB.Sessions.<SessionName>.TLSConnect is set to verify_ca or verify_full

Plugins.MongoDB.Default.TLSCertFile

Specify full pathname of the file containing the agent certificate or certificate chain, used 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.MongoDB.Sessions.<SessionName>.TLSKeyFile is specified

Plugins.MongoDB.Default.TLSKeyFile

Specify full pathname of the file containing the database private key, used 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.MongoDB.Sessions.<SessionName>.TLSCertFile is specified

Plugins.MongoDB.Default.Uri

Specify the default URI.
<SessionName> - define name of a session for using in item keys.
Must match the URI format.
Supported schemes: mongodb:// and mongodb+srv://; the tcp:// scheme is deprecated and kept for backward compatibility with existing configurations.
A port can be omitted (default=27017).
Examples: ``

Default: tcp://127.0.0.1:27017

Examples:

mongodb://127.0.0.1:27017
mongodb+srv://example.com
localhost
Plugins.MongoDB.Default.User

Specify the default username.
<SessionName> - define name of a session for using in item keys.

Plugins.MongoDB.KeepAlive

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

Default: 300 Range: 60-900

Plugins.MongoDB.Sessions.<SessionName>.AuthMechanism

Specify the named session authentication mechanism for connecting to MongoDB server.
<SessionName> - define name of a session for using in item keys.

Range: SCRAM-SHA-1, SCRAM-SHA-256, or MONGODB-X509

Plugins.MongoDB.Sessions.<SessionName>.AuthSource

Specify the named session database for authenticating connection to MongoDB server.
<SessionName> - define name of a session for using in item keys.

Default: admin

If MONGODB-X509 authentication mechanism is used, this parameter is automatically set to $external; modifying it to any other value will cause an error when launching.

Plugins.MongoDB.Sessions.<SessionName>.Direct

Disable automatic discovery of MongoDB replica set nodes for named session.
<SessionName> - define name of a session for using in item keys.

Default: false Range: true - connect only to the specified server, ignoring other members of the replica set, false - automatically discover all nodes in the replica set.

If the tcp:// (deprecated) scheme is used, the parameter is set to true by default.

Plugins.MongoDB.Sessions.<SessionName>.Password

Specify the named session password.
<SessionName> - define name of a session for using in item keys.

Plugins.MongoDB.Sessions.<SessionName>.ReplicaSet

Specify the named session replica set name, used for automatic discovery of MongoDB replica set nodes.
<SessionName> - define name of a session for using in item keys.
If this parameter is used with the mongodb+srv:// scheme, it will behave as if multiple URLs have been provided; a DNS server may have a TXT record that can override this (or any other) parameter.
Unavailable if the Plugins.MongoDB.Sessions.<SessionName>.Direct parameter is set to true; the agent will fail to start.

Plugins.MongoDB.Sessions.<SessionName>.ReadPreference

Specify the named session order for connecting to MongoDB replica set nodes or fallback.
<SessionName> - define name of a session for using in item keys.
Unavailable if the Plugins.MongoDB.Sessions.<SessionName>.Direct parameter is set to true; the agent will fail to start.

Range: PrimaryMode, PrimaryPreferredMode, SecondaryMode, SecondaryPreferredMode, or NearestMode

Plugins.MongoDB.Sessions.<SessionName>.TLSConnect

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

Range: required - require TLS connection, verify_ca - verify certificates, verify_full - verify certificates and IP address

Plugins.MongoDB.Sessions.<SessionName>.TLSCAFile

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

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

Plugins.MongoDB.Sessions.<SessionName>.TLSCertFile

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

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

Plugins.MongoDB.Sessions.<SessionName>.TLSKeyFile

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

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

Plugins.MongoDB.Sessions.<SessionName>.Uri

Specify the named session URI.
<SessionName> - define name of a session for using in item keys.
Must match the URI format.
Supported schemes: mongodb:// and mongodb+srv://; the tcp:// scheme is deprecated and kept for backward compatibility with existing configurations.
A port can be omitted (default=27017).
Examples: ``

Default: tcp://127.0.0.1:27017

Examples:

mongodb://127.0.0.1:27017
mongodb+srv://example.com
localhost
Plugins.MongoDB.Sessions.<SessionName>.User

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

Plugins.MongoDB.System.Path

Specify path to the MongoDB plugin executable.

Example usage: Plugins.MongoDB.System.Path=/usr/libexec/zabbix/zabbix-agent2-plugin-mongodb

Plugins.MongoDB.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> 启动插件进行测试(忽略插件配置)。

参数

连接到 MongoDB 时,插件会按特定顺序检查其配置,这决定了要使用哪个值。 从高到低的优先级顺序如下:

  1. 连接 URI 中指定的参数(例如,在 Plugins.MongoDB.Sessions.<session_name>.Uri? 后定义的查询参数优先级最高)。
  2. Zabbix agent 2 监控项键中的参数(例如,mongodb.collection.stats)。
  3. 在命名会话中定义的参数(例如,Plugins.MongoDB.Sessions.<SessionName>.UserPlugins.MongoDB.Sessions.<SessionName>.Password)。
  4. 默认值(例如,Plugins.MongoDB.Default.UserPlugins.MongoDB.Default.Password)。

例如:

  • 如果您在 *.<SessionName>.Uri 参数中指定用于对 MongoDB 服务器连接进行身份验证的数据库(例如,Plugins.MongoDB.Sessions.<session_name>.Uri=mongodb://user:[email protected]:27017/?authSource=admin),那么插件会将 *.<SessionName>.AuthSource 参数视为已设置为 admin,即使 *.<SessionName>.AuthSource 参数设置为其他值也是如此。
  • 如果您在 *.<SessionName>.Uri 参数中指定 URI(例如,Plugins.MongoDB.Sessions.<session_name>.Uri=mongodb://127.0.0.1:27017),但在 Zabbix agent 2 监控项键中提供用户名和密码,则插件将使用监控项键中的用户名和密码,即使已配置 Plugins.MongoDB.Sessions.<SessionName>.UserPlugins.MongoDB.Sessions.<SessionName>.Password 也是如此。

如果使用 mongodb+srv:// 方案,URI 可能会从 DNS TXT 记录中获取参数。 从该 TXT 记录获取的参数会覆盖所有其他配置,包括 URI 参数、Zabbix Agent 2 监控项键参数以及会话参数。
连接字符串中使用的主机名只能存在一个 TXT 记录。

Parameter Mandatory Range Default Description
Plugins.MongoDB.System.Path no MongoDB 插件可执行文件的路径。
示例用法:Plugins.MongoDB.System.Path=/usr/libexec/zabbix/zabbix-agent2-plugin-mongodb
Plugins.MongoDB.Timeout no 1-30 global timeout 请求执行超时时间(即在关闭请求之前等待其完成的秒数)。
Plugins.MongoDB.KeepAlive no 60-900 300 关闭未使用的插件连接之前的最长等待时间(秒)。
Plugins.MongoDB.Sessions.<SessionName>.Uri no tcp://127.0.0.1:27017 命名会话的连接字符串。
<SessionName> - 定义一个会话名称,用于监控项键中。

必须符合 URI 格式。
支持的方案:mongodb://mongodb+srv://tcp:// 方案已弃用,仅为兼容现有配置而保留。
端口可以省略(默认=27017)。
示例:mongodb://127.0.0.1:27017mongodb+srv://example.comlocalhost
Plugins.MongoDB.Sessions.<SessionName>.User no 命名会话用户名。
<SessionName> - 定义一个会话名称,用于监控项键中。
Plugins.MongoDB.Sessions.<SessionName>.Password no 命名会话密码。
<SessionName> - 定义一个会话名称,用于监控项键中。
Plugins.MongoDB.Sessions.<SessionName>.Direct no false 用于确定是否启用或禁用 MongoDB 副本集节点自动发现的连接方式。
<SessionName> - 定义一个会话名称,用于监控项键中。

支持的值:
true - 插件将仅连接到指定的服务器,忽略副本集中的其他成员;
false - 插件将自动发现副本集中的所有节点。
如果使用 tcp://(已弃用)方案,则该参数默认设置为 true
Plugins.MongoDB.Sessions.<SessionName>.AuthMechanism no 连接到 MongoDB 服务器时使用的身份验证机制。
<SessionName> - 定义一个会话名称,用于监控项键中。

支持的值:SCRAM-SHA-1SCRAM-SHA-256MONGODB-X509
Plugins.MongoDB.Sessions.<SessionName>.AuthSource no admin 用于对 MongoDB 服务器连接进行身份验证的数据库。
<SessionName> - 定义一个会话名称,用于监控项键中。

如果使用 MONGODB-X509 身份验证机制,则此参数会自动设置为 $external;将其修改为任何其他值都会在启动时导致错误。
Plugins.MongoDB.Sessions.<SessionName>.ReplicaSet no 副本集名称,用于 MongoDB 副本集节点的自动发现。
<SessionName> - 定义一个会话名称,用于监控项键中。

如果将此参数与 mongodb+srv:// 方案一起使用,其行为将如同提供了多个 URL;DNS 服务器可能包含一个 TXT 记录,可覆盖此参数(或任何其他参数)。

如果 Plugins.MongoDB.Sessions.<SessionName>.Direct 参数设置为 true,则不可用,agent 将无法启动。
Plugins.MongoDB.Sessions.<SessionName>.ReadPreference no 连接到 MongoDB 副本集节点或回退时的顺序。
<SessionName> - 定义一个会话名称,用于监控项键中。

支持的值:PrimaryModePrimaryPreferredModeSecondaryModeSecondaryPreferredModeNearestMode
如果 Plugins.MongoDB.Sessions.<SessionName>.Direct 参数设置为 true,则不可用,agent 将无法启动。
Plugins.MongoDB.Sessions.<SessionName>.TLSConnect no Zabbix agent 2 与受监控数据库之间通信的加密类型。
<SessionName> - 定义一个会话名称,用于监控项键中。

支持的值:
required - 要求 TLS 连接;
verify\_ca - 验证证书;
verify\_full - 验证证书和 IP 地址。

自插件版本 1.2.1 起支持。
Plugins.MongoDB.Sessions.<SessionName>.TLSCAFile yes, if Plugins.MongoDB.Sessions.<SessionName>.TLSConnect is set to one of: verify_ca, verify_full 包含用于对等证书验证的顶级 CA 证书的文件完整路径名,用于 Zabbix agent 2 与受监控数据库之间的加密通信。
<SessionName> - 定义一个会话名称,用于监控项键中。
Plugins.MongoDB.Sessions.<SessionName>.TLSCertFile yes, if Plugins.MongoDB.Sessions.<SessionName>.TLSKeyFile is specified 包含 agent 证书或证书链的文件完整路径名,用于 Zabbix agent 2 与受监控数据库之间的加密通信。
<SessionName> - 定义一个会话名称,用于监控项键中。
Plugins.MongoDB.Sessions.<SessionName>.TLSKeyFile yes, if Plugins.MongoDB.Sessions.<SessionName>.TLSCertFile is specified 包含用于 Zabbix agent 2 与受监控数据库之间加密通信的数据库私钥的文件完整路径名。
<SessionName> - 定义一个会话名称,用于监控项键中。
Plugins.MongoDB.Default.Uri no tcp://127.0.0.1:27017 连接 MongoDB 的默认 URI。

必须符合 URI 格式。
支持的方案:mongodb://mongodb+srv://
已弃用的方案:tcp://(作为默认值仅用于与现有配置保持向后兼容)。
端口可以省略(默认=27017)。
示例:mongodb://127.0.0.1:27017mongodb+srv://example.comlocalhost
Plugins.MongoDB.Default.User no 连接 MongoDB 的默认用户名。
Plugins.MongoDB.Default.Password no 连接 MongoDB 的默认密码。
Plugins.MongoDB.Default.Direct no false 用于确定是否启用或禁用 MongoDB 副本集节点自动发现的默认连接方式。

支持的值:
true - 插件将仅连接到指定的服务器,忽略副本集中的其他成员;
false - 插件将自动发现副本集中的所有节点。
如果使用 tcp://(已弃用)方案,则该参数默认设置为 true
Plugins.MongoDB.Default.AuthMechanism no 连接到 MongoDB 服务器的默认身份验证机制。

支持的值:SCRAM-SHA-1SCRAM-SHA-256MONGODB-X509
如果在此处、监控项键、命名会话或 URI 中都未指定值,则将使用基于 SCRAM 的机制(如果提供了用户名);否则,不会使用身份验证。
Plugins.MongoDB.Default.AuthSource no admin 连接到 MongoDB 服务器时用于身份验证的默认数据库。

如果使用 MONGODB-X509 身份验证机制,则此参数会自动设置为 $external;将其修改为任何其他值都会在启动时导致错误。
Plugins.MongoDB.Default.ReplicaSet no 默认副本集名称;用于 MongoDB 副本集节点的自动发现。

如果将此参数与 mongodb+srv:// 方案一起使用,其行为将如同提供了多个 URL;DNS 服务器可能包含一个 TXT 记录,可覆盖此参数(或任何其他参数)。
如果 Plugins.MongoDB.Default.Direct 参数设置为 true,则不可用,agent 将无法启动。
Plugins.MongoDB.Default.ReadPreference no 连接到 MongoDB 副本集节点或回退时的默认顺序。

支持的值:PrimaryModePrimaryPreferredModeSecondaryModeSecondaryPreferredModeNearestMode
如果 Plugins.MongoDB.Default.Direct 参数设置为 true,则不可用,agent 将无法启动。
Plugins.MongoDB.Default.TLSConnect no Zabbix agent 2 与受监控数据库之间通信的默认加密类型。

支持的值:
required - 需要 TLS 连接。
verify\_ca - 验证证书。
verify\_full - 验证证书和 IP 地址。
如果在此处、监控项键、命名会话或 URI 中都未指定值,则不会建立 TLS 连接。
Plugins.MongoDB.Default.TLSCAFile no 包含用于对等证书验证的顶级 CA 证书的默认文件完整路径名。用于 Zabbix agent 2 与受监控数据库之间的加密通信。
Plugins.MongoDB.Default.TLSCertFile no 包含 MongoDB 客户端证书或证书链的默认文件完整路径名。用于 Zabbix agent 2 与受监控数据库之间的加密通信。
Plugins.MongoDB.Default.TLSKeyFile no 包含用于 Zabbix agent 2 与受监控数据库之间加密通信的 MongoDB 客户端私钥的默认文件完整路径名。

另请参见: