CentOS6 Zabbix-Agent2.0安装脚本
2024-10-07 00:02:43
#! /bin/bash
#####################################
#-----------------------------------#
#------zabbix_agentd2.0_install-----#
#-----------------------------------#
##################################### user=zabbix
hostname=`hostname`
zabbix_path="/usr/local/zabbix_agent"
zabbix_name="zabbix_agents_2.0.6.linux2_6.amd64.tar.gz"
#zabbix_conf=`find /usr/local -name zabbix_agentd.conf`
#zabbix_conf_path=${zabbix_conf%/*}
#zabbix_sbin=`find /usr/local -name zabbix_agentd -type f`
#zabbix_sbin_path=${zabbix_sbin%/*} #检查系统里面是否有yum安装的zabbix_agentd##
rpm -qa | grep zabbix >> /dev/null
if [ $? == 0 ];then
echo "zabbix_agentd is installed,If you need to continue the installation,Please execute 'yum remove zabbix-agent -y'"
exit 110
fi
#检查系统里面是否有编译安装的zabbix_agentd##
#find /usr/local -name zabbix_agentd.conf
zabbix_conf=`find /usr/local -name zabbix_agentd.conf`
zabbix_conf_path=${zabbix_conf%/*}
if [ -f "$zabbix_conf" ];then
echo "zabbi_agent2.0 installed exit 120"
exit 120
else
echo "install zabbix_agent"
fi
#检查是否存在Zabbix-agent安装包
if [ -f "$zabbix_name" ];then
echo "zabbix_agentd is exist"
else
echo "wget zabbix-agent"
yum install wget -y
wget http://www.zabbix.com/downloads/2.0.6/zabbix_agents_2.0.6.linux2_6.amd64.tar.gz
sleep 2
fi
mkdir -p $zabbix_path
tar zxvf $zabbix_name -C $zabbix_path
sleep 2
zabbix_conf=`find /usr/local -name zabbix_agentd.conf`
zabbix_conf_path=${zabbix_conf%/*}
cd $zabbix_conf_path
sed -i 's/Server=127.0.0.1/Server=Server.hostname/g' ./zabbix_agentd.conf
sed -i 's/ServerActive=127.0.0.1/ ServerActive=Server.hostname/g' ./zabbix_agentd.conf
sed -i "s/Hostname=Zabbix server/Hostname=$hostname/g" ./zabbix_agentd.conf ##变量需要双引号来调用#
cat /etc/passwd | grep $user >> /dev/null
if [ $? == 0 ];then
echo "User exist" >> /dev/null
else
useradd $user
fi
####启动zabbix_agentd####
zabbix_conf=`find /usr/local -name zabbix_agentd.conf`
zabbix_conf_path=${zabbix_conf%/*}
zabbix_sbin=`find /usr/local -name zabbix_agentd -type f`
zabbix_sbin_path=${zabbix_sbin%/*}
$zabbix_sbin_path/zabbix_agentd -c $zabbix_conf_path/zabbix_agentd.conf
echo "Please execute 'netstat -tunlp | grep zabbix'"
exit 120
最新文章
- SQL2008中Merge的用法
- ---ps 命令
- Java IO读取文件之二
- 图像处理JPEGCodec类错误问题 毕业设计遇到的问题
- Careercup - Google面试题 - 6331648220069888
- JavaBean技术
- 不借助jquery封装好的ajax,你能用js手写ajax框架吗
- 1742. Team building(dfs)
- 计算S(n)=a+aa+aaa+...... 其中a是一个数字
- 汇编函数调用中bp和sp是指什么?
- 《Programming WPF》翻译 第6章 2.资源与样式
- mongodb操作记录
- Spoken English
- 两个div横向排列,顶端对齐的方式。
- 通讯录--(适配iOS7/8/9)
- 自制mpls ldp实验
- PyTorch教程之Tensors
- JavaScript并发模型与Event Loop (转载)
- Sublime Text 3 Mac常用快捷键与注意事项
- IDEA 设置 TOMCAT 虚拟路径