Last active
April 22, 2021 05:50
-
-
Save olmosleo/d6cf290d0f21361a92fe2f158a8df514 to your computer and use it in GitHub Desktop.
Script for install Zabbix Agent on CentOS 7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Script for install Zabbix Agent on CentOS 7. | |
# github.com/@olmosleo | |
#SELINUX="/etc/selinux/config"; | |
#echo "SELINUX=disabled" > $SELINUX; | |
#echo "SELINUXTYPE=targeted" >> $SELINUX; | |
# remember to reboot after install or just restart the machine when you finish to execute the script. | |
# Disabled SELINUX | |
################################ Install the Zabbix Agent 3.0 ################################### | |
#sudo rpm -Uv http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm | |
sudo rpm -Uv http://repo.zabbix.com/zabbix/3.2/rhel/6/x86_64/zabbix-release-3.2-1.el6.noarch.rpm | |
# update 3.4 | |
#sudo rpm -Uv http://repo.zabbix.com/zabbix/3.4/rhel/6/x86_64/zabbix-release-3.4-1.el6.noarch.rpm | |
sudo yum install -y zabbix-agent | |
#sudo sh -c "openssl rand -hex 32 > /etc/zabbix/zabbix_agentd.psk" | |
################################# Edit the file conf ############################################# | |
# edit file /etc/zabbix/zabbix_agentd.conf and add this change | |
ZABBIX_AGENT_CONF="/etc/zabbix/zabbix_agentd.conf"; | |
ZABBIX_SERVER="10.30.3.184"; | |
# add some params to the configure file of zabbix-agent | |
echo "PidFile=/var/run/zabbix/zabbix_agentd.pid" >> $ZABBIX_AGENT_CONF; | |
echo "LogFile=/var/log/zabbix/zabbix_agentd.log" >> $ZABBIX_AGENT_CONF; | |
echo "LogFileSize=0" >> $ZABBIX_AGENT_CONF; | |
echo "Server=$ZABBIX_SERVER" >> $ZABBIX_AGENT_CONF; | |
echo "ServerActive=$ZABBIX_SERVER" >> $ZABBIX_AGENT_CONF; | |
echo "Hostname=Zabbix server" >> $ZABBIX_AGENT_CONF; | |
echo "Include=/etc/zabbix/zabbix_agentd.d/" >> $ZABBIX_AGENT_CONF; | |
# Server=your_zabbix_server_ip_address | |
# TLSConnect=psk | |
# TLSPSKIdentity=PSK 001 | |
# TLSPSKFile=/etc/zabbix/zabbix_agentd.psk | |
############## Add Firewall Rules ##################################### | |
# Open port 10050 on firewall (iptables) Only for CentOS 7 | |
PORT=10050; | |
# remember to hability the port in the local firewall. | |
#firewall-cmd --permanent --add-port=$PORT/tcp | |
# firewall-cmd --permanent --add-port=10051/tcp | |
#sudo systemctl restart firewalld | |
# Open port 10050 on firewall (iptables) Only for CentOS 6.X | |
sudo iptables -I INPUT -p tcp -m tcp --dport $PORT -j ACCEPT | |
sudo iptables -I INPUT -p udp -m udp --dport $PORT -j ACCEPT | |
sudo iptables -A INPUT -m state --state NEW -p tcp --dport $PORT -j ACCEPT | |
sudo iptables -A INPUT -m state --state NEW -p udp --dport $PORT -j ACCEPT | |
sudo service iptables save | |
###################################################################### | |
#### Restart the services ############################################ | |
#sudo systemctl start zabbix-agent | |
#sudo systemctl enable zabbix-agent | |
###################################################################### | |
sudo service zabbix-agent restart | |
sudo chkconfig zabbix-agent on |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Zabbix Server installation script?