1
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 3 years have passed since last update.

mackerel で特定プロセスのメモリ使用率やCPU使用量を監視

Posted at

はじめに

mackerel でサーバ監視をするときに、特定プロセスのメモリ使用率やCPU使用率を監視したいんだけど、デフォルトのものになさそうなので探してみた

モジュール

ググったら出てきました
さすがです、先人の人が作ってくれていました
https://tkuchiki.hatenablog.com/entry/2016/03/25/154617

モジュールのダウンロード
https://github.com/tkuchiki/mackerel-plugin-linux-proc-stats/releases

使い方

上記のREADMEに書いている通りですが、以下の通りで実行できます。
プロセスパターンとかも利用できますが、PIDを指定するのが楽なので、これでいいです。
「-follow-child-processes」をつけると子プロセスまでも含めて計測してくれます。

/usr/bin/mackerel-plugin-linux-proc-stats  -pidfile <PIDファイル> -follow-child-processes

または

/usr/bin/mackerel-plugin-linux-proc-stats  -pid <PID> -follow-child-processes

mackerel で監視

簡単です。「使い方」で書いたコマンドを設定ファイル(mackerel-agent.conf)に追記して再起動するだけです

mackerel agent の設定

/etc/mackerel-agent/mackerel-agent.conf に以下の設定を

[plugin.metrics.linux_proc_stats]
command = "/usr/bin/mackerel-plugin-linux-proc-stats  -pidfile <PIDファイル> -follow-child-processes"

mackerel agent の再起動

# systemctl restart mackerel-agent

確認

カスタムメトリクスのところに以下のように出てくる
表は上から以下の通りになってます。

  • CPU使用率
  • メモリ使用量
  • プロセス数

image.png

1
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
1
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?