#! /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

最新文章

  1. SQL2008中Merge的用法
  2. ---ps 命令
  3. Java IO读取文件之二
  4. 图像处理JPEGCodec类错误问题 毕业设计遇到的问题
  5. Careercup - Google面试题 - 6331648220069888
  6. JavaBean技术
  7. 不借助jquery封装好的ajax,你能用js手写ajax框架吗
  8. 1742. Team building(dfs)
  9. 计算S(n)=a+aa+aaa+...... 其中a是一个数字
  10. 汇编函数调用中bp和sp是指什么?
  11. 《Programming WPF》翻译 第6章 2.资源与样式
  12. mongodb操作记录
  13. Spoken English
  14. 两个div横向排列,顶端对齐的方式。
  15. 通讯录--(适配iOS7/8/9)
  16. 自制mpls ldp实验
  17. PyTorch教程之Tensors
  18. JavaScript并发模型与Event Loop (转载)
  19. Sublime Text 3 Mac常用快捷键与注意事项
  20. IDEA 设置 TOMCAT 虚拟路径

热门文章

  1. Java高并发程序设计学习笔记(十一):Jetty分析
  2. 转载--Java中的PO、DO、DTO、 VO的概念
  3. python文件操作:文件处理案例
  4. Linux命令行——scp命令
  5. 转 SQL连接查询语句(内、外、交叉和合并查询)
  6. nginx代理服务
  7. Java-Base64工具类
  8. HDU-1358-Period(KMP, 循环节)
  9. 部署安装python3.7
  10. linux下su设置无密码模式