zabbix客户端安装脚本

592 人阅读
分类:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
Hostname=`hostname`
debain_install(){
    wget https://repo.zabbix.com/zabbix/4.0/debian/pool/main/z/zabbix-release/zabbix-release_4.0-3+buster_all.deb
    dpkg -i zabbix-release_4.0-3+buster_all.deb
    apt -y install zabbix-agent
    sed -i 's@Server=127.0.0.1@Server=11.11.11.11@g' /etc/zabbix/zabbix_agentd.conf
    sed -i 's@ServerActive=127.0.0.1@ServerActive=11.11.11.11@g' /etc/zabbix/zabbix_agentd.conf
    sed -i "s@Hostname=Zabbix server@Hostname=${Hostname}@g" /etc/zabbix/zabbix_agentd.conf
    systemctl start zabbix-agent
    systemctl enable zabbix-agent
}
centos_install(){
    rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
    yum install zabbix-agent -y
    sed -i 's@Server=127.0.0.1@Server=11.11.11.11@g' /etc/zabbix/zabbix_agentd.conf
    sed -i 's@ServerActive=127.0.0.1@ServerActive=11.11.11.11@g' /etc/zabbix/zabbix_agentd.conf
    sed -i "s@Hostname=Zabbix server@Hostname=${Hostname}@g" /etc/zabbix/zabbix_agentd.conf
    systemctl start zabbix-agent.service
    systemctl enable zabbix-agent.service
}
os_check() {
    if [ -e /etc/redhat-release ]; then
            REDHAT=`cat /etc/redhat-release |cut -d' '  -f1`
    else
            DEBIAN=`cat /etc/issue |cut -d' ' -f1`
    fi
    if "$REDHAT" == "CentOS" -o "$REDHAT" == "Red" ]; then
            centos_install
    elif [ "$DEBIAN" == "debian" -o "$DEBIAN" == "Debian" ]; then
            debain_install
    else
            Operating system does not support.
            exit 1
    fi
}
if [ -x "$(command -v zabbix_agentd)" ]; then
        echo "zabbix_agentd already install"
        exit 1
else
    os_check
fi
systemctl restart zabbix-agent.service


和博主交个朋友吧
关闭

博主小程序[微信扫一扫]

    发布篇幅
    • 文章总数:0
    • 原创:0
    • 转载:0
    • 译文:0
    文章分类
      文章存档
      阅读排行