tcpflowを使ってパケット監視
何かトラブルが起こったとき、アプリケーションのログを見るよりもパケット直接見た方が早いってばあちゃんが言ってた。
参考:http://www.slideshare.net/takafumionaka/ss-5852561
とあるアプリの開発運用(トラブルシュート)
Debian環境で使う。
まずはインストール
sudo aptitude install tcpflow
tcpflowのヘルプを見る。
usage: tcpflow [-chpsv] [-b max_bytes] [-d debug_level] [-f max_fds] [-i iface] [-w file] [expression] -b: max number of bytes per flow to save -c: console print only (don't create files) -C: console print only, but without the display of source/dest header -d: debug level; default is 1 -e: output each flow in alternating colors -f: maximum number of file descriptors to use -h: print this help message -i: network interface on which to listen (type "ifconfig -a" for a list of interfaces) -p: don't use promiscuous mode -r: read packets from tcpdump output file -s: strip non-printable characters (change to '.') -v: verbose operation equivalent to -d 10 expression: tcpdump-like filtering expression
- c を忘れると大変なことになるので忘れないといいと思います。
監視するネットワークアダプタを探す。
ifconfig -a
で、監視
sudo tcpflow -c port 80 -i lo
80番ポートでアクセスするとログが流れるので、監視成功する。