itopで割り込み負荷をモニタリングする

はじめに

システムのパフォーマンスを監視する際、CPU使用率やメモリ使用量だけでなく、割り込み(interrupt)の発生状況も重要な指標となる。
特に、ネットワーク通信やディスクI/Oが頻繁に発生する環境では、割り込み処理がシステムのボトルネックになることがある。

itopは、topコマンドのように割り込みの発生状況をリアルタイムで監視できるシンプルなツールである。
今回は、itopを使って割り込み負荷を確認してみる。

環境

Ubuntu 24.04 LTS
itop 0.1-4.1

itopとは

itopは、Linuxシステムの割り込み(interrupt)負荷をtopコマンドのようにリアルタイムで監視するシンプルなツール。
/proc/interruptsを開いて監視し、各割り込みの発生頻度を表示する。

主な特徴

  • /proc/interruptsをtopライクな方法で監視
  • CPUコアごとの割り込み回数を表示
  • 使用中の割り込みだけでなく、すべての割り込みを表示可能
  • 指定回数だけ監視して終了するオプションあり
  • シンプルで軽量

インストール

sudo apt install itop
ログ
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
  crack-common gyp libcares2 libgl1-amber-dri libglapi-mesa libjs-async libjs-events libjs-inherits
  libjs-is-typedarray libjs-prettify libjs-regenerate libjs-source-map libjs-sprintf-js
  libjs-typedarray-to-buffer libllvm17t64 liblttng-ust-common1t64 liblttng-ust-ctl5t64 liblttng-ust1t64
  libnotify-bin libqt5x11extras5 libre2-10 libssl-dev libuv1-dev libxcb-damage0 mesa-utils-bin node-abbrev
  node-ampproject-remapping node-ansi-regex node-ansi-styles node-aproba node-are-we-there-yet node-arrify
  node-async node-async-each node-auto-bind node-babel-plugin-add-module-exports node-babel7-runtime
  node-balanced-match node-base64-js node-binary-extensions node-brace-expansion node-busboy
  node-camelcase node-caniuse-lite node-chownr node-chrome-trace-event node-ci-info node-cjs-module-lexer
  node-cli-boxes node-cli-cursor node-clone node-collection-visit node-color-convert node-color-name
  node-colors node-commander node-commondir node-concat-stream node-console-control-strings
  node-convert-source-map node-core-js node-core-js-pure node-core-util-is node-data-uri-to-buffer
  node-decompress-response node-deep-is node-defaults node-define-property node-delegates node-depd
  node-diff node-electron-to-chromium node-encoding node-end-of-stream node-err-code node-error-ex
  node-es-module-lexer node-escape-string-regexp node-eslint-utils node-eslint-visitor-keys node-esquery
  node-estraverse node-esutils node-events node-fancy-log node-fast-deep-equal node-fast-levenshtein
  node-fetch node-find-up node-flatted node-foreground-child node-fs-readdir-recursive
  node-fs-write-stream-atomic node-fs.realpath node-function-bind node-get-caller-file node-get-stream
  node-get-value node-glob node-globals node-got node-graceful-fs node-growl node-has-flag
  node-has-unicode node-has-value node-has-values node-hosted-git-info node-iconv-lite node-ieee754
  node-iferr node-imurmurhash node-indent-string node-inflight node-inherits node-ini node-interpret
  node-ip node-ip-regex node-is-arrayish node-is-binary-path node-is-buffer node-is-descriptor
  node-is-extglob node-is-path-cwd node-is-plain-obj node-is-plain-object node-is-stream
  node-is-typedarray node-is-windows node-isarray node-isexe node-isobject node-js-tokens node-json-buffer
  node-json-parse-better-errors node-json-schema node-json-schema-traverse node-json-stable-stringify
  node-jsonify node-jsonparse node-kind-of node-levn node-loader-runner node-locate-path
  node-lodash-packages node-lowercase-keys node-lru-cache node-map-visit node-memfs node-merge-stream
  node-mimic-response node-minimatch node-minimist node-minipass node-mute-stream node-n3 node-negotiator
  node-npm-run-path node-object-inspect node-object-visit node-once node-optimist node-optionator
  node-osenv node-p-cancelable node-p-limit node-p-locate node-p-map node-pascalcase node-path-dirname
  node-path-exists node-path-is-absolute node-path-is-inside node-path-type node-pify node-pkg-dir
  node-postcss-value-parser node-prelude-ls node-process-nextick-args node-promise-inflight
  node-promise-retry node-promzard node-prr node-pump node-punycode node-quick-lru node-randombytes
  node-read node-readable-stream node-rechoir node-regenerator-runtime node-regenerator-transform
  node-regexpp node-regjsgen node-repeat-string node-require-directory node-require-from-string
  node-resolve node-resolve-cwd node-resolve-from node-restore-cursor node-resumer node-retry
  node-run-queue node-safe-buffer node-serialize-javascript node-set-blocking node-set-immediate-shim
  node-shebang-command node-shebang-regex node-shell-quote node-signal-exit node-slash node-slice-ansi
  node-source-list-map node-source-map node-spdx-correct node-spdx-exceptions node-spdx-expression-parse
  node-spdx-license-ids node-sprintf-js node-ssri node-stack-utils node-string-decoder node-strip-bom
  node-supports-color node-tapable node-terser node-text-table node-through node-time-stamp
  node-to-fast-properties node-tslib node-type-check node-typedarray node-typedarray-to-buffer node-undici
  node-unicode-canonical-property-names-ecmascript node-unicode-match-property-value-ecmascript
  node-unicode-property-aliases-ecmascript node-unset-value node-uri-js node-util-deprecate node-uuid
  node-v8flags node-validate-npm-package-license node-wcwidth.js node-webpack-sources node-wordwrap
  node-wrappy node-write-file-atomic node-xtend node-y18n node-yallist node-yaml nodejs-doc xbitmaps
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
  itop
