4
2

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.

[Linux]sarコマンド以外でメモリおよびCPU使用量をモニタリングする方法

Last updated at Posted at 2016-01-18

sarコマンドが実行できない(sysstatが未インストール)LinuxサーバーのメモリおよびCPU使用量を一定間隔で計測し、その結果をファイル出力する必要があったため、以下のコマンドを実行

####要件

  • メモリおよびCPU使用量を一定間隔で計測し、ファイルにリダイレクトしたい
  • tailコマンドを実行して、ファイルに出力された内容を表示したい

####実行するコマンド

  • vmstatコマンドのオプションで、実行間隔と回数を指定する
  • パイプに続けてawkで実行日時を表示する
  • 「system("")」で出力バッファをフラッシュする
(例)vmstatを5秒間隔で100回実行する際に、日時を表示する
vmstat 5 100 | awk '{print strftime("%Y-%m-%d %T"), $0; system("");}' > vmstat_out.txt 
4
2
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
4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?