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

リソースモニター(sysstat, sar)

Last updated at Posted at 2025-06-21

sarを使ってリソース状況を確認する。
参考にさせていただいたページ

レポートを作成する

sar

collectorが作成したファイルからレポート

$ sar [ -f ファイル ] OPT 

いまから、インターバル×回数 測定して、ファイルへ出力

$ sar [ -o ファイル ] OPT インターバル 回数
$ sar [ -f ファイル ] OPT 

sarのオプション、表示項目

オプション 用法
== CPU ==
-u CPU %user %nice %system %iowait %steal %idle
-u ALL + %irq %soft %guest %gnice %idle
-q LOAD runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15 blocked
-w Task creation and Context switching
proc/s cswch/s
-I ALL INTR intr/s
== IO ==
-b IOと転送レート
tps rtps wtps dtps bread/s bwrtn/s bdscd/s
-d BLOCKデバイス毎の情報
DEV tps rkB/s wkB/s dkB/s areq-sz aqu-sz await %util
== NW ==
-n ALL
-n DEV
NW Statistics
IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s %ifutil
-n NFS
NFS client
call/s retrans/s read/s write/s access/s getatt/s
-n NFSD
NFS server
scall/s badcall/s packet/s udp/s tcp/s hit/s miss/s sread/s swrite/s saccess/s sgetatt/s
== Memory ==
-r kbmemfree kbavail kbmemused %memused kbbuffers kbcached kbcommit %commit kbactive kbinact kbdirty
-r ALL + kbdirty kbanonpg kbslab kbkstack kbpgtbl kbvmused
-S Swap Statistics
kbswpfree kbswpused %swpused kbswpcad %swpcad
-W Swapping Statistics
pswpin/s pswpout/s
-B Paging Statistics
pgpgin/s pgpgout/s fault/s majflt/s pgfree/s pgscank/s pgscand/s pgsteal/s %vmeff

sarのオプション、時刻ほか

用途 オプション 併用オプション
時刻範囲 -s 18:00:00 -e 18:10:00
Interface --iface=eth0,br-a91c3bb56c36 -n DEV
Device --dev=sda -b, -d
CPU -P 0,1
-P ALL
-u

準備(debianの場合)

インストール

# apt install sysstat

sysstatの有効化

systemd-timerで動かす場合は不要かもしれないが、修正した

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

# 有効化
# ENABLED="false"
ENABLED="true"

ログの保存日数、collectorのオプション、ログの出力先ディレクトリ

/etc/sysstat/sysstat
# ログの保存日数
# HISTORY=7
HISTORY=35

# 取得情報の設定
# SADC_OPTIONS="-S DISK"
SADC_OPTIONS="-S DISK -S INT"

# ログ出力先
# SA_DIR=/var/log/sysstat
SA_DIR=/mnt/usbhdd/sysstat-log

systemd,systemd-timerの設定

  • /usr/lib/systemd/system/sysstat.service : デフォルトのまま
  • /usr/lib/systemd/system/sysstat-collect.service : デフォルトのまま
  • /usr/lib/systemd/system/sysstat-summary.service : デフォルトのまま
  • /usr/lib/systemd/system/sysstat-collect.timer : 測定間隔の設定
    10分間隔(デフォ)を2分間隔に変更する例
sysstat-collect.timer
[Timer]
# OnCalendar=*:00/10
OnCalendar=*:00/2
  • /usr/lib/systemd/system/sysstat-summary.timer : レポート作成の時刻設定
sysstat-summary.timer
[Timer]
OnCalendar=00:07:00

systemdの再起動

# systemctl daemon-reload
# systemctl enable sysstat
# systemctl start sysstat

起動時間の確認

# systemctl list-timers
0
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
0
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?