diff options
Diffstat (limited to 'collectors/ioping.plugin')
-rw-r--r-- | collectors/ioping.plugin/Makefile.am | 24 | ||||
-rw-r--r-- | collectors/ioping.plugin/README.md | 82 | ||||
-rw-r--r-- | collectors/ioping.plugin/ioping.conf | 40 | ||||
-rwxr-xr-x | collectors/ioping.plugin/ioping.plugin.in | 212 |
4 files changed, 358 insertions, 0 deletions
diff --git a/collectors/ioping.plugin/Makefile.am b/collectors/ioping.plugin/Makefile.am new file mode 100644 index 000000000..7610b0e07 --- /dev/null +++ b/collectors/ioping.plugin/Makefile.am @@ -0,0 +1,24 @@ +# SPDX-License-Identifier: GPL-3.0-or-later + +AUTOMAKE_OPTIONS = subdir-objects +MAINTAINERCLEANFILES = $(srcdir)/Makefile.in + +CLEANFILES = \ + ioping.plugin \ + $(NULL) + +include $(top_srcdir)/build/subst.inc +SUFFIXES = .in + +dist_plugins_SCRIPTS = \ + ioping.plugin \ + $(NULL) + +dist_noinst_DATA = \ + ioping.plugin.in \ + README.md \ + $(NULL) + +dist_libconfig_DATA = \ + ioping.conf \ + $(NULL) diff --git a/collectors/ioping.plugin/README.md b/collectors/ioping.plugin/README.md new file mode 100644 index 000000000..15fdf6ff7 --- /dev/null +++ b/collectors/ioping.plugin/README.md @@ -0,0 +1,82 @@ +# ioping.plugin + +The ioping plugin supports monitoring latency for any number of directories/files/devices, +by pinging them with `ioping`. + +A recent version of `ioping` is required (one that supports option ` -N `). +The supplied plugin can install it, by running: + +```sh +/usr/libexec/netdata/plugins.d/ioping.plugin install +``` + +The `-e` option can be supplied to indicate where the netdata environment file is installed. The default path is `/etc/netdata/.environment`. + +The above will download, build and install the right version as `/usr/libexec/netdata/plugins.d/ioping`. + +Then you need to edit `/etc/netdata/ioping.conf` (to edit it on your system run +`/etc/netdata/edit-config ioping.conf`) like this: + +```sh +# uncomment the following line - it should already be there +ioping="/usr/libexec/netdata/plugins.d/ioping" + +# set here the directory/file/device, you need to ping +destination="destination" + +# override the chart update frequency - the default is inherited from netdata +update_every="1s" + +# the request size in bytes to ping the destination +request_size="4k" + +# other iping options - these are the defaults +ioping_opts="-T 1000000 -R" +``` + +## alarms + +netdata will automatically attach a few alarms for each host. +Check the [latest versions of the ioping alarms](../../health/health.d/ioping.conf) + +## Multiple ioping Plugins With Different Settings + +You may need to run multiple ioping plugins with different settings or different end points. +For example, you may need to ping one destination once per 10 seconds, and another once per second. + +netdata allows you to add as many `ioping` plugins as you like. + +Follow this procedure: + +**1. Create New ioping Configuration File** + + +```sh +# Step Into Configuration Directory +cd /etc/netdata + +# Copy Original ioping Configuration File To New Configuration File +cp ioping.conf ioping2.conf +``` + +Edit `ioping2.conf` and set the settings and the destination you need for the seconds instance. + +**2. Soft Link Original ioping Plugin to New Plugin File** + +```sh +# Become root (If The Step Step Is Performed As Non-Root User) +sudo su + +# Step Into The Plugins Directory +cd /usr/libexec/netdata/plugins.d + +# Link ioping.plugin to ioping2.plugin +ln -s ioping.plugin ioping2.plugin +``` + +That's it. netdata will detect the new plugin and start it. + +You can name the new plugin any name you like. +Just make sure the plugin and the configuration file have the same name. + +[![analytics](https://www.google-analytics.com/collect?v=1&aip=1&t=pageview&_s=1&ds=github&dr=https%3A%2F%2Fgithub.com%2Fnetdata%2Fnetdata&dl=https%3A%2F%2Fmy-netdata.io%2Fgithub%2Fcollectors%2Fioping.plugin%2FREADME&_u=MAC~&cid=5792dfd7-8dc4-476b-af31-da2fdb9f93d2&tid=UA-64295674-3)]() diff --git a/collectors/ioping.plugin/ioping.conf b/collectors/ioping.plugin/ioping.conf new file mode 100644 index 000000000..86f0de7f4 --- /dev/null +++ b/collectors/ioping.plugin/ioping.conf @@ -0,0 +1,40 @@ +# no need for shebang - this file is sourced from ioping.plugin + +# ioping.plugin requires a recent version of ioping. +# +# You can get it on your system, by running: +# +# /usr/libexec/netdata/plugins.d/ioping.plugin install + +# ----------------------------------------------------------------------------- +# configuration options + +# The ioping binary to use. We need one that can output netdata friendly info +# (supporting: -N). If you have multiple versions, put here the full filename +# of the right one + +#ioping="/usr/libexec/netdata/plugins.d/ioping" + + +# The directory/file/device to ioping + +destination="" + + +# The update frequency of the chart in seconds (symbolic modifiers are supported) +# the default is inherited from netdata + +#update_every="1s" + + +# The request size in bytes to ioping the destination (symbolic modifiers are supported) +# by default 4k chunks are used + +#request_size="4k" + + +# Other ioping options +# the defaults: +# -T 1000000 = maximum valid request time (us) + +#ioping_opts="-T 1000000" diff --git a/collectors/ioping.plugin/ioping.plugin.in b/collectors/ioping.plugin/ioping.plugin.in new file mode 100755 index 000000000..9f9babd89 --- /dev/null +++ b/collectors/ioping.plugin/ioping.plugin.in @@ -0,0 +1,212 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: GPL-3.0-or-later + +# netdata +# real-time performance and health monitoring, done right! +# (C) 2017 Costa Tsaousis <costa@tsaousis.gr> +# GPL v3+ +# +# This plugin requires a latest version of ioping. +# You can compile it from source, by running me with option: install + +export PATH="${PATH}:/sbin:/usr/sbin:/usr/local/sbin" +export LC_ALL=C + +usage="$(basename "$0") [install] [-h] [-e] + +where: + install install ioping binary + -e, --env path to environment file (defauls to '/etc/netdata/.environment' + -h show this help text" + +INSTALL=0 +ENVIRONMENT_FILE="/etc/netdata/.environment" + +while :; do + case "$1" in + -h | --help) + echo "$usage" >&2 + exit 1 + ;; + install) + INSTALL=1 + shift + ;; + -e | --env) + ENVIRONMENT_FILE="$2" + shift 2 + ;; + -*) + echo "$usage" >&2 + exit 1 + ;; + *) break ;; + esac +done + +if [ "$INSTALL" == "1" ] + then + [ "${UID}" != 0 ] && echo >&2 "Please run me as root. This will install a single binary file: /usr/libexec/netdata/plugins.d/ioping." && exit 1 + + source "${ENVIRONMENT_FILE}" || exit 1 + + run() { + printf >&2 " > " + printf >&2 "%q " "${@}" + printf >&2 "\n" + "${@}" || exit 1 + } + + download() { + local git="$(which git 2>/dev/null || command -v git 2>/dev/null)" + [ ! -z "${git}" ] && run git clone "${1}" "${2}" && return 0 + + echo >&2 "Cannot find 'git' in this system." && exit 1 + } + + tmp=$(mktemp -d /tmp/netdata-ioping-XXXXXX) + [ ! -d "${NETDATA_PREFIX}/usr/libexec/netdata" ] && run mkdir -p "${NETDATA_PREFIX}/usr/libexec/netdata" + + run cd "${tmp}" + + if [ -d ioping-netdata ] + then + run rm -rf ioping-netdata || exit 1 + fi + + download 'https://github.com/netdata/ioping.git' 'ioping-netdata' + [ $? -ne 0 ] && exit 1 + run cd ioping-netdata || exit 1 + + INSTALL_PATH="${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/ioping" + + run make clean + run make + run mv ioping "${INSTALL_PATH}" + run chown root:"${NETDATA_GROUP}" "${INSTALL_PATH}" + run chmod 4750 "${INSTALL_PATH}" + echo >&2 + echo >&2 "All done, you have a compatible ioping now at ${INSTALL_PATH}." + echo >&2 + + exit 0 +fi + +# ----------------------------------------------------------------------------- + +PROGRAM_NAME="$(basename "${0}")" + +logdate() { + date "+%Y-%m-%d %H:%M:%S" +} + +log() { + local status="${1}" + shift + + echo >&2 "$(logdate): ${PROGRAM_NAME}: ${status}: ${*}" + +} + +warning() { + log WARNING "${@}" +} + +error() { + log ERROR "${@}" +} + +info() { + log INFO "${@}" +} + +fatal() { + log FATAL "${@}" + echo "DISABLE" + exit 1 +} + +debug=0 +debug() { + [ $debug -eq 1 ] && log DEBUG "${@}" +} + +# ----------------------------------------------------------------------------- + +# store in ${plugin} the name we run under +# this allows us to copy/link ioping.plugin under a different name +# to have multiple ioping plugins running with different settings +plugin="${PROGRAM_NAME/.plugin/}" + + +# ----------------------------------------------------------------------------- + +# the frequency to send info to netdata +# passed by netdata as the first parameter +update_every="${1-1}" + +# the netdata configuration directory +# passed by netdata as an environment variable +[ -z "${NETDATA_USER_CONFIG_DIR}" ] && NETDATA_USER_CONFIG_DIR="@configdir_POST@" +[ -z "${NETDATA_STOCK_CONFIG_DIR}" ] && NETDATA_STOCK_CONFIG_DIR="@libconfigdir_POST@" + +# the netdata directory for internal binaries +[ -z "${NETDATA_PLUGINS_DIR}" ] && NETDATA_PLUGINS_DIR="@pluginsdir_POST@" + +# ----------------------------------------------------------------------------- +# configuration options +# can be overwritten at /etc/netdata/ioping.conf + +# the ioping binary to use +# we need one that can output netdata friendly info (supporting: -N) +# if you have multiple versions, put here the full filename of the right one +ioping="${NETDATA_PLUGINS_DIR}/ioping" + +# the destination to ioping +destination="" + +# the request size in bytes to ping the disk +request_size="4k" + +# ioping options +ioping_opts="-T 1000000" + +# ----------------------------------------------------------------------------- +# load the configuration files + +for CONFIG in "${NETDATA_STOCK_CONFIG_DIR}/${plugin}.conf" "${NETDATA_USER_CONFIG_DIR}/${plugin}.conf" +do + if [ -f "${CONFIG}" ] + then + info "Loading config file '${CONFIG}'..." + source "${CONFIG}" + [ $? -ne 0 ] && error "Failed to load config file '${CONFIG}'." + else + warning "Cannot find file '${CONFIG}'." + fi +done + +if [ -z "${destination}" ] +then + fatal "destination is not configured - nothing to do." +fi + +if [ ! -f "${ioping}" ] +then + fatal "ioping command is not found. Please set its full path in '${NETDATA_USER_CONFIG_DIR}/${plugin}.conf'" +fi + +if [ ! -x "${ioping}" ] +then + fatal "ioping command '${ioping}' is not executable - cannot proceed." +fi + +# the ioping options we will use +options=( -N -i ${update_every} -s ${request_size} ${ioping_opts} ${destination} ) + +# execute ioping +info "starting ioping: ${ioping} ${options[*]}" +exec "${ioping}" "${options[@]}" + +# if we cannot execute ioping, stop +fatal "command '${ioping} ${options[*]}' failed to be executed (returned code $?)." |