Zabbixを利用するにあたり、高速pingツール「fping」をCentOSにインストールして触ってみました。fping では、テキストファイルに書き出しておいた複数のターゲットホストに対して、Pingパケットを一気に送信して、結果を取得する事が可能です。
fpingツールの経緯
fping 自体は昔から知っていましたが、今回インストールするにあたり、fpingについて調べてみると、特殊な経緯があるみたいです。
多くのパッチは増えていくけど、長い間メンテナンスがされておらず、現在のメンテナンス者があらたにメンテナンスを引き継いだみたいです。
引き続き、頑張ってほしいです。
インストール
rpmを取得し、rpmコマンドでインストールしました。バージョンは「3.4」です。
# wget http://pkgs.repoforge.org/fping/fping-3.4-1.el6.rf.x86_64.rpm # rpm -ivh fping-3.4-1.el6.rf.x86_64.rpm # which fping /usr/sbin/fping #
インストールは以上です。簡単ですね。
fpingの利用
fping は、通常のPingコマンドに比べて、機能は豊富だと思います。
中でも、対象アドレスをテキストファイルにまとめておくと、fpingで一気にチェックできる機能は素晴らしいと思います。
以下に実行例を記載しておきます。(※IPアドレスは実際の実行結果から変更しています。)
# cat host.txt 127.0.0.1 192.168.0.100 172.16.12.100 (←到達できないIPアドレスを書いておく) 192.168.0.200 # fping -f host.txt (←ファイルで指定する事によって一気に実行) 127.0.0.1 is alive 192.168.0.100 is alive 192.168.0.200 is alive 172.16.12.100 is unreachable # fping -s -f host.txt (←統計情報を最後に表示) 127.0.0.1 is alive 192.168.0.100 is alive 192.168.0.200 is alive 172.16.12.100 is unreachable 4 targets 3 alive 1 unreachable 0 unknown addresses 1 timeouts (waiting for response) 7 ICMP Echos sent 3 ICMP Echo Replies received 0 other ICMP received 0.05 ms (min round trip time) 0.30 ms (avg round trip time) 0.80 ms (max round trip time) 4.150 sec (elapsed real time) #
その他にも、使えるオプションがいくつかあります。オプション例は、以降に載せておきます。
ネットワーク調査やアセスメント作業などで重宝しそうなツールです。
補足:fpingオプション例
# fping -help Usage: fping [options] [targets...] -a show targets that are alive -A show targets by address -b n amount of ping data to send, in bytes (default 56) -B f set exponential backoff factor to f -c n count of pings to send to each target (default 1) -C n same as -c, report results in verbose format -e show elapsed time on return packets -f file read list of targets from a file ( - means stdin) (only if no -g specified) -g generate target list (only if no -f specified) (specify the start and end IP in the target list, or supply a IP netmask) (ex. fping -g 192.168.1.0 192.168.1.255 or fping -g 192.168.1.0/24) -H n Set the IP TTL value (Time To Live hops) -i n interval between sending ping packets (in millisec) (default 25) -l loop sending pings forever -m ping multiple interfaces on target host -n show targets by name (-d is equivalent) -p n interval between ping packets to one target (in millisec) (in looping and counting modes, default 1000) -q quiet (don't show per-target/per-ping results) -Q n same as -q, but show summary every n seconds -r n number of retries (default 3) -s print final stats -I if bind to a particular interface -S addr set source address -t n individual target initial timeout (in millisec) (default 500) -T n ignored (for compatibility with fping 2.4) -u show targets that are unreachable -O n set the type of service (tos) flag on the ICMP packets -v show version targets list of targets to check (if no -f specified) #