If you’re using saltstack 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 or 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:
install_zabbix_agent: pkg.installed: - name: zabbix-agent /etc/zabbix/zabbix_agentd.conf: file: - managed - source: salt://files/zabbix_agentd.conf - require: - pkg: zabbix-agent run_agent: service.running: - 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!