はじめに
Ceph にはダッシュボードがありクラスタの状態を確認できる。
しかし既存の監視と統合したい場合には Zabbix で監視したいこともあるかもしれない。
Zabbix で Ceph を監視しようと思ったとき方法が 2 種類あるようだ。
- Ceph の
zabbix module
によって値を取得する方法 - Zabbix-Agent2 のプラグインによって値を取得する方法
今回は Zabbix-Agent2 のプラグインによって値を取得する方法を解説する。
環境
- Zabbix 7.0 LTS
- Ceph 19.2.2 squid (stable)
Zabbix のダッシュボードからテンプレートを追加する
各監視対象のホストに Ceph のテンプレートを追加する。
Data colection -> Host -> 監視対象
ホスト設定のテンプレートにCeph by Zabbix agent 2
を追加
何も設定していないのでアイテムは表示されるが下記のようにエラーが出る。
Cannot fetch data: Post "https://zabbix:***@localhost:8003/request?wait=1": dial tcp 127.0.0.1:8003: connect: connection refused.
ここで問題となるのは8003
ポートは何者かということ。
私の環境では少なくとも Listen していなかった。
$ sudo ss -ltnp | grep 8003
$
Zabbix の公式ページでも特に言及なし。
Ceph の Restful モジュールの設定とトラブルシューティング
8003 ポートに関して検索していると Restful モジュールで利用していることがわかった。
しかし私の環境では Restful モジュールはすでに ON だった
$ sudo ceph mgr module ls
MODULE
balancer on (always on)
crash on (always on)
devicehealth on (always on)
orchestrator on (always on)
pg_autoscaler on (always on)
progress on (always on)
rbd_support on (always on)
status on (always on)
telemetry on (always on)
volumes on (always on)
cephadm on
dashboard on
iostat on
nfs on
prometheus on
restful on
ポートを明示的に指定してみる
公式ドキュメントでは Restful モジュールのはデフォルトで0.0.0.0:8003
を Listen するとしているが、明示的に設定してみる。
$ sudo ceph config set mgr mgr/restful/server_addr 127.0.0.1
$ sudo ceph config set mgr mgr/restful/server_port 8003
$ sudo ceph config dump | grep restful
mgr advanced mgr/restful/server_addr 127.0.0.1 *
mgr advanced mgr/restful/server_port 8003 *
この状態でも Listen しなかった。
ユーザを設定してみる
Zabbix 用のユーザを作成する。
$ sudo ceph restful create-key zabbix
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx
この状態でも Listen はしなかった。
証明書を設定してみる
すでに有効になっているので必要ないと思っていたが証明書を設定してみた。
$ sudo ceph restful create-self-signed-cert
この設定で Listen する状態になった。
$ sudo ss -ltnp | grep 8003
LISTEN 0 128 127.0.0.1:8003 0.0.0.0:* users:(("ceph-mgr",pid=2751734,fd=87))
直接の例ではないがこのトラブルシューティングから着想を得た。
Zabbix のエラー内容が変わった
Cannot fetch data: Post "https://zabbix:***@localhost:8003/request?wait=1": tls: failed to verify certificate: x509: certificate is not valid for any names, but wanted to match localhost.
自己証明書のエラーになったのでかなり進展した。
証明書チェックを無効化する
ceph のプラグインの設定ファイルで証明書チェックを無効化する。
$ sudo vim /etc/zabbix/zabbix_agent2.d/plugins.d/ceph.conf
Plugins.Ceph.InsecureSkipVerify=true
Zabbix-Agent2 を再起動する。
$ sudo systemctl restart zabbix-agent2.service
これでデータが取れるようになった。
監視できない項目がいくつかあった
Ceph OSD Apply latency Avg
など一部の項目がAccess denied.
で表示できなかった。
マネージャーデーモンの権限まわりの問題のようなので調整する。
作業前の権限は以下
$ sudo ceph auth ls
mgr.node01.xxxxxx
key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
caps: [mds] allow *
caps: [mon] profile mgr
caps: [osd] allow *
mgr.node02.xxxxxx
key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
caps: [mds] allow *
caps: [mon] profile mgr
caps: [osd] allow *
mgr.node03.xxxxxx
key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
caps: [mds] allow *
caps: [mon] profile mgr
caps: [osd] allow *
profile mgr
は基本操作のための最低限の権限のみ許可された状態。
これらの設定を変更する。
mon ‘allow *’ のみ指定すると mds や osd の 設定が消えるので注意! 必ず現在の設定を確認して mon、mds、osd 全て同時に設定する。
$ sudo ceph auth caps mgr.node01.xxxxxx mon 'allow *' mds 'allow *' osd 'allow *'
$ sudo ceph auth caps mgr.node02.xxxxxx mon 'allow *' mds 'allow *' osd 'allow *'
$ sudo ceph auth caps mgr.node03.xxxxxx mon 'allow *' mds 'allow *' osd 'allow *'
サーバー名mgr.node01.xxxxxx
は環境によって変更する。
$ sudo systemctl restart ceph.target
再起動して設定を適用する。
まとめ
Ceph のクラスタを Zabbix-Agent2 で監視した。
Restful モジュールを利用して監視するためクラスタ側である程度設定することが必要だった。
監視自体はできるもののマネージャーデーモンが複数ある場合に、マネージャーデーモンの稼働ホストが切り替わると監視が途切れることとなる。
実運用には IP を固定やトリガーの調整などもうひと工夫が必要そうだ。