#!/bin/bash #description: zabbix_agentd install #set -x rpm -qa|grep -i zabbix if [ "$?" -eq 0 ];then echo -e "\033[31m zabbix agent was installd\033[0m" flag=1 else echo "zabbix agent start intstall......" flag=0 fi # 所有下载文件放在 /data/software/init_install/ ############################################################## # 创建下载目录 function checkDir(){ if [ ! -d $dir ];then echo "start create $dir" mkdir -p $dir else: echo -e "$dir was exit" fi } dir="/data/software/init_install/" checkDir cd $dir echo "$dir" ########################################################### #安装rpm文件 function install_zabbix(){ OSver=$(cat /etc/redhat-release |awk '{print $3}'|awk -F "." '{print $1}') yum -y install wget echo $OSver if [ $OSver == "release" ];then echo -e "\033[31m the system version is 7 \033[0m" wget http://haha.com/init_install/zabbix-agent-3.4.5-1.el7.x86_64.rpm zrpm="zabbix-agent-3.4.5-1.el7.x86_64.rpm" else echo -e "\033[31m the system version is 6 \033[0m" wget http://haha.com/init_install/zabbix-agent-3.4.1-1.el6.x86_64.rpm zrpm="zabbix-agent-3.4.1-1.el6.x86_64.rpm" fi yum -y install flex byacc libpcap libpcap-devel ncurses ncurses-devel # 判断rpm文件是否存在 if [ ! -f $zrpm ];then echo -e "\033[31m rpm was not exit \033[0m" exit 1 fi rpm -ivh $zrpm if [ $? -eq 0 ];then echo -e " \033[31m zabbix_agent installed successful \033[0m " else echo -e "\033[32m zabbix_agent install was failed ! \033[0m" exit 2 fi sed -i 's#Server=127.0.0.1#Server=xxx.xxx.xxx.xxxx#g' /etc/zabbix/zabbix_agentd.conf #启动服务 chkconfig zabbix-agent on service zabbix-agent start if [ $? -eq 0 ];then echo "zabbix_agent was started " else echo "zabbix_agent start was failed!" exit 1 fi } #################### if [ $flag -eq 0 ];then checkDir install_zabbix else echo "error exit" exit 1 fi
zabbix客户端脚本
标签:agentd,agent,echo,zabbix,install,033,rpm From: https://www.cnblogs.com/python-uuu/p/16633675.html