使用 Prometheus IPMI 导出器获取远程机器的 IPMI 信息

本文的目的

本文介绍了使用 Prometheus IPMI Exporter 在 Prometheus 服务器上收集远程机器(未启动 ipmi_exporter 进程的监控目标服务器)的 IPMI 信息的方法。

如果阅读公式GitHub存储库的README.md文件,从启动ipmi_exporter进程的本地机器收集IPMI信息是不难的。然而,由于监视远程机器时的配置方法不明确,所以我决定写这篇文章,既作为备忘录,也作为自己理解的记录。

    • この記事に含まれるもの:

Prometheus サーバの最低限の起動方法
Prometheus IPMI Exporter の最低限の起動方法
Prometheus IPMI Exporter で遠隔マシンから IPMI 情報を取得するための設定の詳細

この記事に含まれないもの:

Prometheus に関する詳細な解説

获取远程机器的IPMI信息

本文介绍了以Prometheus服务器和被监视服务器的两台服务器进行配置,在Prometheus服务器上启动Prometheus和Prometheus IPMI Exporter两个进程,以在Prometheus服务器上收集被监视服务器的IPMI信息。

undefined

为了获取远程机器的 IPMI 信息,需要分别设置 Prometheus 和 Prometheus IPMI Exporter 的配置文件,现在将对它们的内容进行解释。

Prometheus:

prometheus.yml
target_ipmi.yml

Prometheus IPMI Exporter:

ipmi_remote.yml

Prometheus IPMI Exporter 是什么?

Prometheus IPMI Exporter通过收集本地或远程机器的IPMI信息,并将数据暴露给Prometheus服务器。Prometheus定期访问Prometheus IPMI Exporter,对收集的各种数据进行集中管理。

