Ad Widget

Collapse

Auto starting zabbix services on Ubuntu

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Gijs007
    Member
    • Oct 2017
    • 40

    #1

    Auto starting zabbix services on Ubuntu

    I'm having an issue where the Zabbix services are not automatically started at bootup of our Ubuntu 17.10 machine.
    We've manually compiled and installed Zabbix.

    We've installed the Zabbix agents as services by copying the debian startup scripts from the zabbix rar:
    cd zabbix/misc/init.d/debian
    sudo cp zabbix-agent /etc/init.d
    sudo cp zabbix-server /etc/init.d

    sudo chmod 755 /etc/init.d/zabbix-server
    sudo update-rc.d zabbix-server defaults
    sudo chmod 755 /etc/init.d/zabbix-agent
    sudo update-rc.d zabbix-agent defaults
    Now we can start Zabbix from the terminal with the following commands:
    sudo service zabbix-agent start
    sudo service zabbix-server start
    How can we configure the system to auto start the Zabbix services?

    I've already tried systemctl enable, which results in the following error:
    zabbix-agent.service is not a native service, redirecting to systemd-sysv-install.
    Executing: /lib/systemd/systemd-sysv-install enable zabbix-agent
    update-rc.d: error: zabbix-agent Default-Start contains no runlevels, aborting.
    and I've also tried update-rc.d, but this doesn't work.
    sudo update-rc.d zabbix-agent defaults
    sudo update-rc.d zabbix-server defaults
    Last edited by Gijs007; 29-11-2017, 17:21.
  • jan.garaj
    Senior Member
    Zabbix Certified Specialist
    • Jan 2010
    • 506

    #2
    Use systemd unit files and system, because systemd is default init system of Ubuntu 17.

    Example:
    Code:
    $ cat /usr/lib/systemd/system/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/zabbix_agentd.pid
    KillMode=control-group
    ExecStart=/usr/sbin/zabbix_agentd -c $CONFFILE
    ExecStop=/bin/kill -SIGTERM $MAINPID
    RestartSec=10s
    
    [Install]
    WantedBy=multi-user.target
    $ systemctl enable zabbix-agent.service
    Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
    $  systemctl start zabbix-agent.service
    ...
    Check systemd documentation.
    Devops Monitoring Expert advice: Dockerize/automate/monitor all the things.
    My DevOps stack: Docker / Kubernetes / Mesos / ECS / Terraform / Elasticsearch / Zabbix / Grafana / Puppet / Ansible / Vagrant

    Comment

    Working...