LoginSignup
0
1

More than 1 year has passed since last update.

netstatコマンドでApache Web Serverの接続数を確認する方法(メモ)

Last updated at Posted at 2022-10-01

netstatコマンドで、Apache Web Serverの接続数を確認することができます。

以下のコマンドは、クライアントからHTTPS接続(443ポート)で、Apache Web Server(IPアドレス:192.168.0.10)への接続をカウントしています。

  • Apacheへの接続情報を表示するコマンド
netstat -antp | grep '192.168.0.10:443 '
  • Apacheへの接続数を状態ごとにカウントして表示するコマンド
netstat -antp | grep '192.168.0.10:443 ' | awk '{print $6}' | sort | uniq -c
  • Apacheへの接続数を状態ごとにカウントして表示するコマンド(5秒ごとに時間付きでファイルに出力)
nohup bash -c "while true; do netstat -antp | grep '192.168.0.10:443 ' | awk '{print \$6}' | sort | uniq -c | awk '{print strftime(\"%y/%m/%d %H:%M:%S\"), \$0}'; sleep 5;done" < /dev/null > out_$(date "+%Y%m%d_%H%M%S").log 2>&1 &
  • Apacheへの接続数を接続元のIPアドレスごとにカウントして表示するコマンド
netstat -antp | grep '192.168.0.10:443 ' | awk '{print $5}' | cut -d : -f1 | sort -n | uniq -c | sort -n
  • Apacheへの接続数を接続元のIPアドレスごとにカウントして表示するコマンド(5秒ごとに時間付きでファイルに出力)
nohup bash -c "while true; do netstat -antp | grep '192.168.0.10:443 ' | awk '{print \$5}' | cut -d : -f1 | sort -n | uniq -c | sort -n | awk '{print strftime(\"%y/%m/%d %H:%M:%S\"), \$0}'; sleep 5;done" < /dev/null > out_$(date "+%Y%m%d_%H%M%S").log 2>&1 &

以上

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