Zabbix-client-install
#! / bin/bash
# this script mainly adds zabbix-agent for CentOS 6 or 7 version
# run scripts as root users
If [$(id-u)! = "0"]; then
Echo "You must be root to run this script..."
Exit 1
Fi
If [$#! = "1"]; then
Echo "Give me ZABBIX server IP..."
Exit 2
Fi
# selinux will prevent the service from being enabled, so shut down
Sed-I'/ SELINUX/s/enforcing/disabled/' / etc/selinux/config
Setenforce 0
If [- f / etc/redhat-release]; then
Edition= `grep-o'[[: digit:]]'/ etc/redhat-release | head-1`
Else
Edition= `uname`
Fi
Case "$Edition" in
7)
Echo-e "\ n\ 033 [34mStart installation.\ 033 [0m\ n"
Rpm-ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
Yum-y install zabbix-agent zabbix-sender
Sed-I "/ Server/s/Server=127.0.0.1/Server=$1/" / etc/zabbix/zabbix_agentd.conf
Sed-I "/ Server/s/ServerActive=127.0.0.1/ServerActive=$1/" / etc/zabbix/zabbix_agentd.conf
Systemctl start zabbix-agent
Systemctl enable zabbix-agent
6)
Echo-e "\ n\ 033 [34mStart installation.\ 033 [0m\ n"
Rpm-ivh http://repo.zabbix.com/zabbix/3.0/rhel/6/x86_64/zabbix-release-3.0-1.el6.noarch.rpm
Yum-y install zabbix-agent zabbix-sender
Sed-I "/ Server/s/Server=127.0.0.1/Server=$1/" / etc/zabbix/zabbix_agentd.conf
Sed-I "/ Server/s/ServerActive=127.0.0.1/ServerActive=$1/" / etc/zabbix/zabbix_agentd.conf
/ etc/init.d/zabbix-agent start
Chkconfig zabbix-agent on
*)
Echo "="
Echo "This system is not CentOS 6 or 7, script execution failed!"
Echo "="
Exit 3
Esac
If ss-ntl | grep 10050 & > / dev/null; then
Echo-e "\ n\ 033 [32mCongratulations, ZABBIX client installed successfully\ 033 [0m\ n"
Else
Echo-e "\ n\ 033 [31mSorry, please rerun the command or contact the administrator\ 033 [0m\ n"
Fi