はじめに
Linuxシステムのパフォーマンス監視において、様々なツールが存在するが、CPU、メモリ、ディスク、ネットワークなど複数の指標を監視したい場面がある。collectl
は、オールインワンのパフォーマンス監視ツールであるとのことなので使ってみる。
環境
Windows 11 Professional
Ubuntu 24.04 LTS
collectl 4.3.1
collectlとは
collectlは、Linux向けの包括的なパフォーマンス監視ツールである。 従来のtop、vmstat、iostat、netstatなどの機能を統合し、リアルタイム監視からログ記録まで幅広く対応している。
主な特徴
- 多様なサブシステム監視が可能(CPU、メモリ、ディスク、ネットワーク、プロセス、スラブ、ソケットなど)
- 柔軟な出力形式を提供(brief、verbose、detailの3つのフォーマット)
- リアルタイム監視とログ記録の両方に対応(インタラクティブ表示とデーモンモード)
- プラグイン機能でデータ送信が可能(Ganglia、Graphiteなど)
インストール
Ubuntuでは標準リポジトリからインストール可能である。
sudo apt update
sudo apt install collectl
ログ
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 additional packages will be installed:
aglfn apache2 apache2-bin apache2-data apache2-utils colplot gnuplot gnuplot-data gnuplot-qt libapr1t64
libaprutil1-dbd-sqlite3 libaprutil1-ldap libaprutil1t64 libgetopt-simple-perl libpcre2-32-0
libqt5printsupport5t64 libwxbase3.2-1t64 libwxgtk3.2-1t64 pciutils perl-tk ssl-cert
Suggested packages:
apache2-doc apache2-suexec-pristine | apache2-suexec-custom www-browser ufw gnuplot-doc
The following NEW packages will be installed:
aglfn apache2 apache2-bin apache2-data apache2-utils collectl colplot gnuplot gnuplot-data gnuplot-qt
libapr1t64 libaprutil1-dbd-sqlite3 libaprutil1-ldap libaprutil1t64 libgetopt-simple-perl libpcre2-32-0
libqt5printsupport5t64 libwxbase3.2-1t64 libwxgtk3.2-1t64 pciutils perl-tk ssl-cert
0 upgraded, 22 newly installed, 0 to remove and 8 not upgraded.
Need to get 11.9 MB of archives.
After this operation, 44.1 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 libapr1t64 amd64 1.7.2-3.1ubuntu0.1 [108 kB]
Get:2 http://archive.ubuntu.com/ubuntu noble/main amd64 libaprutil1t64 amd64 1.6.3-1.1ubuntu7 [91.9 kB]
Get:3 http://archive.ubuntu.com/ubuntu noble/main amd64 libaprutil1-dbd-sqlite3 amd64 1.6.3-1.1ubuntu7 [11.2 kB]
Get:4 http://archive.ubuntu.com/ubuntu noble/main amd64 libaprutil1-ldap amd64 1.6.3-1.1ubuntu7 [9116 B]
Get:5 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 apache2-bin amd64 2.4.58-1ubuntu8.8 [1331 kB]
Get:6 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 apache2-data all 2.4.58-1ubuntu8.8 [163 kB]
Get:7 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 apache2-utils amd64 2.4.58-1ubuntu8.8 [97.7 kB]
Get:8 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 apache2 amd64 2.4.58-1ubuntu8.8 [90.2 kB]
Get:9 http://archive.ubuntu.com/ubuntu noble/main amd64 pciutils amd64 1:3.10.0-2build1 [69.7 kB]
Get:10 http://archive.ubuntu.com/ubuntu noble/universe amd64 collectl all 4.3.1-1 [512 kB]
Get:11 http://archive.ubuntu.com/ubuntu noble/universe amd64 perl-tk amd64 1:804.036+dfsg1-1ubuntu3 [2047 kB]
Get:12 http://archive.ubuntu.com/ubuntu noble/universe amd64 libgetopt-simple-perl all 1.52-7 [10.3 kB]
Get:13 http://archive.ubuntu.com/ubuntu noble/universe amd64 aglfn all 1.7+git20191031.4036a9c-2 [30.6 kB]
Get:14 http://archive.ubuntu.com/ubuntu noble/universe amd64 gnuplot-data all 6.0.0+dfsg1-1ubuntu3 [75.3 kB]
Get:15 http://archive.ubuntu.com/ubuntu noble/universe amd64 libqt5printsupport5t64 amd64 5.15.13+dfsg-1ubuntu1 [208 kB]
Get:16 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 libpcre2-32-0 amd64 10.42-4ubuntu2.1 [197 kB]
Get:17 http://archive.ubuntu.com/ubuntu noble/universe amd64 libwxbase3.2-1t64 amd64 3.2.4+dfsg-4build1 [899 kB]
Get:18 http://archive.ubuntu.com/ubuntu noble/universe amd64 libwxgtk3.2-1t64 amd64 3.2.4+dfsg-4build1 [4535 kB]
Get:19 http://archive.ubuntu.com/ubuntu noble/universe amd64 gnuplot-qt amd64 6.0.0+dfsg1-1ubuntu3 [1237 kB]
Get:20 http://archive.ubuntu.com/ubuntu noble/universe amd64 gnuplot all 6.0.0+dfsg1-1ubuntu3 [3568 B]
Get:21 http://archive.ubuntu.com/ubuntu noble/universe amd64 colplot all 5.2.0-1.3 [147 kB]
Get:22 http://archive.ubuntu.com/ubuntu noble/main amd64 ssl-cert all 1.1.2ubuntu1 [17.8 kB]
Fetched 11.9 MB in 4s (3170 kB/s)
Preconfiguring packages ...
Selecting previously unselected package libapr1t64:amd64.
(Reading database ... 114856 files and directories currently installed.)
Preparing to unpack .../00-libapr1t64_1.7.2-3.1ubuntu0.1_amd64.deb ...
Unpacking libapr1t64:amd64 (1.7.2-3.1ubuntu0.1) ...
Selecting previously unselected package libaprutil1t64:amd64.
Preparing to unpack .../01-libaprutil1t64_1.6.3-1.1ubuntu7_amd64.deb ...
Unpacking libaprutil1t64:amd64 (1.6.3-1.1ubuntu7) ...
Selecting previously unselected package libaprutil1-dbd-sqlite3:amd64.
Preparing to unpack .../02-libaprutil1-dbd-sqlite3_1.6.3-1.1ubuntu7_amd64.deb ...
Unpacking libaprutil1-dbd-sqlite3:amd64 (1.6.3-1.1ubuntu7) ...
Selecting previously unselected package libaprutil1-ldap:amd64.
Preparing to unpack .../03-libaprutil1-ldap_1.6.3-1.1ubuntu7_amd64.deb ...
Unpacking libaprutil1-ldap:amd64 (1.6.3-1.1ubuntu7) ...
Selecting previously unselected package apache2-bin.
Preparing to unpack .../04-apache2-bin_2.4.58-1ubuntu8.8_amd64.deb ...
Unpacking apache2-bin (2.4.58-1ubuntu8.8) ...
Selecting previously unselected package apache2-data.
Preparing to unpack .../05-apache2-data_2.4.58-1ubuntu8.8_all.deb ...
Unpacking apache2-data (2.4.58-1ubuntu8.8) ...
Selecting previously unselected package apache2-utils.
Preparing to unpack .../06-apache2-utils_2.4.58-1ubuntu8.8_amd64.deb ...
Unpacking apache2-utils (2.4.58-1ubuntu8.8) ...
Selecting previously unselected package apache2.
Preparing to unpack .../07-apache2_2.4.58-1ubuntu8.8_amd64.deb ...
Unpacking apache2 (2.4.58-1ubuntu8.8) ...
Selecting previously unselected package pciutils.
Preparing to unpack .../08-pciutils_1%3a3.10.0-2build1_amd64.deb ...
Unpacking pciutils (1:3.10.0-2build1) ...
Selecting previously unselected package collectl.
Preparing to unpack .../09-collectl_4.3.1-1_all.deb ...
Unpacking collectl (4.3.1-1) ...
Selecting previously unselected package perl-tk.
Preparing to unpack .../10-perl-tk_1%3a804.036+dfsg1-1ubuntu3_amd64.deb ...
Unpacking perl-tk (1:804.036+dfsg1-1ubuntu3) ...
Selecting previously unselected package libgetopt-simple-perl.
Preparing to unpack .../11-libgetopt-simple-perl_1.52-7_all.deb ...
Unpacking libgetopt-simple-perl (1.52-7) ...
Selecting previously unselected package aglfn.
Preparing to unpack .../12-aglfn_1.7+git20191031.4036a9c-2_all.deb ...
Unpacking aglfn (1.7+git20191031.4036a9c-2) ...
Selecting previously unselected package gnuplot-data.
Preparing to unpack .../13-gnuplot-data_6.0.0+dfsg1-1ubuntu3_all.deb ...
Unpacking gnuplot-data (6.0.0+dfsg1-1ubuntu3) ...
Selecting previously unselected package libqt5printsupport5t64:amd64.
Preparing to unpack .../14-libqt5printsupport5t64_5.15.13+dfsg-1ubuntu1_amd64.deb ...
Unpacking libqt5printsupport5t64:amd64 (5.15.13+dfsg-1ubuntu1) ...
Selecting previously unselected package libpcre2-32-0:amd64.
Preparing to unpack .../15-libpcre2-32-0_10.42-4ubuntu2.1_amd64.deb ...
Unpacking libpcre2-32-0:amd64 (10.42-4ubuntu2.1) ...
Selecting previously unselected package libwxbase3.2-1t64:amd64.
Preparing to unpack .../16-libwxbase3.2-1t64_3.2.4+dfsg-4build1_amd64.deb ...
Unpacking libwxbase3.2-1t64:amd64 (3.2.4+dfsg-4build1) ...
Selecting previously unselected package libwxgtk3.2-1t64:amd64.
Preparing to unpack .../17-libwxgtk3.2-1t64_3.2.4+dfsg-4build1_amd64.deb ...
Unpacking libwxgtk3.2-1t64:amd64 (3.2.4+dfsg-4build1) ...
Selecting previously unselected package gnuplot-qt.
Preparing to unpack .../18-gnuplot-qt_6.0.0+dfsg1-1ubuntu3_amd64.deb ...
Unpacking gnuplot-qt (6.0.0+dfsg1-1ubuntu3) ...
Selecting previously unselected package gnuplot.
Preparing to unpack .../19-gnuplot_6.0.0+dfsg1-1ubuntu3_all.deb ...
Unpacking gnuplot (6.0.0+dfsg1-1ubuntu3) ...
Selecting previously unselected package colplot.
Preparing to unpack .../20-colplot_5.2.0-1.3_all.deb ...
Unpacking colplot (5.2.0-1.3) ...
Selecting previously unselected package ssl-cert.
Preparing to unpack .../21-ssl-cert_1.1.2ubuntu1_all.deb ...
Unpacking ssl-cert (1.1.2ubuntu1) ...
Setting up perl-tk (1:804.036+dfsg1-1ubuntu3) ...
Setting up libgetopt-simple-perl (1.52-7) ...
Setting up libpcre2-32-0:amd64 (10.42-4ubuntu2.1) ...
Setting up ssl-cert (1.1.2ubuntu1) ...
Created symlink /etc/systemd/system/multi-user.target.wants/ssl-cert.service → /usr/lib/systemd/system/ssl-cert.service.
Setting up aglfn (1.7+git20191031.4036a9c-2) ...
Setting up pciutils (1:3.10.0-2build1) ...
Setting up collectl (4.3.1-1) ...
Setting up libapr1t64:amd64 (1.7.2-3.1ubuntu0.1) ...
Setting up apache2-data (2.4.58-1ubuntu8.8) ...
Setting up libwxbase3.2-1t64:amd64 (3.2.4+dfsg-4build1) ...
Setting up libwxgtk3.2-1t64:amd64 (3.2.4+dfsg-4build1) ...
Setting up libqt5printsupport5t64:amd64 (5.15.13+dfsg-1ubuntu1) ...
Setting up gnuplot-data (6.0.0+dfsg1-1ubuntu3) ...
Setting up libaprutil1t64:amd64 (1.6.3-1.1ubuntu7) ...
Setting up libaprutil1-ldap:amd64 (1.6.3-1.1ubuntu7) ...
Setting up gnuplot-qt (6.0.0+dfsg1-1ubuntu3) ...
update-alternatives: using /usr/bin/gnuplot-qt to provide /usr/bin/gnuplot (gnuplot) in auto mode
Setting up libaprutil1-dbd-sqlite3:amd64 (1.6.3-1.1ubuntu7) ...
Setting up gnuplot (6.0.0+dfsg1-1ubuntu3) ...
Setting up apache2-utils (2.4.58-1ubuntu8.8) ...
Setting up apache2-bin (2.4.58-1ubuntu8.8) ...
Setting up colplot (5.2.0-1.3) ...
Apache2 not installed, skipping
Setting up apache2 (2.4.58-1ubuntu8.8) ...
Enabling module mpm_event.
Enabling module authz_core.
Enabling module authz_host.
Enabling module authn_core.
Enabling module auth_basic.
Enabling module access_compat.
Enabling module authn_file.
Enabling module authz_user.
Enabling module alias.
Enabling module dir.
Enabling module autoindex.
Enabling module env.
Enabling module mime.
Enabling module negotiation.
Enabling module setenvif.
Enabling module filter.
Enabling module deflate.
Enabling module status.
Enabling module reqtimeout.
Enabling conf charset.
Enabling conf localized-error-pages.
Enabling conf other-vhosts-access-log.
Enabling conf security.
Enabling conf serve-cgi-bin.
Enabling site 000-default.
Created symlink /etc/systemd/system/multi-user.target.wants/apache2.service → /usr/lib/systemd/system/apache2.service.
Created symlink /etc/systemd/system/multi-user.target.wants/apache-htcacheclean.service → /usr/lib/systemd/system/apache-htcacheclean.service.
Processing triggers for man-db (2.12.0-4build2) ...
Processing triggers for libc-bin (2.39-0ubuntu8.5) ...
依存関係として以下のパッケージが推奨される。
libio-compress-perl
: データ圧縮用pciutils
: ハードウェア情報取得用
コマンドオプション
collectlには多数のオプションが用意されているので表形式で記載する。
基本オプション
オプション | 説明 |
---|---|
-c, --count | 指定回数サンプルを収集して終了する |
-f, --filename | 出力先ディレクトリ/ファイル名を指定する |
-i, --interval | 収集間隔を秒単位で指定(デフォルト:1秒) |
-o, --options | 出力フォーマットのオプションを指定する |
-p, --playback | 記録ファイルからデータを再生する |
-P, --plot | プロット形式で出力を生成する |
-s, --subsys | 監視するサブシステムを指定(デフォルト:cdn) |
--verbose | 詳細形式で出力を表示する |
出力オプション(-o)
オプション | 説明 |
---|---|
d|D | 出力に日付を含める |
T | 出力に時刻を含める |
z | プロットファイルの圧縮を無効にする |
ヘルプオプション
オプション | 説明 |
---|---|
-h, --help | 基本ヘルプを表示する |
-v, --version | バージョン情報を表示する |
-V, --showdefs | 動作デフォルト値を表示する |
-x, --helpextend | 拡張ヘルプを表示する |
-X, --helpall | 全ヘルプを連結して表示する |
詳細表示オプション
オプション | 説明 |
---|---|
--showoptions | 全オプションを表示する |
--showsubsys | 全サブシステムを表示する |
--showsubopts | サブシステム固有オプションを表示する |
--showtopopts | –topオプションを表示する |
--showheader | 生成されるファイルヘッダーを表示する |
--showcolheaders | 生成される列ヘッダーを表示する |
--showslabaliases | SLUB allocatorの非rootエイリアスを表示する |
--showrootslabs | SLUB allocatorのrootエイリアスを表示する |
基本的な使い方
1. デフォルト表示
引数なしで実行すると、CPU、ディスク、ネットワークの基本情報が1行で表示される。
collectl
出力例
waiting for 1 second sample...
#<----CPU[HYPER]-----><----------Disks-----------><----------Network---------->
#cpu sys inter ctxsw KBRead Reads KBWrit Writes KBIn PktIn KBOut PktOut
0 0 1645 5727 0 0 76 14 0 1 0 0
0 0 2140 5821 80 2 7613 36 0 3 0 2
0 0 525 2923 0 0 0 0 0 1 0 0
0 0 1560 5186 0 0 0 0 0 0 0 0
0 0 591 2709 0 0 0 0 0 0 0 0
0 0 1556 5475 0 0 16 2 0 0 0 0
2. 監視対象の指定
-s
オプションで監視するサブシステムを指定する。
# CPUのみ監視
collectl -sc
# メモリのみ監視
collectl -sm
# CPU、メモリ、ディスクを監視
collectl -scmd
サブシステム識別子
識別子 | 監視対象 |
---|---|
c | CPU使用率 |
d | ディスクI/O |
m | メモリ使用量 |
n | ネットワーク |
j | 割り込み |
s | スワップ |
t | TCP統計 |
f | NFS |
Z | プロセス |
3. 出力フォーマットについて
brief形式(デフォルト)
collectl -sc
verbose形式
collectl -sc --verbose
出力例
# CPU[HYPER] SUMMARY (INTR, CTXSW & PROC /sec)
# User Nice Sys Wait IRQ Soft Steal Guest NiceG Idle CPUs Intr Ctxsw Proc RunQ Run Avg1 Avg5 Avg15 RunT BlkT
0 0 0 0 0 0 0 0 0 99 24 1034 3842 9 1568 0 0.24 0.20 0.18 0 0
0 0 0 0 0 0 0 0 0 99 24 915 3395 7 1568 0 0.24 0.20 0.18 0 0
0 0 0 0 0 0 0 0 0 99 24 1634 5679 9 1567 0 0.24 0.20 0.18 0 0
0 0 0 0 0 0 0 0 0 100 24 3667 12K 0 1567 0 0.24 0.20 0.18 0 0
0 0 0 0 0 0 0 0 0 99 24 596 3028 5 1570 1 0.22 0.19 0.18 1 0
0 0 0 0 0 0 0 0 0 99 24 1570 5045 10 1567 0 0.22 0.19 0.18 0 0
detail形式
collectl -sC
# SINGLE CPU[HYPER] STATISTICS
# Cpu User Nice Sys Wait IRQ Soft Steal Guest NiceG Idle
0 0 0 0 0 0 2 0 0 0 98
1 0 0 0 0 0 0 0 0 0 100
2 0 0 0 0 0 0 0 0 0 100
3 0 0 0 0 0 0 0 0 0 100
4 0 0 1 0 0 1 0 0 0 98
5 0 0 0 0 0 0 0 0 0 100
6 0 0 1 0 0 0 0 0 0 97
7 0 0 0 0 0 0 0 0 0 100
8 1 0 1 0 0 0 0 0 0 97
9 0 0 0 0 0 0 0 0 0 100
10 0 0 2 0 0 0 0 0 0 97
プロセス別やCPUコア別の詳細情報を表示する。
4. タイムスタンプの表示
-o
オプションでタイムスタンプを追加できる。
# 時刻表示
collectl -sc -oT
# ミリ秒付きの時刻表示
collectl -sc -oTm
waiting for 1 second sample...
# <----CPU[HYPER]----->
#Time cpu sys inter ctxsw
17:35:24 0 0 876 3108
17:35:25 0 0 1704 4608
17:35:26 0 0 818 3761
17:35:27 0 0 847 3356
17:35:28 0 0 917 3268
17:35:29 0 0 2062 6224
17:35:29 0 0 1929 5490
17:35:30 5 0 1500 3750
5. 監視間隔の設定
-i
オプションで監視間隔を指定する(デフォルト: 1秒)
# 5秒間隔
collectl -sc -i5
# 0.5秒間隔
collectl -sc -i0.5
使用例
システムの全体的な監視
# CPU、メモリ、ディスク、ネットワークを5秒間隔で監視
collectl -scmdn -i5 -oT
waiting for 5 second sample...
# <----CPU[HYPER]-----><-----------Memory-----------><----------Disks-----------><----------Network---------->
#Time cpu sys inter ctxsw Free Buff Cach Inac Slab Map KBRead Reads KBWrit Writes KBIn PktIn KBOut PktOut
17:37:13 0 0 1587 5081 24G 13M 1G 516M 558M 5G 0 0 3077 15 0 1 0 0
17:37:14 0 0 1600 4400 24G 13M 1G 516M 558M 5G 0 0 0 0 0 0 0 0
17:37:19 0 0 981 3306 24G 13M 1G 516M 558M 5G 0 0 1532 7 0 1 0 0
17:37:23 0 0 1343 4517 24G 13M 1G 516M 558M 5G 0 0 1542 10 0 0 0 0
17:37:24 0 0 1429 3429 24G 13M 1G 516M 558M 5G 0 0 0 0 0 0 0 0
プロセス監視
# 物理メモリ使用量順でプロセストップ10を表示
collectl -sZ -oT --top rss
# CPU使用量順でプロセストップ5を表示
collectl -sZ -oT --top cpu,5
割り込み監視
# 詳細な割り込み情報を表示
collectl -sJ -oTm
ログファイルへの記録
# データを1時間ごとのファイルに記録
collectl -scmdn -f /var/log/collectl/ -r01:00:00 -F0
# バックグラウンドで実行
collectl -scmdn -f /var/log/collectl/ -D
記録データの再生
# 記録されたデータを再生
collectl -p /var/log/collectl/[ファイル名].raw.gz
# 特定の時間範囲を再生
collectl -p /var/log/collectl/[ファイル名].raw.gz --from 09:00 --thru 17:00
トラブルシューティング
パフォーマンスの低下が見られる場合
# 高頻度監視時はCPUコア別詳細を確認
collectl -sC -i1 -oT
# ディスクI/O詳細を確認
collectl -sD -i1 -oT
# ネットワーク詳細を確認
collectl -sN -i1 -oT
メモリ不足の調査
# メモリ詳細とスラブ情報を表示
collectl -smY --verbose -oT
# プロセス別メモリ使用量を確認
collectl -sZ --top mem,20 -oT
参考
- collectl公式サイト
https://collectl.sourceforge.net/ - Ubuntu パッケージ情報
https://packages.ubuntu.com/noble/admin/collectl - collectl Tutorial
https://collectl.sourceforge.net/Tutorial.html - collectl Documentation
https://collectl.sourceforge.net/Documentation.html
おわりに
collectl
は多機能でありながら使いやすいパフォーマンス監視ツールである。
単発の調査から継続的な監視まで、様々な場面で活躍できそう。
特に複数の指標を同時に確認したい場合や、ログとして記録しておきたい場合には非常に便利。 一度使い方を覚えれば、従来のtopやvmstatの代わりとしても活躍の場がありそうだ…!