#!/bin/bash # Author: kernal # Date:2014-03-25 # Filename: autoinstall_zabbixclient.sh # auto install & config zabbix_agent_client find /etc/yum.repos.d/ -name epel.repo if [ $? -eq 0 ]; then yum –enablerepo=epel -y install zabbix-agent else rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm fi input_fun() { OUTPUT_VAR=$1 //$1 就是Input Host ip or name INPUT_VAR=”” //定义变量INPUT_VAR起始值为空 while [ -z $INPUT_VAR ]; do //判断变量INPUT_VAR是否为空 read -p “$OUTPUT_VAR” INPUT_VAR //进入交互式,继续输入ip地址,知道输出内容后退出此次循环 done echo $INPUT_VAR } IPADDR=$( input_fun “Input Host ip [192.168.1.188 or www.iopenstack.com]: “) //定义变量IPADDR LOCAL_HOST_NAME=$( input_fun “Input Host Name [yourhostname]: “) //定义主机名称 # Edit file sed -i ’82 s/Server=127.0.0.1/Server=’$IPADDR’/’ /etc/zabbix/zabbix_agentd.conf # Edit Hostname sed -i ’105 s/Hostname=Zabbix server/Hostname=’$LOCAL_HOST_NAME’/’ /etc/zabbix/zabbix_agentd.conf if [ $? -eq 0 ];then echo “successful” fi /etc/init.d/zabbix-agent start chkconfig zabbix-agent on
本文出自 “西伯利亚·狼” 博客,请务必保留此出处http://kernal.blog.51cto.com/8136890/1530235
auto install zabbix-agent,布布扣,bubuko.com
原文地址:http://kernal.blog.51cto.com/8136890/1530235