[ZBX-21223] Parameter ControlSocket cannot be redefined in zabbix_agent2.d/*.conf Created: 2022 Jun 19  Updated: 2026 Mar 23  Resolved: 2026 Mar 23

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Agent2 plugin (G)
Affects Version/s: 6.0.5
Fix Version/s: None

Type: Problem report Priority: Trivial
Reporter: v99glu Assignee: Zabbix Support Team
Resolution: Fixed Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Ubuntu 20.04 with official Zabbix Apt Repo



 Description   

Steps to reproduce:

  1. Install Zabbix Agent2
  2. Put ControlSocket=/run/zabbix/agent.sock into zabbix_agent2.d/controlsock.conf
  3. Run zabbix-agent2.service

Result:
Zabbix Agent2 creates control socket file ControlSocket=/tmp/agent.sock
Expected:
Zabbix Agent2 creates control socket file ControlSocket=/run/zabbix/agent.sock
Reason:
Directive Include=/etc/zabbix/zabbix_agent2.d/*.conf goes before directive ControlSocket= in zabbix_agent2.conf, so any definition of ControlSocket in included files will be overridden.
Suggested fix:
Move directive Include=/etc/zabbix/zabbix_agent2.d/*.conf to the end of zabbix_agent2.conf.



 Comments   
Comment by v99glu [ 2022 Jun 19 ]

Obviously I can comment out ControlSocket= in zabbix_agent2.conf and everything will become OK but this file is a part of package and shouldn't be altered by user without a good reason.

Comment by Vladimir Stepanov (Inactive) [ 2022 Jun 21 ]

Thank you for reporting the issue!  Handled over developers for fixing.

Comment by Igor Gorbach (Inactive) [ 2022 Jun 21 ]

General Zabbix parameters like ListenPort, ControlSocket,ListenIP - if they should be re-defined in the included file - should be commented into the general configuration file - there is no bug
Zabbix reads the configuration file and included files and defines parameters once only, so similar parameters with the other values defined will be ignored

Comment by v99glu [ 2022 Jun 26 ]

OK, lets experiment.
Content of /run/za2/zabbix_agent2.conf:
    PidFile=/var/run/zabbix/zabbix_agent2.pid
    LogFile=/var/log/zabbix/zabbix_agent2.log
    LogFileSize=0
    Server=127.0.0.1
    ServerActive=127.0.0.1
    Hostname=Zabbix server
    Include=./zabbix_agent2.d/*.conf
    ControlSocket=/tmp/agent.sock
    Include=./zabbix_agent2.d/plugins.d/*.conf
It is a copy of original zabbix_agent2.conf without comments and empty lines and with "Include=./zabbix_agent2.d/*.conf" instead of "Include=/etc/zabbix/zabbix_agent2.d/*.conf".

Content of /run/za2/zabbix_agent2.d/agent.conf:
    ControlSocket=/run/za2/agent2.sock
    DebugLevel=4
    Hostname=
    ListenPort=20052
    LogFile=/dev/stdout
    PidFile=/run/za2/agent2.pid

Run agent2 from command line:
    zabbix_agent2 -foreground -config /run/za2/zabbix_agent2.conf | grep -P 'listen|control'
Output of command above:
    2022/06/26 09:47:45.002711 [0] starting listener for '0.0.0.0:20052'
    2022/06/26 09:47:45.003360 cannot start agent: An agent is already using control socket /tmp/agent.sock
    2022/06/26 09:47:45.003510 listener has been stopped

As we see agent2 cannot start because distributive zabbix-agent2.service is running and listening on /tmp/agent.sock.
BTW, note that ListenPort=, LogFile= were overridden.

Now put ControlSocket= before Include= in /run/za2/zabbix_agent2.conf:
    PidFile=/var/run/zabbix/zabbix_agent2.pid
    LogFile=/var/log/zabbix/zabbix_agent2.log
    LogFileSize=0
    Server=127.0.0.1
    ServerActive=127.0.0.1
    Hostname=Zabbix server
    ControlSocket=/tmp/agent.sock
    Include=./zabbix_agent2.d/*.conf
    Include=./zabbix_agent2.d/plugins.d/*.conf

Run agent2 from command line:
    zabbix_agent2 -foreground -config /run/za2/zabbix_agent2.conf | grep -P 'listen|control'
Output of command above:
    2022/06/26 09:51:39.001175 [0] starting listener for '0.0.0.0:20052'
    2022/06/26 09:51:39.001285 listening for control connections on /run/za2/agent2.sock

Voila, ControlSocket successfully overridden and we don't need to comment out ControlSocket= in base configuration.

I remember that when I tried to do so with Zabbix Agent 4.0, it didn't allow such overriding. And I was happy endlessly when noted that Zabbix Agent2 5.0+ did. Now from your words "Zabbix ... defines parameters once only" I can conclude - it is a bug rather than longly awaited feature, isn't it.

Comment by Paul Donohue [ 2025 Jun 03 ]

As an (ugly) work-around, you can put your config under /etc/zabbix/zabbix_agent2.d/plugins.d/ instead of /etc/zabbix/zabbix_agent2.d/ ... Or put a symlink to your config under plugins.d/ (which will cause your config to be loaded twice, although that should be harmless).

Comment by Petro Sklyar [ 2026 Mar 23 ]

Ticket marked as fixed/closed, unsupported version.
If the issue still persists, please create new request.

Generated at Fri Apr 10 15:58:03 EEST 2026 using Jira 10.3.18#10030018-sha1:5642e4ad348b6c2a83ebdba689d04763a2393cab.