テスト自動化のためのパッケージキャプチャを行うための信頼できるソリューションを探しています。
現在、tcpdumpは次のコマンドで使用されています。
sudo tcpdump -i ens160 -w filename.pcap -G 60 -W 1
私はtcpdumpを次のように停止します:
kill -s SIGINT <pid>
20回に1回、tcpdumpが正しく終了せず、pcapファイルが破損します。
tcpdumpが正しく終了することを確認する方法はありますか?
切り捨てられたダンプファイルを回避するには、次の2つの方法があります。
Doug Smythiesが提案しているように、プロセスを強制終了するSIGTERM
代わりに、終了シグナル()を使用SIGINT
しtcpdump
ます。
kill <pid>
教えてtcpdump
各パケットは(オプションを保存すると、ファイルに直接パケットを書き込むこと-U
)。このように、SIGINTを使用しても、ファイルは切り捨てられません。man tcpdumpから:
-U --packet-buffered If the -w option is not specified, make the printed packet output ``packet-buffered''; i.e., as the description of the contents of each packet is printed, it will be written to the standard output, rather than, when not writing to a ter‐ minal, being written only when the output buffer fills. If the -w option is specified, make the saved raw packet output ``packet-buffered''; i.e., as each packet is saved, it will be written to the output file, rather than being written only when the output buffer fills. The -U flag will not be supported if tcpdump was built with an older version of libpcap that lacks the pcap_dump_flush() function.
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加