一键自动化安装zabbix客户端服务

声明

作者:昨夜星辰

博客:http://yestreenstars.blog.51cto.com/

本文由本人创作,如需转载,请注明出处,谢谢合作!

目的

一键自动化安装zabbix客户端服务。

环境

OS:CentOS 6.2 32

zabbix版本:2.2.4

配置

#!/bin/bash
# Script Name: One-key Automatic Install Zabbix Client
# Author: yestreenstars
# Create Time: 2014-08-12

zabbix_server_IP="192.168.1.88" # Change this to your zabbix server's IP.
hostname="test" # You can change it to other name.

echo -n "--Adding zabbix user..."
useradd -M -s /sbin/nologin zabbix && echo "Completed!"

echo -n "--Installing related software..."
yum -y install wget gcc make > /dev/null 2>&1 && echo "Completed!"

echo -n "--Downloading and installing zabbix_agents..."
(
wget -P /tmp/ http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.2.4/zabbix-2.2.4.tar.gz > /dev/null 2>&1
tar xzf /tmp/zabbix-2.2.4.tar.gz -C /usr/src/
cd /usr/src/zabbix-2.2.4/
./configure --prefix=/usr/local/zabbix --enable-agent
make install
cp $PWD/misc/init.d/fedora/core/zabbix_agentd /etc/init.d/
sed -i '/BASEDIR=/s/$/\/zabbix/' /etc/init.d/zabbix_agentd
sed -i '/^Server=/s/=.*/='"$zabbix_server_IP"'/;/^Hostname=/s/=.*/='"$hostname"'/' /usr/local/zabbix/etc/zabbix_agentd.conf
) > /dev/null 2>&1 && echo "Completed!"

echo -n "--Adding zabbix_agentd service to run on startup..."
(
chkconfig --add zabbix_agentd
chkconfig zabbix_agentd on
) && echo "Completed!"

echo -n "--Starting zabbix_agentd service..."
service zabbix_agentd start > /dev/null 2>&1 && echo "Completed!"

echo -n "--Modifying iptables firewall..."
(
iptables -I INPUT -p tcp --dport 10050 -j ACCEPT
service iptables save
) > /dev/null 2>&1 && echo "Completed!"


你可能感兴趣的:(安装,自动化,zabbix)