Redfish Exporter ile Fiziksel Sunucu Metriklerini Toplama ve Grafana’ya Ekleme

onur kocaman
Turk Telekom Bulut Teknolojileri
4 min readOct 28, 2022

Merhaba,

Geçen yazımızda grafana + prometheus + node exporter üçlüsünü kullanarak OS metriklerini toplayıp göstermiştik. Bu yazı da fiziksel sunucuların donanımsal metriklerini (Fan hızı, çekilen güç ve sıcaklık değerleri vb.) redfish exporter ile çekip, prometheus’ da toplayacağız.

Prometheus’ dan biraz bahsedelim. Prometheus metrikleri izlenecek makinalara api request atar ve pull metodu ile çalışır. Sürekli ayakta olan servisleri için ideal bir kullanımı vardır. Ama kısa süreli çalışan servislerde pull yönetimi ile sorgu atmak anlamsızdır. Bu geçici (ephemeral) servislerin izlenmesi gerektiğinde, prometheus araya “pushgateway” denilen server’ı koyar ve kendi çalışma metodunu değiştirmeden bu servislerden bilgiyi çeker. Ephemeral job’lar özellikle K8s tarafında kullanılır.

Biraz da Redfish protokolünden bahsedelim. Redfish, hemen hemen tüm sunucu markalarının desteklediği uzaktan yönetim protokolüdür. Aşağıdaki listede, redfish’in desteklediği uzaktan yönetim modüllerinin versiyonları bulunmaktadır.

  • Dell iDRAC BMC with minimum iDRAC 7/8 FW 2.40.40.40, iDRAC9 FW 3.00.00.0
  • HPE iLO BMC with minimum iLO4 FW 2.30, iLO5
  • HPE Moonshot BMC with minimum FW 1.41
  • Lenovo XClarity Controller (XCC) BMC with minimum XCC FW 1.00
  • Supermicro X10 BMC with minimum FW 3.0 and X11 with minimum FW 1.0
  • IBM Power Systems BMC with minimum OpenPOWER (OP) firmware level OP940[6]
  • IBM Power Systems Flexible Service Processor (FSP) with minimum firmware level FW860.20[7]
  • Cisco Integrated Management Controller with minimum IMC SW Version 3.0[8]

Çalışmada Python’la yazılmış Redfish exporter’ı kullanarak dell marka sunucularından, ihtiyacımız olan verileri çekeceğiz.

Not: Çalışmada kullanacağımız Prometheus’un kurulumu daha önceki yazıda mevcut.

Kaynak: https://medium.com/t%C3%BCrk-telekom-bulut-teknolojileri/grafana-prometheus-ve-node-exporter-yard%C4%B1m%C4%B1yla-i%C5%9Fletim-sistemlerinin-izlenmesi-35a3cf40220c

Redfish Exporter Kurulumu

# Öncelikle /var/lib dizini altına gidip redfish exporter’ı klonluyoruz.

> cd /var/lib

> git clone https://github.com/42School/redfish-exporter.git

# redfish isminde bir kullanıcı yaratıyoruz.

> useradd redfish -s /sbin/nologin

# redfish-exporter dizinini bu kullanıcıya atıyoruz.

chown redfish:redfish -R redfish-exporter

# Dizinde bulunan örnek config dosyasını kopyalayarak içinde idrac ile ilgili bilgileri giriyoruz.

> cd /var/lib/redfish-exporter

> cp config.yaml.sample config.yaml

> vi config.yaml

hosts:
<idrac_ip_1>:
name: iDRAC-name_1
username: root
password: <password>
proto: https
version: idrac9
verify: False

<idrac_ip_2>:
name: iDRAC-name_2
username: root
password: <password>
proto: https
version: idrac9
verify: False

<idrac_ip_3>:
name: iDRAC-name_3
username: root
password: <password>
proto: https
version: idrac9
verify: False

# Sonrasında pushgateway kurulumunu yapıyoruz. Bu sayede prometheus’a verileri push metodu ile gönderebileceğiz.

> wget https: //github.com/prometheus/pushgateway/releases/download/ v1.2.0/pushgateway-1.2.0.linux-amd64.tar.gz

> tar xvfz pushgateway-1.2.0.linux-amd64.tar.gz
> cp pushgateway-1.2.0.linux-amd64/pushgateway /usr/local/bin/
> chown pushgateway:pushgateway /usr/local/bin/pushgateway

# pushgateway’i servis olarak tanımlıyoruz.
> vi /etc/systemd/system/pushgateway.service

[Unit]
Description=Prometheus Pushgateway
Wants=network-online.target
After=network-online.target

[Service]
User=pushgateway
Group=pushgateway
Type=simple
ExecStart=/usr/local/bin/pushgateway

[Install]
WantedBy=multi-user.target

> systemctl enable pushgateway
> systemctl start pushgateway
> systemctl status pushgateway

# Aşağıdaki pushgateway job’ını prometheus conf dosyasına ekliyoruz ve prometheus servisini restart edyoruz.
> vi /etc/prometheus/prometheus.yml

> systemctl restart prometheus
> systemctl status prometheus

# Şimdi, Python ile Redfish-exporter kurulumuna geçiyoruz ama öncesinde sunucu içinde sanal environment kurmalıyız. Bu sayede sunucuda python ile kurduğumuz ya da kuracağızmı yazılımlarda python paketlerinin çakışmasını engellemiş olacağız.

> apt install python3-virtualenv

> python3.8 -m venv venv

> source venv/bin/activate

> python setup.py install

# şimdi redfish-exporter çalıştırıp metriklerin push edilmesini sağlıyoruz.

python -m redfish_exporter — config ./config.yaml — port 9091 — ip 127.0.0.1 — user pushgateway — password <password>

[2022–10–27 22:57:25,082 — __main__] INFO: Succefull metrics push
[2022–10–27 22:57:27,687 — __main__] INFO: Succefull metrics push
[2022–10–27 22:57:37,337 — __main__] INFO: Succefull metrics push
[2022–10–27 23:00:40,416 — __main__] INFO: Succefull metrics push
[2022–10–27 23:00:45,662 — __main__] INFO: Succefull metrics push
[2022–10–27 23:00:56,581 — __main__] INFO: Succefull metrics push
[2022–10–27 23:03:59,208 — __main__] INFO: Succefull metrics push
[2022–10–27 23:04:04,842 — __main__] INFO: Succefull metrics push
[2022–10–27 23:04:13,484 — __main__] INFO: Succefull metrics push

Şimdi grafanaya, prometheus datasource ve dashboard dosyamızı göstererek metriklerimizi grafanaya yansıtıyoruz.

Aşağıdaki linkten ilgili dashboard indirip grafanaya gösterdiğimiz de sunucuların güç, fan hızı ve sıcakla ve lokal diskleri ile metrik ve loglara ulaşabiliriz.

https://grafana.com/grafana/dashboards/12403-redfish-exporter/

--

--