Prometheus (https://github.com/prometheus/prometheus)

Prometheus IPMI Exporter (https://github.com/prometheus-community/ipmi_exporter)

事前准备

前提条件是 Prometheus 服务器和被监视服务器已经安装了操作系统,IP 地址已正确设置,并且它们可以互相通信。

安装 Prometheus 到 Prometheus 服务器。

    1. 在适当的位置创建适当的工作文件夹(例如prometheus/),然后移动到该文件夹:

4shi1o@ubuntu:~$ mkdir prometheus
4shi1o@ubuntu:~$ cd prometheus
4shi1o@ubuntu:~/prometheus$

从Prometheus官方网站下载最新的二进制文件:

4shi1o@ubuntu:~/prometheus$ wget https://github.com/prometheus/prometheus/releases/download/v2.31.1/prometheus-2.31.1.linux-amd64.tar.gz

解压下载的tar.gz文件:

4shi1o@ubuntu:~/prometheus$ tar xfz prometheus-2.31.1.linux-amd64.tar.gz

2. 在 Prometheus 服务器上安装 Prometheus IPMI 导出器。

    1. 在适当的位置创建适当的工作文件夹(例如prometheus/),并进行移动。

4shi1o@ubuntu:~$ mkdir ipmi_exporter
4shi1o@ubuntu:~$ cd ipmi_exporter
4shi1o@ubuntu:~/ipmi_exporter$

从prometheus-community/ipmi_exporter的GitHub项目中下载最新版本的二进制文件。

4shi1o@ubuntu:~/ipmi_exporter$ wget https://github.com/prometheus-community/ipmi_exporter/releases/download/v1.4.0/ipmi_exporter-1.4.0.linux-amd64.tar.gz

解压下载的tar.gz文件。

4shi1o@ubuntu:~/ipmi_exporter$ tar xfz ipmi_exporter-1.4.0.linux-amd64.tar.gz

3. 安装freeipmi

为了收集IPMI信息,Prometheus IPMI 导出程序需要先安装freeipmi命令。

4shi1o@ubuntu:~$ sudo apt install freeipmi

用于获取远程机器的 IPMI 信息的配置文件。

Prometheus: prometheus.yml

prometheus.yml は、下記 2 つの場所で紹介されているサンプルを組み合わせて作成します。

Prometheus の Getting started ドキュメント に記載されているサンプル

scrape_interval に特別なこだわりがなければ、サンプルをそのまま利用します。
デフォルトで、Prometheus プロセスは、9090 ポートで起動します。

Prometheus IPMI Exporter の Configuration ドキュメント に記載されているサンプル

修正すべき箇所が 2 つあります。

file_sd_configs 内の files で指定するファイル名およびパス: 今回の例では、ipmi_targets.yml と指定します。

separator 内の replacement で指定する Prometheus IPMI Exporter が起動する IP アドレスとポート番号の組み合わせ: 今回の例では、localhost:9290 と指定します。

global:
  scrape_interval: 15s

scrape_configs:
  - job_name: "prometheus"
    scrape_interval: 5s
    static_configs:
      - targets: ["localhost:9090"]

# ここまで: Prometheus の Gettubg started ドキュメントのサンプルを利用
# ここから: Prometheus IPMI Exporter の Configuration ドキュメントのサンプルを利用

  - job_name: "ipmi"
    params:
      module: ['default']
    scrape_interval: 30s
    scrape_timeout: 15s
    metrics_path: /ipmi
    scheme: http
    file_sd_configs:
    - files:
      - ipmi_targets.yml
      refresh_interval: 5m
    relabel_configs:
    - source_labels: [__address__]
      separator: ;
      regex: (.*)
      target_label: __param_target
      replacement: ${1}
      action: replace
    - source_labels: [__param_target]
      separator: ;
      regex: (.*)
      target_label: instance
      replacement: ${1}
      action: replace
    - separator: ;
      regex: .*
      target_label: __address__
      replacement: localhost:9290
      action: replace

Prometheus: ipmi_targets.yml

ipmi_targets.yml は、下記サンプルを利用します。

Prometheus IPMI Exporter の Configuration ドキュメント に記載されているサンプル

targets で指定する IP アドレスは、監視対象マシンの IP アドレスに修正してください。

---
- targets:
  - 10.1.2.23    # 例えば、これが監視対象マシンの IP アドレスだとする
  labels:
    job: ipmi_exporter

Prometheus IPMI Exporter: ipmi_remote.yml

ipmi_remote.yml は、下記サンプルを利用します。

Prometheus IPMI Exporter の ipmi_remote.yml

各 module 内に記載されている user と pass を監視対象マシンの IPMI ユーザ、パスワードに修正してください。
今回の例では、default モジュールのみ実行するので、他のモジュールに関する設定は削除していますが、そのまま残しておいても問題ありません。

modules:
        default:
                # These settings are used if no module is specified, the
                # specified module doesn't exist, or of course if
                # module=default is specified.
                user: "default_user"
                pass: "example_pw"
                # The below settings correspond to driver-type, privilege-level, and
                # session-timeout respectively, see `man 5 freeipmi.conf` (and e.g.
                # `man 8 ipmi-sensors` for a list of driver types).
                driver: "LAN_2_0"
                privilege: "user"
                # The session timeout is in milliseconds. Note that a scrape can take up
                # to (session-timeout * #-of-collectors) milliseconds, so set the scrape
                # timeout in Prometheus accordingly.
                timeout: 10000
                # Available collectors are bmc, ipmi, chassis, dcmi, sel, and sm-lan-mode
                # If _not_ specified, bmc, ipmi, chassis, and dcmi are used
                collectors:
                - bmc
                - ipmi
                - chassis
                # Got any sensors you don't care about? Add them here.
                exclude_sensor_ids:
                - 2
                - 29
                - 32
                - 50
                - 52
                - 55

请尝试具体执行一下

image.png

请提供相关的网址

普罗米修斯公式文件

    • First Steps with Prometheus

 

    • Download

 

    Exporters and Integrations

Prometheus相关的GitHub存储库

Prometheus

Getting started

Prometheus IPMI Exporter

Configuration
ipmi_remote.yml

bannerAds