3

I'm trying to run zabbix-agent 3.0.4 on CentOS7, systemd failed to start the zabbix agent, from journalctl -xe

PID file /run/zabbix/zabbix_agentd.pid not readable (yes?) after start. node=localhost.localdomain type=SERVICE_START msg=audit(1475848200.601:17994): pid=1 uid=0 auid=4294967298 ses=... zabbix-agent.service never wrote its PID file. Failing. Failed to start Zabbix Agent.

There is no permission error, and I try to re-configure the PID path to /tmp folder in zabbix-agent.service and zabbix_agentd.conf, it doesn't work.

Very weird, anyone has idea? Thank you in advance.

=====

Investigating a little bit, the PID should be under /run/zabbix folder, I create manually the zabbix_agentd.pid, and it disappears after 1 second. Really weird.

perigee
  • 9,438
  • 11
  • 31
  • 35
  • Try to start the agent directly. Any error messages? Maybe the config file is not accessible, or has mistakes? Also check that the PidFile option in the agent daemon config file is set to match that path. – Richlv Oct 07 '16 at 15:56
  • @Richlv, check the permission, no conflict, just there seems be a process deleting `/run/zabbix/zabbix_agentd.pid` constantly, don't know it is `systemd` or not. – perigee Oct 11 '16 at 14:20
  • For the moment, the workaround i used, install first the zabbix-agent 2.2 version, restarted, enabled, and then install zabbix-agent 3.0.4, restart the agent again. – perigee Oct 11 '16 at 17:12

5 Answers5

6

I had the same issue and it was related to selinux. So I allowed zabbix_agent_t via semanage

 yum install policycoreutils-python 

 semanage permissive -a zabbix_agent_t
user2398069
  • 385
  • 1
  • 5
  • 13
0

Giving the full permissions 7777 to that pid file will help to resolve the issue.

Tunaki
  • 132,869
  • 46
  • 340
  • 423
0

i had this too and it was Selinux, it was disabled but i had to run the command

0

That's work for me.

Prerequisites: Centos 7, zabbix-server 3.4 and zabbix-agent 3.4 runing on same host.

Solution steps:

  1. Install zabbix-server and zabbix-agent (no matter how - via yum or building from source code).

  2. Check first if there is already separate users exist in /etc/passwd. If there is already zabbix users exist go to p.4.

  3. Create separate groups and users for zabbix-server and zabbix-agent. Example (you can specify usernames on your desire):

    groupadd zabbix-agent  
    useradd -g zabbix-agent zabbix-agent  
    groupadd zabbix  
    useradd -g zabbix zabbix  
    
  4. Specify PID and LOG file location in Zabbix config files. Example:

    • For zabbix-server: in /etc/zabbix/zabbix_server.conf:
    PidFile=/run/zabbix/zabbix_server.pid  
    LogFile=/var/log/zabbix/zabbix_server.log  
    
    • For zabbix-agent: in /etc/zabbix/zabbix_agentd.conf:
    PidFile=/run/zabbix-agent/zabbix-agent.pid  
    LogFile=/var/log/zabbix-agent/zabbix-agent.log
    
  5. Create appropriate directories (if they haven't been creatred previously) as were specified in config files and change owners for this directories:

    mkdir /var/log/zabbix-agent  
    mkdir /run/zabbix-agent  
    chown zabbix-agent:zabbix-agent /var/log/zabbix-agent  
    chown zabbix-agent:zabbix-agent /run/zabbix-agent  
    
    mkdir /var/log/zabbix  
    mkdir /run/zabbix  
    chown zabbix:zabbix /var/log/zabbix-agent  
    chown zabbix:zabbix /run/zabbix-agent
    
  6. Check systemd config for zabbix services and add Username= and Group= in [Service] section under which services will run. Example:

    • For zabbix-server: /etc/systemd/system/multi-user.target.wants/zabbix-server.service:
    [Unit]
    Description=Zabbix Server
    After=syslog.target
    After=network.target
    
    [Service]
    Environment="CONFFILE=/etc/zabbix/zabbix_server.conf"
    EnvironmentFile=-/etc/sysconfig/zabbix-server
    Type=forking
    Restart=on-failure
    PIDFile=/run/zabbix/zabbix_server.pid
    KillMode=control-group
    ExecStart=/usr/sbin/zabbix_server -c $CONFFILE
    ExecStop=/bin/kill -SIGTERM $MAINPID
    RestartSec=10s
    TimeoutSec=0
    
    User=zabbix
    Group=zabbix
    
    [Install]
    WantedBy=multi-user.target
    
    • For zabbix-agent: /etc/systemd/system/multi-user.target.wants/zabbix-agent.service:
    [Unit]
    Description=Zabbix Agent
    After=syslog.target
    After=network.target
    
    [Service]
    Environment="CONFFILE=/etc/zabbix/zabbix_agentd.conf"
    EnvironmentFile=-/etc/sysconfig/zabbix-agent
    Type=forking
    Restart=on-failure
    PIDFile=/run/zabbix-agent/zabbix-agent.pid
    KillMode=control-group
    ExecStart=/usr/sbin/zabbix_agentd -c $CONFFILE
    ExecStop=/bin/kill -SIGTERM $MAINPID
    RestartSec=10s
    
    User=zabbix-agent
    Group=zabbix-agent
    
    [Install]
    WantedBy=multi-user.target
    
    • If there is no such configs - you can find them in:

    /usr/lib/systemd/system/

OR

Enable zabbix-agent.service service and thereby create symlink in /etc/systemd/system/multi-user.target.wants/ directory to /usr/lib/systemd/system/zabbix-agent.service

  1. Run services:

    systemctl start zabbix-server  
    systemctl start zabbix-agent  
    
  2. Check users under which services had been started (first column):

    ps -aux | grep zabbix  
    

or via top command.

0

Disable SELinux and Firewalld and you're good to go

John M
  • 1