Skip to content

Instantly share code, notes, and snippets.

@lichti
Created December 15, 2016 14:07
Show Gist options
  • Save lichti/cbf197e45f998cbb196a8d12d9ab7bad to your computer and use it in GitHub Desktop.
Save lichti/cbf197e45f998cbb196a8d12d9ab7bad to your computer and use it in GitHub Desktop.
ZABBIX_HOSTNAME=zabbix-server.lichti.com.br
ZABBIX_DBPASS=my_super_pass
sed -i 's/^SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config
setenforce Permissive
sed -i "s/^HOSTNAME=.*/HOSTNAME=${ZABBIX_HOSTNAME}/g" /etc/sysconfig/network
echo "${ZABBIX_HOSTNAME}" > /etc/hostname
systemctl disable firewalld
yum update
yum install epel-release -y
yum install httpd mariadb-server mariadb php php-mysql php-gd php-pear -y
rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent zabbix-java-gateway -y
systemctl enable httpd
systemctl enable mariadb
systemctl enable zabbix-server
systemctl enable zabbix-agent
systemctl start httpd
systemctl start mariadb
mysql_secure_installation
mysql -uroot -p -e "create database zabbixdb character set utf8;"
mysql -uroot -p -e "grant all privileges on zabbixdb.* to 'zabbixuser'@'localhost' identified by '${ZABBIX_DBPASS}';"
mysql -uroot -p -e "flush privileges;"
zcat /usr/share/doc/zabbix-server-mysql-3.2.2/create.sql.gz | mysql -uzabbixuser -p${ZABBIX_DBPASS} zabbixdb
cat << EOF > /etc/zabbix/zabbix_server.conf
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
DBName=zabbixdb
DBUser=zabbixuser
DBPassword=${ZABBIX_DBPASS}
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000
EOF
cat << EOF > /etc/zabbix/zabbix_agentd.conf
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=${ZABBIX_HOSTNAME}
ServerActive=${ZABBIX_HOSTNAME}
Hostname=${ZABBIX_HOSTNAME}
Include=/etc/zabbix/zabbix_agentd.d/*.conf
EOF
systemctl restart httpd
systemctl restart mariadb
systemctl start zabbix-server
systemctl start zabbix-agent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment