2010年8月18日水曜日

Zabbixでfpingを使うときの注意点

Zabbixサーバの設定ファイルzabbix_server.confにはSourceIPというオプションがあり、これを設定しておくとエージェントやSNMP、シンプルチェックなどのポーリング監視の際に利用するソースIPを設定できるようになっています。

この設定を利用した場合、pingを利用した監視(icmppingやicmppingsec)の場合にはfpingの-Sオプションを利用するようになっています。ところが-SオプションはDebian/Ubuntuに含まれているfpingには存在するのですが、標準のfpingやFedoraに含まれるfpingパッケージ、FrdoraパッケージをRHEL/CentOS用にリビルドしたepelリポジトリのパッケージには存在していません。

そのため、SourceIPオプションを利用した場合はfpingの返り値が「3」(そんなオプションはない!というエラーメッセージのリターンコード)になってしまい、Zabbixの画面上では必ずping監視が失敗してしまいます。

  • Fedora(epelパッケージ)のfpingオプション
Usage: /usr/sbin/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 68)
   -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. /usr/sbin/fping -g 192.168.1.0 192.168.1.255 or /usr/sbin/fping -g 192.168.1.0/24)
   -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
   -t n       individual target initial timeout (in millisec) (default 500)
   -u         show targets that are unreachable
   -v         show version
   targets    list of targets to check (if no -f specified)
  • Ubuntuのfpingオプション
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 68)
   -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)
   -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
   -S addr    set source address
   -t n       individual target initial timeout (in millisec) (default 500)
   -T n       set select timeout (default 10)
   -u         show targets that are unreachable
   -v         show version
   targets    list of targets to check (if no -f specified)

また、監視対象ホストのIPアドレスがIPv4とIPv6混在の場合に、IPv6ホストへのPingが失敗する問題もあります。これも同様にDebianパッチで修正されていました。詳細はZABBIX-JPフォーラムへの投稿を参照してください。

ということで、Debianからパッチを持ってきてZABBIX-JP版のRPMに含めてリリースをするようにしました。

Fedoraには標準でZabbixパッケージが含まれているのですが、そのままインストールするとfpingは-Sオプションに対応していないので注意が必要です。

同様にDAGリポジトリなどで公開されているfpingパッケージを利用する場合でも、-Sオプションが利用できるパッチが適用されているかを確認してから使った方が良いです。

そもそも本家のfping自体、2002年からアップデートされていないんですね。利用ユーザもそれなりに多いだろうソフトウェアなのに、各ディストリビューションにはフォークに近いような形で含まれているのはオープンソースの考え方からすると残念な感じがします。

何か理由があるのかもしれませんが、本家にはパッチが反映されないんですかね。

参考情報: