plugins icon indicating copy to clipboard operation
plugins copied to clipboard

net-mgmt/zabbix-agent: Can't make use of HA in Zabbix agent

Open Alwaysin opened this issue 1 year ago • 2 comments

Important notices Before you add a new report, we ask you kindly to acknowledge the following:

  • [ x] I have read the contributing guide lines at https://github.com/opnsense/plugins/blob/master/CONTRIBUTING.md
  • [ x] I have searched the existing issues, open and closed, and I'm convinced that mine is new.
  • [ x] The title contains the plugin to which this issue belongs

Describe the bug os-zabbix7-agent version 1.14 on OPNsense 24.7.5_3-amd64

Can't make use of clusters in Zabbix agent, when adding active check servers separated by semicolon, we're getting this error:

Please provide valid active check receivers, i.e. 10.0.0.1:10051, zabbix.example.com or [::1]:30051.

To Reproduce Steps to reproduce the behavior:

  1. Go to 'Zabbix Features' (/ui/zabbixagent#tab_zabbixagent-settings-features)
  2. Click on 'Active Check Servers'
  3. Add two servers separated by semicolon (new feature to make use of a cluster of proxy - this is not the same as using a comma or a colon)
  4. See error

Expected behavior Taking the configuration into account

Screenshots chrome_Or38W6eX1F

Relevant log files If applicable, information from log files supporting your claim.

Additional context Zabbix explanations on default config file :

### Option: ServerActive
#       Zabbix server/proxy address or cluster configuration to get active checks from.
#       Server/proxy address is IP address or DNS name and optional port separated by colon.
#       Cluster configuration is one or more server addresses separated by semicolon.
#       Multiple Zabbix servers/clusters and Zabbix proxies can be specified, separated by comma.
#       More than one Zabbix proxy should not be specified from each Zabbix server/cluster.
#       If Zabbix proxy is specified then Zabbix server/cluster for that proxy should not be specified.
#       Multiple comma-delimited addresses can be provided to use several independent Zabbix servers in parallel. Spaces are allowed.
#       If port is not specified, default port is used.
#       IPv6 addresses must be enclosed in square brackets if port for that host is specified.
#       If port is not specified, square brackets for IPv6 addresses are optional.
#       If this parameter is not specified, active checks are disabled.
#       Example for Zabbix proxy:
#               ServerActive=127.0.0.1:10051
#       Example for multiple servers:
#               ServerActive=127.0.0.1:20051,zabbix.domain,[::1]:30051,::1,[12fc::1]
#       Example for high availability:
#               ServerActive=zabbix.cluster.node1;zabbix.cluster.node2:20051;zabbix.cluster.node3
#       Example for high availability with two clusters and one server:
#               ServerActive=zabbix.cluster.node1;zabbix.cluster.node2:20051,zabbix.cluster2.node1;zabbix.cluster2.node2,zabbix.domain
#
# Mandatory: no
# Default:
# ServerActive=

Environment Software version used and hardware type if relevant.

Alwaysin avatar Oct 08 '24 13:10 Alwaysin

It appears if the config file for the proxy is manually changed in the shell with semi-colon, the service will function as intended if that helps. This to me points to a web ui sanity check throwing the error. This problem exists in the package for 6.0 proxies as well

joewhipple avatar Oct 08 '24 20:10 joewhipple

This can be resolved by modifying the regex in this location: https://github.com/opnsense/plugins/blob/b6db17f7b035f30a474c680d37370edb5513975c/net-mgmt/zabbix-agent/src/opnsense/mvc/app/models/OPNsense/ZabbixAgent/ZabbixAgent.xml#L118

Simply replace the , with [,;] in which the regular expression would look like this: ^([a-zA-Z0-9\.:\[\]\-]*?[,;])*([a-zA-Z0-9\.:\[\]\-]*)$

This allows you to add cluster configuration and separate servers, for example: ServerActive=node1.cluster1;node2.cluster1,node1.cluster2

If you wish to make the modification immediately, you can modify the file directly in OPNsense at /usr/local/opnsense/mvc/app/models/OPNsense/ZabbixAgent/ZabbixAgent.xml

muriloglix avatar Oct 29 '25 18:10 muriloglix