zabbix-client-install

#!/bin/bash
# 此脚本主要针对CentOS 6 or 7 版本进行zabbix-agent添加

# 以root用户运行脚本
if [ $(id -u) != "0" ]; then
    echo "You must be root to run this script ..."
    exit 1
fi

if [ $# != "1" ]; then
    echo "Give me ZABBIX server IP ..."
    exit 2
fi

# selinux 会阻止服务开启,所以关闭
sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config
setenforce 0

if [ -f /etc/redhat-release ];then
        Edition=`grep -o '[[:digit:]]' /etc/redhat-release |head -1`
else
        Edition=`uname`
fi

case "$Edition" in
      7)
        echo -e "\n\033[34mStart installation……\033[0m\n"
        rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
        yum -y install zabbix-agent zabbix-sender
        sed -i  "/Server/s/Server=127.0.0.1/Server=$1/" /etc/zabbix/zabbix_agentd.conf
        sed -i  "/Server/s/ServerActive=127.0.0.1/ServerActive=$1/" /etc/zabbix/zabbix_agentd.conf
        systemctl start zabbix-agent
        systemctl enable zabbix-agent
        ;;
      6)
        echo -e "\n\033[34mStart installation……\033[0m\n"
        rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/6/x86_64/zabbix-release-3.0-1.el6.noarch.rpm
        yum -y install zabbix-agent zabbix-sender
        sed -i  "/Server/s/Server=127.0.0.1/Server=$1/" /etc/zabbix/zabbix_agentd.conf
        sed -i  "/Server/s/ServerActive=127.0.0.1/ServerActive=$1/" /etc/zabbix/zabbix_agentd.conf
        /etc/init.d/zabbix-agent start
        chkconfig zabbix-agent on
        ;;
    *)
        echo "========================================================================"
        echo "This system is not CentOS 6 or 7, script execution failed!!"
        echo "========================================================================"
        exit 3
esac

if ss -ntl|grep 10050 &>/dev/null; then
    echo -e "\n\033[32mCongratulations, ZABBIX client installed successfully\033[0m\n"
else
    echo -e "\n\033[31mSorry, please rerun the command or contact the administrator\033[0m\n"
fi

成都创新互联是一家专业提供茶陵企业网站建设,专注与网站设计、网站制作H5页面制作、小程序制作等业务。10年已为茶陵众多企业、政府机构等服务。创新互联专业网络公司优惠进行中。

新闻标题:zabbix-client-install
文章源于:https://www.cdcxhl.com/article6/igeiog.html

成都网站建设公司_创新互联,为您提供网站策划自适应网站搜索引擎优化定制网站App开发网站排名

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

外贸网站制作