[Osaka/Yokohama] Looking for infrastructure/server side engineers!

[Osaka/Yokohama] Looking for infrastructure/server side engineers!

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Successor to CentOS] AlmaLinux OS server construction/migration service

[Successor to CentOS] AlmaLinux OS server construction/migration service

[For WordPress only] Cloud server “Web Speed”

[For WordPress only] Cloud server “Web Speed”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Reservation system development] EDISONE customization development service

[Reservation system development] EDISONE customization development service

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[Global exclusive service] Beyond's MSP in North America and China

[Global exclusive service] Beyond's MSP in North America and China

[YouTube] Beyond official channel “Biyomaru Channel”

[YouTube] Beyond official channel “Biyomaru Channel”

sysstatでサーバの各リソース状況を調査する

sysstatとは

Linux用サーバの負荷を分析するための監視ツールです。
CPU負荷、ディスクI/O使用率、メモリ使用状況、ネットワークデバイス状況を調査することができます。

sysstatパッケージには次のコマンドが含まれています。
sar・sadc・sadf・iostat・tapestat・cifsiostat・mpstat・pidstat

ではインストールしてみましょう。
次のコマンドを実行するとインストールできます。

# yum install sysstat
# rpm -qa | grep sysstat
sysstat-9.0.4-27.10.amzn1.x86_64

パッケージが表示されているので、インストールできています。
では実際に各コマンドを実行していきます。

sar

システムの稼働状況を確認できるコマンドです。

# sar [オプション] 取得間隔 取得回数

1回目はオプションなしで実行してみると、10分区切りで結果が表示されました。

2回目はiowait状況を10秒間×3回表示するよう実行しました。
1回目の実行結果とと同様に、最終行にコマンド実行時の平均値が表示されています。

他にも、オプションを指定することでCPULAの状況や、メモリ使用状況の確認なども可能です。

# CPULAの状況を確認する
 sar -q 
# メモリの使用状況を確認する
 sar -r

vmstat

メモリ・SWAP・ディスクI/O・CPU使用率を確認できるコマンドです。

# vmstat  [オプション]  取得間隔 取得回数

取得時間を表示する「-t」オプションをつけて、1秒間×3回のリソース状況を表示しています。

mpstat

CPU利用状況を確認できるコマンドです。

# mpstat  [オプション]  取得間隔 取得回数

sarコマンドやtopコマンドと比べ、%irq(ハードウェア割込み)、%soft(ソフトウェア割込みのCPU)、%guest(仮想サーバ実行のCPU)等、それぞれのCPU処理時間の表示されています。

終わりに

サーバー上で何か不具合や障害が発生している時にはtopコマンドやpsコマンドを使っても
リソース状況を確認することができます。
ロードアベレージでサーバの負荷を確認する
サーバ負荷の原因を探る方法

平常時の負荷状況・長期的なリソース状況を知る場合は、Zabbixのような監視ツールが向いています。
ですが障害発生時の調査手段の一つとして今回sysstatをご紹介しました。

sysstatをインストールすれば今回紹介したものも含め、各コマンドを実行できます。
サーバに負荷をかけるコマンドとも併用してリソース状況を確認したり
オプションを組み合わせて色々と試してみてください。
ここまで読んで下さりありがとうございます。

この記事がお役に立てば【 いいね 】のご協力をお願いいたします!
1
読み込み中...
1 票, 平均: 1.00 / 11
3,309
X facebook はてなブックマーク pocket
[2024.6.30 CentOS support ended] CentOS server migration solution

[2024.6.30 CentOS support ended] CentOS server migration solution

[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

[Osaka/Yokohama] Actively recruiting infrastructure engineers and server side engineers!

[Osaka/Yokohama] Actively recruiting infrastructure engineers and server side engineers!

The person who wrote this article

About the author

Sakina Nakagawa

I joined the company in 2016 as a new graduate. Lately, I've been having fun learning the basics of servers.