LoginSignup
3
0

【小ネタ】sarコマンド入力後に出る「Cannot open /var/log/sysstat/saXX: No such file or directory Please check if data collecting is enabled」の解決策

Posted at

事象

sysstatパッケージは既にインストール済みで、実行環境はUbuntu 22.04です。
sarコマンドでシステムの負荷状況を取ってみたかったのですが、取得できず。。。
実行結果は以下の通りです。

$ sar -r 2
Cannot open /var/log/sysstat/sa19: No such file or directory
Please check if data collecting is enabled

原因

sysstatのインストール後、データ収集を有効化していないのが原因でした。
/etc/default/sysstatENABLED="false"ENABLED="true"にすればOKです。

$ cat /etc/default/sysstat
#
# Default settings for /etc/init.d/sysstat, /etc/cron.d/sysstat
# and /etc/cron.daily/sysstat files
#

# Should sadc collect system activity informations? Valid values
# are "true" and "false". Please do not put other values, they
# will be overwritten by debconf!
## 編集前
## ENABLED="false"
## 編集後
ENABLED="true"

manコマンドのユーザマニュアルには出てこなかったので、一次情報に当たりました。下記のURLをご参照ください。

編集後、無事にメモリとスワップ関連の情報を取得できました。

$ sar -r 2
Linux 5.15.90.1-microsoft-standard-WSL2 (XXXXXXXXXX)     08/19/23        _x86_64_        (8 CPU)

16:39:47    kbmemfree   kbavail kbmemused  %memused kbbuffers  kbcached  kbcommit   %commit  kbactive   kbinact   kbdirty
16:39:49      3561608   6306896   1353720     16.94     51208   2869228   4130348     40.93    932480   3019192        16
16:39:51      3561108   6306396   1354216     16.94     51208   2869228   4130348     40.93    932480   3019556        16
16:39:53      3561108   6306396   1354208     16.94     51208   2869228   4130348     40.93    932480   3019284        16
^C
Average:      3561275   6306563   1354048     16.94     51208   2869228   4130348     40.93    932480   3019344        16

以上、備忘録でした!

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