0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
Need to get 6770 B of archives.
After this operation, 29.7 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu noble/universe amd64 itop amd64 0.1-4.1 [6770 B]
Fetched 6770 B in 1s (8383 B/s)
Selecting previously unselected package itop.
(Reading database ... 116857 files and directories currently installed.)
Preparing to unpack .../itop_0.1-4.1_amd64.deb ...
Unpacking itop (0.1-4.1) ...
Setting up itop (0.1-4.1) ...
Processing triggers for man-db (2.12.0-4build2) ...

使い方

基本的な起動

itop

実行すると、/proc/interruptsの内容を監視し、以下のような形式で割り込み情報がリアルタイムで表示される。

INT                NAME          RATE             MAX
  0 [CPU2       CPU3   ]     0 Ints/s     (max:     0)
  8 [   0          0   ]     0 Ints/s     (max:     0)

オプション

オプション説明
-n <回数>指定した回数だけ監視して終了する
-a使用されていない割り込みも含めてすべて表示する

使用例:

# 10回監視して終了
itop -n 10

# すべての割り込みを表示
itop -a

# 5回監視、すべての割り込みを表示
itop -n 5 -a

表示内容の見方

項目説明
INT割り込み番号(IRQ番号)
NAME各CPUコアでの割り込み回数
RATE1秒あたりの割り込み発生頻度
MAX記録された最大割り込み発生頻度

キー操作

キー動作
q終了
r表示を更新

活用してみる

割り込み発生状況の確認

実際にitopを実行すると、各割り込み番号とCPUコアごとの割り込み回数が表示される。

INT                NAME          RATE             MAX
  0 [CPU0       CPU1   ]   120 Ints/s     (max:   150)
  8 [  15         18   ]    33 Ints/s     (max:    45)
 16 [1234       5678   ]  1500 Ints/s     (max:  2000)
  • INT 0: タイマー割り込み(システムクロック)
  • INT 8: RTC(リアルタイムクロック)
  • INT 16: ネットワークインターフェースなど

高負荷時の動作確認

ネットワーク通信やディスクI/Oが発生している状態でitopを実行すると、該当する割り込み番号のRATEが上昇する。

例えば、大量のファイルをダウンロードしている場合

INT                NAME          RATE             MAX
 16 [5000      10000   ] 15000 Ints/s     (max: 20000)

このように、ネットワーク関連の割り込みが急増していることが確認できる。

割り込みの偏りの確認

CPUコア間で割り込み回数に大きな差がある場合、割り込み処理が特定のコアに集中している可能性がある。

INT                NAME          RATE             MAX
 16 [   10      9990   ] 10000 Ints/s     (max: 12000)

この例では、CPU1に割り込みが集中しており、IRQアフィニティの設定を見直すことでパフォーマンスが改善する可能性がある。

注意点

  • itop/proc/interruptsの監視に特化したツールのため、CPU使用率やメモリ使用量などの総合的なシステム状態はtophtopで確認する必要がある
  • 割り込み頻度が高いからといって、必ずしも問題があるわけではない(高負荷環境では正常な状態)
  • 仮想環境では、ホストOSの割り込み処理の影響を受けるため、物理環境とは異なる結果になることがある
  • デフォルトでは使用中の割り込みのみ表示されるため、すべて確認したい場合は-aオプションを使用する

参考

おわりに

itop/proc/interruptsをtopライクに監視できるシンプルで軽量なツールだった。

特に、ネットワークやディスクI/Oが頻繁に発生する環境では、割り込み処理がパフォーマンスに影響を与えることがあるため、itopで定期的に確認することが有効だろうか。

-nオプションを使えば、一定時間だけ監視してログに記録するといった使い方もできる。

tophtopと組み合わせて使うことで、より詳細なシステムのパフォーマンス分析が可能と思われる。

Hugo で構築されています。
テーマ StackJimmy によって設計されています。