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 (supporting: -N)
83 # if you have multiple versions, put here the full filename of the right one
84 fping="$( which fping 2>/dev/null || command -v fping 2>/dev/null )"
86 # a space separated list of hosts to fping
87 # we suggest to put names here and the IPs of these names in /etc/hosts
90 # the time in milliseconds (1 sec = 1000 ms)
91 # to ping the hosts - by default 5 pings per host per iteration
92 ping_every="$((update_every * 1000 / 5))"
95 other_opts="-R -i 10 -r 0"
97 # -----------------------------------------------------------------------------
98 # load the configuration file
100 if [ ! -f "${NETDATA_CONFIG_DIR}/fping.conf" ]
102 fatal "configuration file '${NETDATA_CONFIG_DIR}/fping.conf' not found - nothing to do."
105 source "${NETDATA_CONFIG_DIR}/fping.conf"
109 fatal "no hosts configued in '${NETDATA_CONFIG_DIR}/fping.conf' - nothing to do."
112 if [ -z "${fping}" -o ! -x "${fping}" ]
114 fatal "command '${fping}' is not executable - cannot proceed."
117 if [ ${ping_every} -lt 20 ]
119 warning "ping every was set to ${ping_every} but 20 is the minimum for non-root users. Setting it to 20 ms."
123 # the fping options we will use
124 options=( -N -l -Q ${update_every} -p ${ping_every} ${other_opts} ${hosts} )
127 exec "${fping}" "${options[@]}"
129 # if we cannot execute fping, stop
130 fatal "command '${fping} ${options[@]}' failed to be executed."