开源网络监控工具部署安装

昨天推荐了网络监控工具,今天介绍下几款开源监控工具的安装方法
开源网络监控工具有很多,常见的有 Nagios、Zabbix、Prometheus+Grafana 等。以下是一些流行的开源网络监控工具的部署和安装步骤:

1. Nagios

Nagios 是一个功能强大的开源网络监控工具,适用于监控各种网络设备、服务器和服务。

安装步骤(以 Ubuntu 为例):

  1. 更新包列表并安装必要的依赖:

    sudo apt update
    sudo apt install -y autoconf gcc libc6 make wget unzip apache2 php libapache2-mod-php7.4 libgd-dev
    
  2. 创建 Nagios 用户和组:

    sudo useradd nagios
    sudo groupadd nagcmd
    sudo usermod -a -G nagcmd nagios
    sudo usermod -a -G nagcmd www-data
    
  3. 下载并解压 Nagios:

    cd /tmp
    wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.6.tar.gz
    tar zxvf nagios-4.4.6.tar.gz
    cd nagios-4.4.6
    
  4. 编译和安装 Nagios:

    ./configure --with-command-group=nagcmd
    make all
    sudo make install
    sudo make install-commandmode
    sudo make install-init
    sudo make install-config
    sudo make install-webconf
    
  5. 设置 Nagios Web 界面的基本身份验证:

    sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
    
  6. 启动 Apache 和 Nagios 服务:

    sudo systemctl restart apache2
    sudo systemctl start nagios
    sudo systemctl enable nagios
    
  7. 访问 Nagios Web 界面:

    打开浏览器,访问 http://<server-ip>/nagios,使用刚才创建的 nagiosadmin 用户登录。

2. Zabbix

Zabbix 是一个企业级的开源监控工具,支持监控各种 IT 组件,包括网络设备、服务器、虚拟机和云资源。

安装步骤(以 Ubuntu 为例):

  1. 安装 Zabbix 仓库:

    wget https://repo.zabbix.com/zabbix/5.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.0-1+ubuntu18.04_all.deb
    sudo dpkg -i zabbix-release_5.0-1+ubuntu18.04_all.deb
    sudo apt update
    
  2. 安装 Zabbix 服务器、前端和代理:

    sudo apt install zabbix-server-mysql zabbix-frontend-php zabbix-agent
    
  3. 创建初始数据库:

    sudo apt install mysql-server
    sudo mysql_secure_installation
    
    mysql -uroot -p
    create database zabbix character set utf8 collate utf8_bin;
    create user zabbix@localhost identified by 'password';
    grant all privileges on zabbix.* to zabbix@localhost;
    quit;
    
  4. 导入初始架构和数据:

    zcat /usr/share/doc/zabbix-server-mysql/create.sql.gz | mysql -uzabbix -p zabbix
    
  5. 配置数据库连接:

    编辑 /etc/zabbix/zabbix_server.conf 文件,并设置数据库密码:

    DBPassword=password
    
  6. 配置 PHP 前端:

    编辑 /etc/zabbix/apache.conf 文件,并设置时区:

    php_value date.timezone Europe/Riga
    
  7. 启动 Zabbix 服务器和代理进程:

    sudo systemctl restart zabbix-server zabbix-agent apache2
    sudo systemctl enable zabbix-server zabbix-agent apache2
    
  8. 访问 Zabbix 前端:

    打开浏览器,访问 http://<server-ip>/zabbix,并按照向导完成配置。

3. Prometheus + Grafana

Prometheus 是一个开源的系统监控和报警工具,Grafana 是一个开源的数据可视化工具。两者常常结合使用,用于监控和可视化数据。

安装步骤(以 Ubuntu 为例):

安装 Prometheus:

  1. 创建 Prometheus 用户:

    sudo useradd --no-create-home --shell /bin/false prometheus
    
  2. 下载并安装 Prometheus:

    wget https://github.com/prometheus/prometheus/releases/download/v2.31.1/prometheus-2.31.1.linux-amd64.tar.gz
    tar -xvf prometheus-2.31.1.linux-amd64.tar.gz
    sudo mv prometheus-2.31.1.linux-amd64 /usr/local/prometheus
    sudo chown -R prometheus:prometheus /usr/local/prometheus
    
  3. 创建 Prometheus 配置文件:

    创建 /etc/prometheus/prometheus.yml 文件:

    global:
      scrape_interval: 15s
    scrape_configs:
      - job_name: 'prometheus'
        static_configs:
          - targets: ['localhost:9090']
    
  4. 创建 Systemd 服务文件:

    创建 /etc/systemd/system/prometheus.service 文件:

    [Unit]
    Description=Prometheus
    Wants=network-online.target
    After=network-online.target
    
    [Service]
    User=prometheus
    Group=prometheus
    Type=simple
    ExecStart=/usr/local/prometheus/prometheus --config.file=/etc/prometheus/prometheus.yml --storage.tsdb.path=/usr/local/prometheus/data
    
    [Install]
    WantedBy=multi-user.target
    
  5. 启动 Prometheus:

    sudo systemctl daemon-reload
    sudo systemctl start prometheus
    sudo systemctl enable prometheus
    

安装 Grafana:

  1. 添加 Grafana 仓库:

    sudo apt-get install -y software-properties-common
    sudo add-apt-repository "deb https://packages.grafana.com/oss/deb stable main"
    wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
    
  2. 安装 Grafana:

    sudo apt-get update
    sudo apt-get install grafana
    
  3. 启动 Grafana:

    sudo systemctl start grafana-server
    sudo systemctl enable grafana-server
    
  4. 访问 Grafana:

    打开浏览器,访问 http://<server-ip>:3000,默认用户名和密码是 admin

  5. 配置数据源:

    在 Grafana 中添加 Prometheus 作为数据源,地址为 http://localhost:9090

  6. 创建仪表盘:

    使用 Grafana 创建新的仪表盘,并添加相关的图表和指标。

总结

以上介绍了三款流行的开源网络监控工具:Nagios、Zabbix 和 Prometheus+Grafana 的安装和基本配置步骤。选择适合你的工具取决于具体的监控需求、环境规模和技术背景。

  • 27
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

iangyu

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值