4 # real-time performance and health monitoring, done right!
5 # (C) 2016 Costa Tsaousis <costa@tsaousis.gr>
8 # This plugin requires a special version of fping.
9 # Get it from https://github.com/ktsaou/fping
10 # and build it, like this:
13 # git clone https://github.com/ktsaou/fping.git fping-netdata.git
14 # cd fping-netdata.git
16 # ./configure --prefix=/usr/local
18 # cp src/fping /usr/local/bin/
19 # chown root:root /usr/local/bin/fping
20 # chmod 4755 /usr/local/bin/fping
22 # Then, create /etc/netdata/fping.conf
23 # and set the configuration options given below
25 export PATH="${PATH}:/sbin:/usr/sbin:/usr/local/sbin"
28 # -----------------------------------------------------------------------------
30 PROGRAM_NAME="$(basename "${0}")"
33 date "+%Y-%m-%d %H:%M:%S"
40 echo >&2 "$(logdate): ${PROGRAM_NAME}: ${status}: ${*}"
64 [ $debug -eq 1 ] && log DEBUG "${@}"
67 # -----------------------------------------------------------------------------
69 # the frequency to send info to netdata
70 # passed by netdata as the first parameter
73 # the netdata configuration directory
74 # passed by netdata as an environment variable
75 NETDATA_CONFIG_DIR="${NETDATA_CONFIG_DIR-/etc/netdata}"
77 # -----------------------------------------------------------------------------
78 # configuration options
79 # can be overwritten at /etc/netdata/fping.conf
81 # the fping binary to use
82 # we need one that can output netdata friendly info
83 fping="$(which fping || command -v fping)"
85 # a space separated list of hosts to fping
88 # the time in milliseconds (1 sec = 1000 ms)
89 # to ping the hosts - by default 2 pings per iteration
90 ping_every="$((update_every * 1000 / 2))"
92 # how many retries to make if a host does not respond
95 # -----------------------------------------------------------------------------
96 # load the configuration file
98 if [ ! -f "${NETDATA_CONFIG_DIR}/fping.conf" ]
100 fatal "configuration file '${NETDATA_CONFIG_DIR}/fping.conf' not found - nothing to do."
103 source "${NETDATA_CONFIG_DIR}/fping.conf"
107 fatal "no hosts configued in '${NETDATA_CONFIG_DIR}/fping.conf' - nothing to do."
110 if [ -z "${fping}" -o ! -x "${fping}" ]
112 fatal "command '${fping}' is not executable - cannot proceed."
115 # the fping options we will use
116 options=( -N -l -R -Q ${update_every} -p ${ping_every} -r ${retries} ${hosts} )
119 exec "${fping}" "${options[@]}"
121 # if we cannot execute fping, stop
122 fatal "command '${fping} ${options[@]}' failed to be executed."