shell-安装 zabbix agent

前提: 配好yum源

#!/bin/bash

#设置agent的相关参数

read -p "please input the zabbix-server-ipaddress:" server

read -p "please input the client name:" host

server_ip="Server=$server"

serveractive_ip="ServerActive=$server"

host_name="Hostname=$host"

#配置yum源

#mkdir -p /etc/yum.repos.d/repo &> /dev/null

#mv /etc/yum.repos.d/CentOS-* /etc/yum.repos.d/repo/

#cp ./local.repo /etc/yum.repos.d/

#安装依赖包及agent

yum -y install curl curl-devel net-snmp net-snmp-devel perl-DBI gcc

useradd -u 8001 -M -s /sbin/nologin zabbix

tar xvf zabbix-3.0.5.tar.gz -C /usr/local/src/ #可以将zabbix安装文件放到ftp或web服务器上,用的时候自服务器上下载

cd /usr/local/src/zabbix-3.0.5/

./configure --prefix=/usr/local/zabbix --enable-agent

make install

cd

#配置agent参数

cp /usr/local/src/zabbix-3.0.5/misc/init.d/fedora/core5/zabbix_agentd /etc/init.d/

sed -i 's#ZABBIX_BIN="/usr/local/sbin/zabbix_agentd"#ZABBIX_BIN="/usr/local/zabbix/sbin/zabbix_agentd"#' /etc/init.d/zabbix_agentd

chkconfig zabbix_agentd on

sed -i 's#Server=127.0.0.1#'"$server_ip"'#' /usr/local/zabbix/etc/zabbix_agentd.conf

sed -i 's#ServerActive=127.0.0.1#'"$serveractive_ip"'#' /usr/local/zabbix/etc/zabbix_agentd.conf

sed -i 's#Hostname=Zabbix server#'"$host_name"'#' /usr/local/zabbix/etc/zabbix_agentd.conf

sed -i 's/# UnsafeUserParameters=0/UnsafeUserParameters=1/' /usr/local/zabbix/etc/zabbix_agentd.conf

service zabbix_agentd start

  • 发表于:
  • 原文链接:http://kuaibao.qq.com/s/20180511G1ODS400?refer=cp_1026
  • 腾讯「云+社区」是腾讯内容开放平台帐号(企鹅号)传播渠道之一,根据《腾讯内容开放平台服务协议》转载发布内容。

扫码关注云+社区

领取腾讯云代金券