How to Install Zabbix Agent with Saltstack (or by hand)

If you’re using Zabbix to monitor your network, you’re going to need the Zabbix agent installed on each of your hosts. You could install the Zabbix-agent on each of your computers, which we’ll cover in detail, OR write a saltstack SLS file to install the Zabbix agent!

So, first, let’s install the Zabbix agent by hand, and then we’ll use our lessons learned to spin up a saltstack SLS file to automate the process of installing the Zabbix agent.

Installing the Zabbix agent is really pretty simple! In fact, it’s available in the raspberry repos! So just use apt to install it:

apt -y install zabbix-agent

Let apt do its thing and then get ready to edit the config file. There’s just a single change to make to the config. You’ll have to add the name of your Zabbix server or proxy agent that will be polling the device. So, once apt finishes installing edit the config file and add the names or IP addresses to the line “Server=”. Once you’re done editing, restart the agent with:

systemctl restart zabbix-agent

and your server should get picked up in autodiscovery. Since things are working and we have a general handle on how things work, I think we’re ready to take a swag at writing the sls file in saltstack to push the Zabbix-agent out to the rest of the hosts. Copy your working zabbix-agent.conf file to your saltstack server and into the files directory. Now, spin up an SLS file to install the agent, copy the conf into place and then restart the process if it’s not running:

      - name: zabbix-agent

      - managed
      - source: salt://files/zabbix_agentd.conf
      - require:
      - pkg: zabbix-agent
      - name: zabbix-agent.service
      - enable: true

Now, just wait an hour for autodiscovery to run on the Zabbix server and you can start configuring all your hosts in the server!

2 thoughts on “How to Install Zabbix Agent with Saltstack (or by hand)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.