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















本文转自younger00851CTO博客,原文链接:http://blog.51cto.com/younger008/1918676 ,如需转载请自行联系原作者


相关文章
|
6月前
|
监控 数据库连接 数据安全/隐私保护
安装Zabbix Server
安装Zabbix Server
95 1
|
监控 关系型数据库 MySQL
zabbix-server和zabbix-agent简单安装
zabbix-server和zabbix-agent简单安装
189 0
|
监控
zabbix通过yum安装,启动报错zabbix-agent.service never wrote its PID file. Failing.
zabbix通过yum安装,启动报错zabbix-agent.service never wrote its PID file. Failing.
249 0
|
NoSQL Redis
How to Install and Configure Redis Server on Debian 9
In this tutorial, we will to install, configure, and use Redis on Debian 9 with Alibaba Cloud ECS.
3392 0
How to Install and Configure Redis Server on Debian 9
|
Oracle 关系型数据库 数据库管理
|
监控 关系型数据库 MySQL
|
关系型数据库 应用服务中间件 PHP
|
监控 Linux 关系型数据库
|
监控 Apache 应用服务中间件
|
数据库 关系型数据库 MySQL