Ad Widget

Collapse

How to run automatic zabbix_agentd service at the startup

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • seungkim
    Junior Member
    • Jan 2020
    • 3

    #1

    How to run automatic zabbix_agentd service at the startup

    After system maintenance, macOS system (Catalina) is required to reboot. After restart, the zabbix_agentd service seems not running automatically. How can I change the service to run the service automatically at the startup?

    Please, advise.

    SK
  • AvaTTaR
    Member
    • Dec 2018
    • 96

    #2
    See this solution as example: https://gist.github.com/nojimage/905266

    Comment

    • seungkim
      Junior Member
      • Jan 2020
      • 3

      #3
      AvaTTAr, thank you for your post. According to the given link, I cannot find the zabbix_agentd.init file under /opt/local/share/zabbix/ or anywhere in Catalina OS systems.

      SK

      Comment

      • ma-kom
        Junior Member
        • May 2019
        • 4

        #4
        Since I updated Mac Clients to Catalina and installed the Agents (Version 5.0.4) the agent stopped starting on system boot.
        It seems that there's a non working start daemon in /Library/LaunchDaemons called com.zabbix.zabbix_agentd.plist.
        However, I solved this problem by creating the script as mentioned above with some changes:

        1.) Open a terminal on the mac client system or connect via ssh and create a new LaunchAgent-File:
        Code:
        [FONT=Calibri][FONT=Courier New][COLOR=black]sudo nano /Library/LaunchAgents/org.macports.zabbix_agent.plist[/COLOR][/FONT][/FONT]
        2.) Paste this content into the file:
        Code:
        [FONT=Calibri][FONT=Courier New][COLOR=black]<?xml version="1.0" encoding="UTF-8"?>[/COLOR][/FONT][/FONT]
        [FONT=Calibri][FONT=Courier New][COLOR=black]<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">[/COLOR][/FONT][/FONT]
        [FONT=Calibri][FONT=Courier New][COLOR=black]<plist version="1.0">[/COLOR][/FONT][/FONT]
        [FONT=Calibri][FONT=Courier New][COLOR=black]<dict>[/COLOR][/FONT][/FONT]
        [FONT=Calibri][FONT=Courier New][COLOR=black]<key>Label</key>[/COLOR][/FONT][/FONT]
        [FONT=Calibri][FONT=Courier New][COLOR=black]<string>org.macports.zabbix_agent</string>[/COLOR][/FONT][/FONT]
        
        [FONT=Calibri][FONT=Courier New][COLOR=black]<key>ProgramArguments</key>[/COLOR][/FONT][/FONT]
        [FONT=Calibri][FONT=Courier New][COLOR=black]<array>[/COLOR][/FONT][/FONT]
        [FONT=Calibri][FONT=Courier New][COLOR=black]<string>/usr/local/sbin/zabbix_agentd</string>[/COLOR][/FONT][/FONT]
        [FONT=Calibri][FONT=Courier New][COLOR=black]<string>-c</string>[/COLOR][/FONT][/FONT]
        [FONT=Calibri][FONT=Courier New][COLOR=black]<string>/usr/local/etc/zabbix/zabbix_agentd.conf</string>[/COLOR][/FONT][/FONT]
        [FONT=Calibri][FONT=Courier New][COLOR=black]<string>-f</string>[/COLOR][/FONT][/FONT]
        [FONT=Calibri][FONT=Courier New][COLOR=black]</array>[/COLOR][/FONT][/FONT]
        
        [FONT=Calibri][FONT=Courier New][COLOR=black]<key>OnDemand</key> <false />[/COLOR][/FONT][/FONT]
        [FONT=Calibri][FONT=Courier New][COLOR=black]<key>Disabled</key> <true/>[/COLOR][/FONT][/FONT]
        [FONT=Calibri][FONT=Courier New][COLOR=black]</dict>[/COLOR][/FONT][/FONT]
        [FONT=Calibri][FONT=Courier New][COLOR=black]</plist>[/COLOR][/FONT][/FONT]
        This will start the agent with the corresponding configuration. Check if both files exist!

        3. Execute the LaunchAgent
        Code:
        [FONT=Calibri][FONT=Courier New][COLOR=black]sudo launchctl load -w /Library/LaunchAgents/org.macports.zabbix_agent.plist[/COLOR][/FONT][/FONT]
        If you need to unload the LaunchAgent:
        Code:
        [FONT=Calibri][FONT=Courier New][COLOR=black]sudo launchctl unload -w /Library/LaunchAgents/org.macports.zabbix_agent.plist[/COLOR][/FONT][/FONT]
        Troubleshooting:
        To test if the agent has critical problems, start it manually an check for errors first:
        Code:
        [FONT=Calibri][FONT=Courier New][COLOR=black]cd /usr/local/sbin/
        ./zabbix_agentd[/COLOR][/FONT][/FONT]
        If there are no errors, check the log file for errors:
        Code:
        [FONT=Calibri][FONT=Courier New][COLOR=black]sudo nano /var/log/zabbix/zabbix_agentd.log[/COLOR][/FONT][/FONT]
        If there is no log, then create it:
        Code:
        sudo mkdir /var/log/zabbix
        sudo touch /var/log/zabbix/zabbix_agentd.log
        If the log is empty, the zabbix agent can not write to the log. In this case make it writable:
        Code:
        sudo chmod 777 /var/log/zabbix/zabbix_agentd.log
        Another point of failure could be the systems security settings of mac os and optional firewall apps (i.e. radio silence).
        Check the privacy tab and make sure port 10500 is good to go.

        Hope this helps someone.
        P.S. I used the latest agent installer from the zabbix download area and really wonder, why this still has to be done manually...

        Comment

        • ma-kom
          Junior Member
          • May 2019
          • 4

          #5
          Everything that I posted above did not solve my zabbix autostart problem on mac os catalina.

          Also I tried to use a sh file to start the agent, as suggested somewhere on the web:
          Code:
          [FONT=Calibri][FONT=Courier New][COLOR=black]sudo nano /etc/startzabbix.sh[/COLOR][/FONT][/FONT]
          with the content:
          Code:
          [FONT=Calibri][FONT=Courier New][COLOR=black]#!/bin/bash[/COLOR][/FONT][/FONT]
          [FONT=Calibri][FONT=Courier New][COLOR=black]/usr/local/sbin/zabbix_agentd[/COLOR][/FONT][/FONT]
          made it executable with
          Code:
          [FONT=Calibri][FONT=Courier New][COLOR=black]sudo chmod a+x /etc/startzabbix.sh[/COLOR][/FONT][/FONT]
          and from the LaunchAgent I changed:
          Code:
          [FONT=Calibri][FONT=Courier New][COLOR=black]sudo nano /Library/LaunchAgents/org.macports.zabbix_agent.plist[/COLOR][/FONT][/FONT]
          to this:
          Code:
          [FONT=Calibri][FONT=Courier New][COLOR=black]<?xml version="1.0" encoding="UTF-8"?>[/COLOR][/FONT][/FONT]
          [FONT=Calibri][FONT=Courier New][COLOR=black]<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">[/COLOR][/FONT][/FONT]
          [FONT=Calibri][FONT=Courier New][COLOR=black]<plist version="1.0">[/COLOR][/FONT][/FONT]
          [FONT=Calibri][FONT=Courier New][COLOR=black]<dict>[/COLOR][/FONT][/FONT]
          [FONT=Calibri][FONT=Courier New][COLOR=black]<key>Label</key>[/COLOR][/FONT][/FONT]
          [FONT=Calibri][FONT=Courier New][COLOR=black]<string>org.macports.zabbix_agent</string>[/COLOR][/FONT][/FONT]
          [FONT=Calibri][FONT=Courier New][COLOR=black]<key>RunAtLoad</key>[/COLOR][/FONT][/FONT]
          [FONT=Calibri][FONT=Courier New][COLOR=black]<true/>[/COLOR][/FONT][/FONT]
          [FONT=Calibri][FONT=Courier New][COLOR=black]<key>ProgramArguments</key>[/COLOR][/FONT][/FONT]
          [FONT=Calibri][FONT=Courier New][COLOR=black]<array>[/COLOR][/FONT][/FONT]
          [FONT=Calibri][FONT=Courier New][COLOR=black]<string>sh</string>[/COLOR][/FONT][/FONT]
          [FONT=Calibri][FONT=Courier New][COLOR=black]<string>/etc/startzabbix.sh</string>[/COLOR][/FONT][/FONT]
          [FONT=Calibri][FONT=Courier New][COLOR=black]</array>[/COLOR][/FONT][/FONT]
          [FONT=Calibri][FONT=Courier New][COLOR=black]</dict>[/COLOR][/FONT][/FONT]
          [FONT=Calibri][FONT=Courier New][COLOR=black]</plist>[/COLOR][/FONT][/FONT]
          ... which did not work, too.

          On github I found this issue for the zabbix agent osx installer: https://github.com/mipmip/zabbix_age...aller/issues/5
          So, maybe the next version of the installer will solve that problem?

          Comment

          Working...