入出力の速度を計測するpipemeterを使ってみる

はじめに

Linuxでファイル転送やデータ処理の速度を知りたい場合がある。
特に、大容量ファイルのコピーやバックアップ処理で、実際にどの程度の速度でデータが流れているかを監視したいことがある。

今回は、pipemeterというツールを使ってパイプ処理の入出力速度を計測してみる。
pipemeterは、パイプラインの途中でデータの転送速度をリアルタイムで表示してくれるツールである。

環境

Windows 11 Professional
WSL2 (Ubuntu 24.04.2 LTS)
pipemeter v1.1.5

pipemeterとは

pipemeterは、パイプライン内を流れるデータの転送速度を測定・表示するツール。
パイプの途中に挟み込むことで、データの流量をリアルタイムでモニタリングできる。

pipemeterの特徴

  • パイプラインを中断せずに、データが流れる速度を測定できる
  • 転送中の速度をリアルタイムで確認できる
  • 設定ファイルなどは不要で、インストール後すぐに使える
  • システムへの負荷が軽く、大容量ファイルの転送にも影響しにくい

測定できる指標

指標説明
転送速度現在のデータ転送レート(MB/s等)
累積データ量これまでに転送されたデータの総量
経過時間転送開始からの経過時間
平均速度全体の平均転送速度

pipemeterのインストール

インストール

# パッケージマネージャーでインストール
sudo apt update
sudo apt install pipemeter
ログ
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 libdouble-conversion3 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
  libmd4c0 libnotify-bin libpcre2-16-0 libqt5core5t64 libqt5dbus5t64 libqt5gui5t64 libqt5network5t64
  libqt5qml5 libqt5qmlmodels5 libqt5quick5 libqt5svg5 libqt5waylandclient5 libqt5waylandcompositor5
  libqt5widgets5t64 libqt5x11extras5 libre2-10 libssl-dev libuv1-dev libxcb-damage0 libxcb-xinerama0
  libxcb-xinput0 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 qt5-gtk-platformtheme qttranslations5-l10n qtwayland5 xbitmaps
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
  pipemeter
0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
Need to get 10.8 kB of archives.
After this operation, 34.8 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu noble/universe amd64 pipemeter amd64 1.1.5-1.1 [10.8 kB]
Fetched 10.8 kB in 0s (31.0 kB/s)
Selecting previously unselected package pipemeter.
(Reading database ... 114620 files and directories currently installed.)
Preparing to unpack .../pipemeter_1.1.5-1.1_amd64.deb ...
Unpacking pipemeter (1.1.5-1.1) ...
Setting up pipemeter (1.1.5-1.1) ...
Processing triggers for man-db (2.12.0-4build2) ...

インストール確認

# バージョン確認
pipemeter --version

基本的な使い方

テスト用ファイルの作成

まず、速度測定用の大容量ファイルを作成する。

# 100MBのテストファイルを作成
dd if=/dev/zero of=largefile.dat bs=1M count=100

# 500MBのテストファイルを作成
dd if=/dev/zero of=largefile.dat bs=1M count=500

# ランダムデータの1GBファイルを作成(時間がかかる)
dd if=/dev/urandom of=largefile.dat bs=1M count=1024

# 既存ファイルのサイズ確認
ls -lh largefile.dat

シンプルな速度測定

# ファイルコピーの速度測定
cat largefile.dat | pipemeter > copy.dat

# 出力例
-1.00B/s  100.00M    8.00k   0:00:00

ddコマンドとの組み合わせ

# ディスク書き込み速度の測定
dd if=/dev/zero bs=1M count=1000 | pipemeter | dd of=/tmp/testfile bs=1M

# 出力例
1000+0 records in5M    8.00k   0:00:01
1000+0 records out
1048576000 bytes (1.0 GB, 1000 MiB) copied, 1.36327 s, 769 MB/s
 500.00M/s 1000.00M    8.00k   0:00:02
0+19987 records in
0+19987 records out
1048576000 bytes (1.0 GB, 1000 MiB) copied, 1.36239 s, 770 MB/s

ネットワーク転送の測定

# SSH経由でのファイル転送速度
cat bigfile.tar.gz | pipemeter | ssh user@remote 'cat > /tmp/bigfile.tar.gz'

詳細なオプション

主要オプション一覧

オプション説明
-s, --size size入力サイズを指定し、プログレスバーを有効化
-b, --blocksize block_sizeブロックサイズをバイト単位で指定(デフォルト8192)
-m, --maxblock max_block_size適応ブロックサイズの最大値を指定(デフォルト8M)
-i, --interval interval更新間隔を秒単位で指定
-f, --file infile標準入力の代わりにファイルを指定
-F, --list listfile入力ファイルリストを記載したファイルを指定
-r, --reportレポートのみモード(実行中の出力を抑制)
-a, --autooff適応ブロックサイズを無効化
-l, --logログモード(改行のみ、復帰なし)
-V, --versionバージョン情報を表示

更新間隔の調整

# 2秒間隔で統計表示
cat largefile.dat | pipemeter -i 2 > output.dat

# 出力例
-1.00B/s  100.00M    8.00k   0:00:00

ブロックサイズの指定

# 64KBブロックで転送
cat file.dat | pipemeter -b 65536 > destination.dat

# 大きなブロック(1MB)で高速転送
cat file.dat | pipemeter -b 1M > destination.dat

# 最大ブロックサイズを16MBに設定
cat file.dat | pipemeter -m 16M > destination.dat

プログレスバー表示

# 総サイズを指定してプログレスバー表示
# (事前にファイルサイズを調べる必要がある)
FILESIZE=$(stat -c%s largefile.dat)
cat largefile.dat | pipemeter -s $FILESIZE > copy.dat

# または直接ファイルを指定(サイズ自動検出)
pipemeter -f largefile.dat > copy.dat

# 出力例(プログレスバー付き)
 450.00M/s  100.00M  ████████████████████████████████  100%  0:00:01

レポートモード

# 実行中の表示を抑制し、最終結果のみ表示
cat largefile.dat | pipemeter -r > copy.dat

# 出力例(完了時のみ)
 100.00M/s  100.00M    8.00k   0:00:01

複数ファイルの処理

# 複数ファイルを順次処理
pipemeter -f file1.dat -f file2.dat -f file3.dat > combined.dat

# ファイルリストから一括処理
echo "file1.dat" > filelist.txt
echo "file2.dat" >> filelist.txt
echo "file3.dat" >> filelist.txt
pipemeter -F filelist.txt > combined.dat

他のツールとの比較

pvコマンドとの比較

# pv(Pipe Viewer)
cat file.dat | pv > output.dat

# pipemeter
cat file.dat | pipemeter > output.dat
機能pipemeterpv
速度表示
進捗バー
ETA表示
軽量性

ddコマンドとの比較

# dd with status=progress
dd if=file.dat of=output.dat bs=1M status=progress

# pipemeter
dd if=file.dat bs=1M | pipemeter | dd of=output.dat bs=1M
機能pipemeterdd status=progress
パイプライン
リアルタイム
標準搭載

参考

おわりに

今回は、pipemeterを使った入出力速度の計測について学んだ。

特に、大容量ファイルの転送やバックアップ処理で、現在の進捗状況を把握したい場面で重宝する。
pvコマンドと比べるとシンプルだが、基本的な速度測定には十分な機能はあると思う。

実務でも速度測定したいときは使ってみる。

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