2
0

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.

glances 使い方をまとめる

Posted at

glancesの使い方をまとめておく。
細かい情報は、https://glances.readthedocs.io/en/stable/index.html
がマニュアル。

使おうと思った背景

  • unix系サーバで性能情報取る、ってなったときのファーストチョイスは、sarとかiostatとかそのへんのコマンドだと思うのですが、
    これらのコマンドは、CPU取る、とかディスク取る、とか複数のリソースを一気に取れない。
  • 視覚的な情報じゃない。視覚的な情報にするなら、HPのglanceplusとか・・・
  • windows入ってくると、(もちろん)同じ情報取れない。

インストール

pip install glances
pip install bottle  # Webモード使いたい場合

使い方(とりあえず向け)

モードがいくつかある。

  • standaloneモード
    その名のとおり、インストールサーバだけで動かすもの。
    引数なしで動かすと、GUI(ライク)で動く。
    引数つけると、CSVで取得したりできる。
glances  # GUI
glances --stdout-csv now,cpu.user,mem.used,load  # csvで取得
  • Client/Serverモード
    その名のとおり、クラサバで動かすもの。XML-RPCで接続するみたい。
    他サーバのリソースみたい!というときに使う。
glances -s  # サーバ側
glances -c @IPアドレス  # クライアント側
  • Web Serverモード
    その名のとおり、webサーバとして情報を公開するもの。
glances -w  # サーバ側

これで、ブラウザで開くと見れるらしいのだが、私の環境では、
UnicodeEncodeError: 'latin-1' codec can't encode character '\u65e5' in position 78: ordinal not in range(256)
が出力され、うまく見れなかった。
でも、REST-APIだと普通に見えるので、これはこれで使える。

自分的には、standaloneモードか、Web Serverモードが使えるかな〜と。

  • 普段、cronとかで、csvで情報取得しとく
  • 性能試験とかだと、GUIで見る
  • RESTあると、全台一気に取得とか加工できて、いい感じ

GUIモード

フィルターの仕方とか、とりあえず「h」でヘルプ見ればよい。ヘルプが親切。
Enterキーで、プロセス名フィルターかけれる。

  • 「c」 -> CPU使用率でフィルター
  • 「m」 -> MEM使用率でフィルター
  • 「i」 -> DISK I/Oでフィルター

ぐらいわかっとけばよさそう。

コマンドラインオプション

使いそうなのは、

glances --stdout PLUGINS_STATS

PLUGINは
["alert", "amps", "batpercent", "cloud", "core", "cpu", "diskio", "docker", "folders", "fs", "gpu", "help", "ip", "irq", "load", "mem", "memswap", "network", "now", "percpu", "ports", "processcount", "processlist", "psutilversion", "quicklook", "raid", "sensors", "system", "uptime", "wifi"]
があるみたい。

API

いろいろあるみたいだけど、基本形として、以下をおさえとけばよさそう。

http://サーバ名:61208/api/3/プラグイン名
http://サーバ名:61208/api/3/pluginslist  # 全プラグイン
http://サーバ名:61208/api/3/プラグイン名/アイテム名
http://サーバ名:61208/api/3/プラグイン名/アイテム名/アイテムの値

便利だ!

2
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?