9
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

はじめに

本番サーバーでの調査は

  • 早さ
  • 正確さ
  • 安全性

のバランスです。

手が滑ると

  • ログを消す
  • プロセスを落とす
  • ファイルを上書きする

といった二次災害になります。

この記事は
本番を壊さずに状況を掴むための「安全な確認コマンド」チェックリストを
用途別にまとめます。

大原則

  • まず読み取り専用で観測する
  • 対象を絞る(時間、パス、ユーザー、PID)
  • コマンドと結果をメモに残す

すぐ使えるチェックリスト

プロセスを確認

  • ps aux | head
  • top または htop
  • pgrep -fl <name>

見るポイント

  • CPUとメモリの上位
  • 想定外に増えているプロセス

ディスクを確認

  • df -h
  • du -sh * | sort -h | tail

注意

  • du は重いことがあるので、対象ディレクトリを絞る

ネットワークを確認

  • ss -tulpn
  • curl -I <url>

見るポイント

  • LISTENしているポート
  • TIME_WAIT が増えていないか

ログを安全に見る

  • tail -n 200 <file>
  • tail -f <file>
  • grep -n "error" <file> | head

注意

  • sed -i で直接編集しない
  • ログのローテーション設定を勝手に触らない

やってはいけないこと

  • rm -rf を本番で打つ
  • kill -9 を最初の一手にする
  • > file の上書きリダイレクト

まとめ

本番調査は、壊さずに観測するのが最初の勝ち筋です。
チェックリストを持っておくと
焦っているときでも安全に切り分けが進みます。

9
1
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
9
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?