2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

enebularAdvent Calendar 2016

Day 18

enebular INFOMOTIONでサーバ監視(リソース監視)

Posted at

概要

Node-REDのノードでnode-red-contrib-osというものがあります。これを使えばサーバの基本情報を取得したり、CPU/メモリ/ディスクといったリソースを監視したりすることができます。

とりあえずenebular Flowで試してみる

Flowは以下です。

[{"id":"67b92c01.7430ec","type":"milkcocoa","z":"fe18e088.694ba","appId":"<あなたのMilkcocoa App ID>"},{"id":"f7925704.7ab208","type":"CPUs","z":"fe18e088.694ba","name":"","x":98.5,"y":209,"wires":[["ba663891.29ea08"]]},{"id":"f7de6c38.ea8e5","type":"Loadavg","z":"fe18e088.694ba","name":"","x":104.5,"y":158,"wires":[["8e77d6b9.27c198"]]},{"id":"7e475bd9.4655dc","type":"Memory","z":"fe18e088.694ba","name":"","x":271.5,"y":57,"wires":[["c5b91d21.456ea"]]},{"id":"25c96c09.14060c","type":"inject","z":"fe18e088.694ba","name":"","topic":"","payload":"","payloadType":"date","repeat":"60","crontab":"","once":false,"x":100.5,"y":44.5,"wires":[["7e475bd9.4655dc","2137a046.a2371","f7de6c38.ea8e5","f7925704.7ab208"]]},{"id":"89f73b88.486e48","type":"milkcocoa out","z":"fe18e088.694ba","milkcocoa":"67b92c01.7430ec","dataStore":"server1/loadavg","operation":"push","targetId":"","name":"","x":446.5,"y":158,"wires":[["a9e9f392.0fa768"]]},{"id":"a9e9f392.0fa768","type":"debug","z":"fe18e088.694ba","name":"","active":true,"console":"false","complete":"false","x":544.5,"y":273,"wires":[]},{"id":"2137a046.a2371","type":"Drives","z":"fe18e088.694ba","name":"","x":113.5,"y":107,"wires":[["eef9a751.5d3b6"]]},{"id":"8e77d6b9.27c198","type":"change","z":"fe18e088.694ba","name":"","rules":[{"t":"set","p":"payload.loadavg1","pt":"msg","to":"payload.loadavg.0","tot":"msg"},{"t":"set","p":"payload.loadavg5","pt":"msg","to":"payload.loadavg.1","tot":"msg"},{"t":"set","p":"payload.loadavg15","pt":"msg","to":"payload.loadavg.2","tot":"msg"},{"t":"delete","p":"payload.loadavg","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":271.5,"y":157.5,"wires":[["89f73b88.486e48"]]},{"id":"ba663891.29ea08","type":"change","z":"fe18e088.694ba","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.cpus.0","tot":"msg"},{"t":"set","p":"payload.user","pt":"msg","to":"payload.times.user","tot":"msg"},{"t":"set","p":"payload.nice","pt":"msg","to":"payload.times.nice","tot":"msg"},{"t":"set","p":"payload.sys","pt":"msg","to":"payload.times.sys","tot":"msg"},{"t":"set","p":"payload.idle","pt":"msg","to":"payload.times.idle","tot":"msg"},{"t":"set","p":"payload.irq","pt":"msg","to":"payload.times.irq","tot":"msg"},{"t":"delete","p":"payload.times","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":273,"y":210,"wires":[["bb10b0e8.ecd9b8"]]},{"id":"bb10b0e8.ecd9b8","type":"milkcocoa out","z":"fe18e088.694ba","milkcocoa":"67b92c01.7430ec","dataStore":"server1/cpus","operation":"push","targetId":"","name":"","x":449,"y":208,"wires":[["a9e9f392.0fa768"]]},{"id":"5c1e076.78c99f8","type":"milkcocoa out","z":"fe18e088.694ba","milkcocoa":"67b92c01.7430ec","dataStore":"server1/drives","operation":"push","targetId":"","name":"","x":447,"y":107,"wires":[["a9e9f392.0fa768"]]},{"id":"c5b91d21.456ea","type":"milkcocoa out","z":"fe18e088.694ba","milkcocoa":"67b92c01.7430ec","dataStore":"server1/memory","operation":"push","targetId":"","name":"","x":449,"y":58,"wires":[["a9e9f392.0fa768"]]},{"id":"eef9a751.5d3b6","type":"change","z":"fe18e088.694ba","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.0","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":269,"y":105,"wires":[["5c1e076.78c99f8"]]}]

image

CPU、メモリ、ディスク、Load Averageといった情報を1分間隔で取得して多少データ加工をしてからMilkcocoaへ投入しています。とりあえず試すためにCPUとディスクは取得できる配列の最初の要素のデータだけ投入しています。

今回はMilkcocoaのデータストアを以下のように各メトリクス毎に用意しました。

メトリクス データストア
Load Average server1/loadavg
CPU server1/cpus
ディスク server1/drives
メモリ server1/memory

Milkcocoaのデータストアの詳細についてはドキュメントを参照します。

enebular INFOMOTIONで可視化

あとはenebular INFOMOTIONの設定をします。データソースの設定INFOMOTIONの作成の詳細は各リンク先のドキュメントを参照します。

Load Average

データソース設定

image

INFOMOTION設定

項目 設定する値
TYPE metricsgraphics
DATASOURCE server1/loadavg
rows y_accessor loadavg1
rows y_accessor loadavg5
rows y_accessor loadavg15
legend name 1分
legend name 5分
legend name 15分
limit 20

image

完成

image

CPU

データソース設定

image

INFOMOTION設定

項目 設定する値
TYPE metricsgraphics
DATASOURCE server1/cpus
rows y_accessor user
rows y_accessor nice
rows y_accessor sys
rows y_accessor irq
rows y_accessor idle
legend name user
legend name nice
legend name sys
legend name irq
legend name idle
limit 20

image

完成

image

ディスク

データソース設定

image

INFOMOTION設定

項目 設定する値
TYPE metricsgraphics
DATASOURCE server1/drives
rows y_accessor size
rows y_accessor used
rows y_accessor available
legend name size
legend name used
legend name available
limit 20

image

完成

image

メモリ

データソース設定

image

INFOMOTION設定

項目 設定する値
TYPE metricsgraphics
DATASOURCE server1/memory
rows y_accessor totalmem
rows y_accessor freemem
rows y_accessor memusage
legend name totalmem
legend name freemem
legend name memusage
limit 20

image

完成

image

おまけ

ここまでやったらディスクI/OとネットワークI/Oも取得したいですが、環境によってコマンドが異なるようなメトリクスを取得する場合はnode-red-node-daemonを使って定期的に取得する方法が良さそうです。

こちらはまたの機会に。

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?