Skip to content

Instantly share code, notes, and snippets.

@mrl22
Forked from freeminder/zabbix_agent_install.sh
Last active September 12, 2021 14:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrl22/2cef9305c513f9b4d24ac69a364c5c9a to your computer and use it in GitHub Desktop.
Save mrl22/2cef9305c513f9b4d24ac69a364c5c9a to your computer and use it in GitHub Desktop.
Zabbix Agent installation script
#!/bin/bash -e
if [ "$UID" -ne 0 ]; then
echo "Please run as root"
exit 1
fi
# Only run it if we can (ie. on Ubuntu/Debian)
if [ -x /usr/bin/apt-get ]; then
apt-get update
apt-get -y install zabbix-agent sysv-rc-conf
sysv-rc-conf zabbix-agent on
sed -i 's/Server=127.0.0.1/Server=18.133.222.190/' /etc/zabbix/zabbix_agentd.conf
sed -i 's/ServerActive=127.0.0.1/ServerActive=18.133.222.190/' /etc/zabbix/zabbix_agentd.conf
HOSTNAME=`hostname` && sed -i "s/Hostname=Zabbix\ server/Hostname=$HOSTNAME/" /etc/zabbix/zabbix_agentd.conf
service zabbix-agent restart
fi
# Only run it if we can (ie. on RHEL/CentOS)
if [ -x /usr/bin/yum ]; then
yum -y update
rpm -ivh http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpm
yum -y install zabbix-agent
chkconfig zabbix-agent on
sed -i 's/Server=127.0.0.1/Server=18.133.222.190/' /etc/zabbix/zabbix_agentd.conf
sed -i 's/ServerActive=127.0.0.1/ServerActive=18.133.222.190/' /etc/zabbix/zabbix_agentd.conf
HOSTNAME=`hostname` && sed -i "s/Hostname=Zabbix\ server/Hostname=$HOSTNAME/" /etc/zabbix/zabbix_agentd.conf
service zabbix-agent restart
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment