]> arthur.barton.de Git - netdata.git/blobdiff - plugins.d/fping.plugin
Merge pull request #1686 from ktsaou/master
[netdata.git] / plugins.d / fping.plugin
index 97bd9442979ac8607ab8ebf6a65f9f03a10b8591..d523f4474b52d01c008af15b015986b6395ec81b 100755 (executable)
@@ -27,13 +27,13 @@ if [ "${1}" = "install" ]
 
     run cd /usr/src
 
-    if [ -d fping.git ]
+    if [ -d fping-ktsaou.git ]
         then
-        run cd fping.git
+        run cd fping-ktsaou.git
         run git pull
     else
-        run git clone https://github.com/schweikert/fping.git fping.git
-        run cd fping.git
+        run git clone https://github.com/ktsaou/fping.git fping-ktsaou.git
+        run cd fping-ktsaou.git
     fi
 
     run ./autogen.sh
@@ -50,9 +50,18 @@ if [ "${1}" = "install" ]
     echo >&2
     echo >&2 "All done, you have a compatible fping now at /usr/local/bin/fping."
     echo >&2
-    echo >&2 "If you have another fping installed, please set:"
-    echo >&2 "  fping=\"/usr/local/bin/fping\""
-    echo >&2 "at /etc/netdata/fping.conf"
+
+    fping="$(which fping  2>/dev/null || command -v fping 2>/dev/null)"
+    if [ "${fping}" != "/usr/local/bin/fping" ]
+        then
+        echo >&2 "You have another fping installed at: ${fping}."
+        echo >&2 "Please set:"
+        echo >&2
+        echo >&2 "  fping=\"/usr/local/bin/fping\""
+        echo >&2
+        echo >&2 "at /etc/netdata/fping.conf"
+        echo >&2
+    fi
     exit 0
 fi
 
@@ -95,6 +104,14 @@ debug() {
     [ $debug -eq 1 ] && log DEBUG "${@}"
 }
 
+# -----------------------------------------------------------------------------
+
+# store in ${plugin} the name we run under
+# this allows us to copy/link fping.plugin under a different name
+# to have multiple fping plugins running with different settings
+plugin="${PROGRAM_NAME/.plugin/}"
+
+
 # -----------------------------------------------------------------------------
 
 # the frequency to send info to netdata
@@ -128,21 +145,21 @@ fping_opts="-R -b 56 -i 1 -r 0 -t 5000"
 # -----------------------------------------------------------------------------
 # load the configuration file
 
-if [ ! -f "${NETDATA_CONFIG_DIR}/fping.conf" ]
+if [ ! -f "${NETDATA_CONFIG_DIR}/${plugin}.conf" ]
 then
-       fatal "configuration file '${NETDATA_CONFIG_DIR}/fping.conf' not found - nothing to do."
+       fatal "configuration file '${NETDATA_CONFIG_DIR}/${plugin}.conf' not found - nothing to do."
 fi
 
-source "${NETDATA_CONFIG_DIR}/fping.conf"
+source "${NETDATA_CONFIG_DIR}/${plugin}.conf"
 
 if [ -z "${hosts}" ]
 then
-       fatal "no hosts configued in '${NETDATA_CONFIG_DIR}/fping.conf' - nothing to do."
+       fatal "no hosts configued in '${NETDATA_CONFIG_DIR}/${plugin}.conf' - nothing to do."
 fi
 
 if [ -z "${fping}" -o ! -x "${fping}" ]
 then
-       fatal "command '${fping}' is not executable - cannot proceed."
+       fatal "command '${fping}' is not found or is not executable - cannot proceed."
 fi
 
 if [ ${ping_every} -lt 20 ]
@@ -152,7 +169,7 @@ if [ ${ping_every} -lt 20 ]
 fi
 
 # the fping options we will use
-options=( -N -l -Q ${update_every} -p ${ping_every} ${other_opts} ${hosts} )
+options=( -N -l -Q ${update_every} -p ${ping_every} ${fping_opts} ${hosts} )
 
 # execute fping
 exec "${fping}" "${options[@]}"