Ad Widget

Collapse

Zzabbix agent fails to start - folder /var/run/zabbix/ missing after reboot

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ilia
    Member
    • Dec 2018
    • 37

    #1

    Zzabbix agent fails to start - folder /var/run/zabbix/ missing after reboot

    i have lots of zabbix clients, but i have this annoying issue on few of them

    after reboot the agent fails to start:

    service zabbix-agent status
    ● zabbix-agent.service - Zabbix Agent
    Loaded: loaded (/lib/systemd/system/zabbix-agent.service; enabled; vendor preset: enabled)
    Active: failed (Result: exit-code) since Sun 2020-09-13 11:49:48 IDT; 3s ago
    Docs: man:zabbix_agentd
    Process: 26552 ExecStart=/usr/sbin/zabbix_agentd --foreground (code=exited, status=1/FAILURE)
    Main PID: 26552 (code=exited, status=1/FAILURE)

    Sep 13 11:49:48 dev5 systemd[1]: Started Zabbix Agent.
    Sep 13 11:49:48 dev5 zabbix_agentd[26552]: zabbix_agentd [26552]: cannot create PID file [/var/run/zabbix/zabbix_agentd.pid]: [2] N
    Sep 13 11:49:48 dev5 systemd[1]: zabbix-agent.service: Main process exited, code=exited, status=1/FAILURE
    Sep 13 11:49:48 dev5 systemd[1]: zabbix-agent.service: Failed with result 'exit-code'.


    if i create the folder under zabbix:zabbix
    and start service again it works (until next reboot)
    Last edited by ilia; 13-09-2020, 12:47.
  • Atsushi
    Senior Member
    • Aug 2013
    • 2028

    #2
    Please tell me the distribution and version of the OS you are using. What version of Zabbix agent and how did you install it?
    If you are using Zabbix official package, it should be set according to each OS. For example, if you installed from source, you need to add a setting to create a directory when the OS starts.

    Comment

    • ilia
      Member
      • Dec 2018
      • 37

      #3
      the error occurs on ubuntu 18.04 (3 out of around 30 machines )
      we install using ansible script:


      tasks/main.yml
      Code:
      ---
      - name: Create group zabbix
      group:
      name: zabbix
      system: yes
      state: present
      
      - name: Install Zabbix repo on CentOS
      yum:
      name: https://repo.zabbix.com/zabbix/{{ zabbix_agent_version }}/rhel/{{ ansible_distribution_major_version }}/x86_64/zabbix-release-{{ zabbix_agent_version }}-1.el{{ ansible_distribution_major_version }}.noarch.rpm
      state: present
      when: ansible_pkg_mgr == "yum"
      
      - name: Install zabbix-agent
      package:
      state: present
      pkg:
      - zabbix-agent
      
      - name: update /etc/zabbix/zabbix_agentd.conf
      copy: src=root/etc/zabbix/zabbix_agentd.conf dest=/etc/zabbix/zabbix_agentd.conf owner=root group="{{ zabbix_agentd_conf_group }}"
      
      - name: Check if firewalld service is installed
      command: systemctl status firewalld
      register: firewalld_exists
      changed_when: False
      failed_when: firewalld_exists.rc > 4
      
      - name: Configure firewall to enable access to Zabbix agent
      block:
      - name: Check if 'zabbix' is recognizsed as a service
      shell: "firewall-cmd --get-service | fgrep -q zabbix"
      changed_when: False
      
      - name: Allow incoming connection from Zabbix server
      firewalld:
      rich_rule: rule service name="zabbix-agent" accept
      zone: public
      permanent: yes
      immediate: yes
      state: enabled
      notify:
      - restart firewalld
      when: firewalld_exists.rc == 0
      
      - stat: path=/var/log/zabbix-agent/
      register: zabbix_path_fix
      
      - name: fix zabbix log path
      file:
      src: /var/log/zabbix-agent
      dest: /var/log/zabbix
      state: link
      when: zabbix_path_fix.stat.isdir is defined and zabbix_path_fix.stat.isdir
      
      - name: Restart service zabbix-agent
      service:
      name: zabbix-agent
      state: restarted
      defaults/main.yml
      Code:
      ---
      zabbix_agentd_conf_group: zabbix
      zabbix_agent_version: 5.0
      and the config itself have noting special - just zabbix server ip is set)
      Last edited by ilia; 14-09-2020, 11:00.

      Comment

      Working...