Skip to content

Zabbix with Nginx, Postgres and automation for Agent2: Ansible playbook for Linux nodes, and PowerShell script for Windows node.

License

Notifications You must be signed in to change notification settings

BorysVrublevskyi/zabbix-docker-compose-automation

Repository files navigation

Setup Zabbix monitoring system

Zabbix with Nginx, Postgres and automation for Agent2: Ansible playbook for Linux nodes, and PowerShell script for Windows node.

Requirements

Software: Linux VM or physical server, Docker with docker-compose.

Configuration: Static IP, hostname, DNS record, disabled/configured SELinux and Firewall to work with Docker and Zabbix.

Deploy with Docker-Compose

This repo contains:

  • Docker compose, env file with example credentials, bash script to restore DB from backup.

  • Ansible playbook to install Zabbix agent 2 on Linux machines.

  • PowerShell script for automatic install and config on Windows machine.

Manual installation

Zabbix agent 2 on Centos

rpm --import https://repo.zabbix.com/RPM-GPG-KEY-ZABBIX-A14FE591

# For Centos 7
yum install -y http://repo.zabbix.com/zabbix/5.4/rhel/7/x86_64/zabbix-release-5.4-1.el7.noarch.rpm
yum install -y zabbix-agent2

# For Centos 8
dnf install -y http://repo.zabbix.com/zabbix/5.4/rhel/8/x86_64/zabbix-release-5.4-1.el8.noarch.rpm
dnf install -y zabbix-agent2

cp -n /etc/zabbix/zabbix_agent2.conf{,.bak}
sed -i "s/^Server=.*/Server=zabbix.mydomain.loc/g" /etc/zabbix/zabbix_agent2.conf && grep Server= /etc/zabbix/zabbix_agent2.conf
sed -i "s/^ServerActive=.*/ServerActive=zabbix.mydomain.loc/g" /etc/zabbix/zabbix_agent2.conf && grep ServerActive= /etc/zabbix/zabbix_agent2.conf
# grep -y domain /etc/sysconfig/network-scripts/ifcfg-eth0 # if true, will return fqdn with: hostname -A | awk '{print $1}'
# sed -i "s/^Hostname=.*/Hostname=$(hostname -A | awk '{print $1}')/g" /etc/zabbix/zabbix_agent2.conf && grep Hostname= /etc/zabbix/zabbix_agent2.conf
sed -i "s/^Hostname=.*/Hostname=$(hostname).mydomain.loc/g" /etc/zabbix/zabbix_agent2.conf && grep Hostname= /etc/zabbix/zabbix_agent2.conf
grep -e "^\w.*" /etc/zabbix/zabbix_agent2.conf

Zabbix agent 2 Windows

Windows agent installation from MSI

macOS

Download and install Zabbix agent as a regular pkg

sudo nano /usr/local/etc/zabbix/zabbix_agentd.conf
sudo launchctl unload /Library/LaunchDaemons/com.zabbix.zabbix_agentd.plist
sudo launchctl load /Library/LaunchDaemons/com.zabbix.zabbix_agentd.plist

Zabbix basic configuration

Auto hosts discovery

https://www.zabbix.com/documentation/current/manual/discovery/network_discovery/rule

Configuration → Discovery → Add/Edit rule

Name Value
IP range 192.168.1.1-254
Update interval 30m or 1h
Checks Zabbix agent "system.hostname"
Zabbix agent "system.uname"
Device uniqueness criteria IP address
Host name Zabbix agent "system.hostname"
Visible name Zabbix agent "system.hostname"
Enabled Check

Configuration → Actions → Discovery actions

Auto discovery. Linux servers:

Actions Operations
Received value contains Linux
Discovery status equals Up
Service type equals Zabbix agent
Add host
Add to host groups: Linux servers
Link to templates: Linux by Zabbix agent
Set host inventory mode: Automatic

Forget host after 1 week down:

Name Action
Uptime/Downtime is greater than or equals 604800
Discovery status equals Down
Service type equals Zabbix agent
Remove host

🛈 Default time for hosts to pass from "Monitoring → Discovery" to "Monitoring → Hosts" ~ 1h

Do not track specific Windows services

Configuration → Templates → Windows services by Zabbix agent → Macros

Find section {$SERVICE.NAME.NOT_MATCHES} and add services that you don't want to track BITS|edgeupdate|TrustedInstaller|WbioSrvc

This settings can be overridden by host settings:

Configuration → Hosts → SomeHost → Triggers

Links

About

Zabbix with Nginx, Postgres and automation for Agent2: Ansible playbook for Linux nodes, and PowerShell script for Windows node.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published