Add ioping plugin (#5725)

* Add ioping plugin

* Update the documentation and comments

* Finalize installation of ioping

* Fix find_processors variable

* Fix static build

* Move ioping to libexec directory

* Move ioping to plugins.d directory

* Fix file existence check
This commit is contained in:
Vladimir Kobal 2019-04-23 14:20:00 +03:00 committed by GitHub
parent 1d1b46695a
commit f0bc01ddbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 461 additions and 46 deletions

1
.gitignore vendored
View File

@ -112,6 +112,7 @@ collectors/charts.d.plugin/charts.d.plugin
collectors/node.d.plugin/node.d.plugin
collectors/python.d.plugin/python.d.plugin
collectors/fping.plugin/fping.plugin
collectors/ioping.plugin/ioping.plugin
collectors/go.d.plugin
# installer generated files

View File

@ -346,6 +346,7 @@ Its [Plugin API](collectors/plugins.d/) supports all programing languages (anyth
- **[Veritas Volume Manager](collectors/proc.plugin/)** - naming disks.
- **[megacli](collectors/python.d.plugin/megacli/)** - adapter, physical drives and battery stats.
- **[adaptec_raid](collectors/python.d.plugin/adaptec_raid/)** - logical and physical devices health metrics.
- **[ioping](collectors/ioping.plugin/)** - to measure disk read/write latency.
#### Filesystems
- **[BTRFS](collectors/proc.plugin/)** - detailed disk space allocation and usage.

View File

@ -2,6 +2,7 @@
if sed \
-e 's#[@]localstatedir_POST@#$(localstatedir)#g' \
-e 's#[@]sbindir_POST@#$(sbindir)#g' \
-e 's#[@]pluginsdir_POST@#$(pluginsdir)#g' \
-e 's#[@]configdir_POST@#$(configdir)#g' \
-e 's#[@]libconfigdir_POST@#$(libconfigdir)#g' \
-e 's#[@]cachedir_POST@#$(cachedir)#g' \

View File

@ -11,6 +11,7 @@ SUBDIRS = \
cups.plugin \
diskspace.plugin \
fping.plugin \
ioping.plugin \
freebsd.plugin \
freeipmi.plugin \
idlejitter.plugin \

View File

@ -30,6 +30,7 @@ plugin|lang|O/S|runs as|modular|description
[cups.plugin](cups.plugin/)|`C`|any|external|-|monitors **CUPS**
[diskspace.plugin](diskspace.plugin/)|`C`|linux|internal|-|collects disk space usage metrics on Linux mount points
[fping.plugin](fping.plugin/)|`C`|any|external|-|measures network latency, jitter and packet loss between the monitored node and any number of remote network end points.
[ioping.plugin](ioping.plugin/)|`C`|any|external|-|measures disk read/write latency.
[freebsd.plugin](freebsd.plugin/)|`C`|freebsd|internal|yes|collects resource usage and performance data on FreeBSD systems
[freeipmi.plugin](freeipmi.plugin/)|`C`|linux, freebsd|external|-|collects metrics from enterprise hardware sensors, on Linux and FreeBSD servers.
[idlejitter.plugin](idlejitter.plugin/)|`C`|any|internal|-|measures CPU latency and jitter on all operating systems

View File

@ -82,6 +82,7 @@ node.d.plugin: *node.d.plugin*
python.d.plugin: *python.d.plugin*
tc-qos-helper: *tc-qos-helper.sh*
fping: fping
ioping: ioping
go.d.plugin: *go.d.plugin*
# -----------------------------------------------------------------------------

View File

@ -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)

View File

@ -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)]()

View File

@ -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"

View File

@ -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 $?)."

View File

@ -11,6 +11,7 @@ plugin|language|O/S|description
[charts.d.plugin](../charts.d.plugin/)|`BASH`|all|a **plugin orchestrator** for data collection modules written in `BASH` v4+.
[cups.plugin](../cups.plugin/)|`C`|all|monitors **CUPS**
[fping.plugin](../fping.plugin/)|`C`|all|measures network latency, jitter and packet loss between the monitored node and any number of remote network end points.
[ioping.plugin](../ioping.plugin/)|`C`|all|measures disk latency.
[freeipmi.plugin](../freeipmi.plugin/)|`C`|linux|collects metrics from enterprise hardware sensors, on Linux servers.
[nfacct.plugin](../nfacct.plugin/)|`C`|linux|collects netfilter firewall, connection tracker and accounting metrics using `libmnl` and `libnetfilter_acct`.
[xenstat.plugin](../xenstat.plugin/)|`C`|linux|collects XenServer and XCP-ng metrics using `lxenstat`.
@ -64,6 +65,7 @@ Example:
# charts.d = yes
# fping = yes
# ioping = yes
# node.d = yes
# python.d = yes
```

View File

@ -692,6 +692,7 @@ AC_CONFIG_FILES([
collectors/checks.plugin/Makefile
collectors/diskspace.plugin/Makefile
collectors/fping.plugin/Makefile
collectors/ioping.plugin/Makefile
collectors/freebsd.plugin/Makefile
collectors/freeipmi.plugin/Makefile
collectors/cups.plugin/Makefile

View File

@ -65,6 +65,7 @@ To control which plugins netdata run, edit `netdata.conf` and check the `[plugin
# node.d = yes
# python.d = yes
# fping = yes
# ioping = yes
# charts.d = yes
# apps = yes
# xenstat = yes
@ -94,7 +95,7 @@ sudo su -s /bin/bash netdata
```
Similarly, you can use `charts.d.plugin` for BASH plugins and `node.d.plugin` for node.js plugins.
Other plugins (like `apps.plugin`, `freeipmi.plugin`, `fping.plugin`) use the native netdata plugin API and can be run directly.
Other plugins (like `apps.plugin`, `freeipmi.plugin`, `fping.plugin`, `ioping.plugin`) use the native netdata plugin API and can be run directly.
If you need to configure a netdata plugin or module, all user supplied configuration is kept at `/etc/netdata` while the stock versions of all files is at `/usr/lib/netdata/conf.d`.
To copy a stock file and edit it, run `/etc/netdata/edit-config`. Running this command without an argument, will list the available stock files.
@ -113,6 +114,7 @@ plugin | language | plugin<br/>configuration | modules<br/>configuration |
`charts.d.plugin`<br/>(external plugin orchestrator for BASH modules)|`BASH`|`charts.d.conf`|a file for each module in `/etc/netdata/charts.d/`
`diskspace.plugin`<br/>(internal plugin for collecting Linux mount points usage)|`C`|`netdata.conf` section `[plugin:diskspace]`|N/A
`fping.plugin`<br/>(external plugin for collecting network latencies)|`C`|`fping.conf`|This plugin is a wrapper for the `fping` command.
`ioping.plugin`<br/>(external plugin for collecting disk latencies)|`C`|`ioping.conf`|This plugin is a wrapper for the `ioping` command.
`freeipmi.plugin`<br/>(external plugin for collecting IPMI h/w sensors)|`C`|`netdata.conf` section `[plugin:freeipmi]`
`idlejitter.plugin`<br/>(internal plugin for monitoring CPU jitter)|`C`|N/A|N/A
`macos.plugin`<br/>(internal plugin for monitoring MacOS system resources)|`C`|`netdata.conf` section `[plugin:macos]`|one section for each module `[plugin:macos:MODULE]`. Each module may provide additional sections in the form of `[plugin:macos:MODULE:SUBSECTION]`.
@ -318,6 +320,7 @@ xenstat|C|Collects host and domain statistics for XenServer or XCP-ng hypervisor
application|language|notes|
:---------:|:------:|:----|
apps|C|`apps.plugin` collects resource usage statistics for all processes running in the system. It groups the entire process tree and reports dozens of metrics for CPU utilization, memory footprint, disk I/O, swap memory, network connections, open files and sockets, etc. It reports metrics for application groups, users and user groups.<br/>&nbsp;<br/>[Documentation of `apps.plugin`](../collectors/apps.plugin/).<br/>&nbsp;<br/>netdata plugin: [`apps_plugin.c`](../collectors/apps.plugin)<br/>configuration file: [`apps_groups.conf`](../collectors/apps.plugin)|
ioping|C|Charts disk latency statistics for a directory/file/device, using the `ioping` command. A recent (probably unreleased) version of ioping is required. The plugin supplied can install it in `/usr/local`.<br/>&nbsp;<br/>netdata plugin: [ioping.plugin](../collectors/ioping.plugin) (this is a shell wrapper to start ioping - once ioping is started, netdata and ioping communicate directly - it can also install the right version of ioping)<br/>configuration file: [ioping.conf](../collectors/ioping.plugin)|
cpu_apps|BASH<br/>Shell Script|Collects the CPU utilization of select apps.<br/><br/>DEPRECATED IN FAVOR OF `apps.plugin`. It is still supplied only as an example module to shell scripting plugins.<br/>&nbsp;<br/>netdata plugin: [charts.d.plugin](../collectors/charts.d.plugin#chartsdplugin)<br/>plugin module: [cpu_apps.chart.sh](../collectors/charts.d.plugin/cpu_apps)<br/>configuration file: [charts.d/cpu_apps.conf](../collectors/charts.d.plugin/cpu_apps)|
load_average|BASH<br/>Shell Script|Collects the current system load average.<br/><br/>DEPRECATED IN FAVOR OF THE NETDATA INTERNAL ONE. It is still supplied only as an example module to shell scripting plugins.<br/>&nbsp;<br/>netdata plugin: [charts.d.plugin](../collectors/charts.d.plugin#chartsdplugin)<br/>plugin module: [load_average.chart.sh](../collectors/charts.d.plugin/load_average)<br/>configuration file: [charts.d/load_average.conf](../collectors/charts.d.plugin/load_average)|
mem_apps|BASH<br/>Shell Script|Collects the memory footprint of select applications.<br/><br/>DEPRECATED IN FAVOR OF `apps.plugin`. It is still supplied only as an example module to shell scripting plugins.<br/>&nbsp;<br/>netdata plugin: [charts.d.plugin](../collectors/charts.d.plugin#chartsdplugin)<br/>plugin module: [mem_apps.chart.sh](../collectors/charts.d.plugin/mem_apps)<br/>configuration file: [charts.d/mem_apps.conf](../collectors/charts.d.plugin/mem_apps)|

View File

@ -224,6 +224,7 @@ echo -ne " - BASH:
navpart 3 collectors/apps.plugin
navpart 3 collectors/cups.plugin
navpart 3 collectors/fping.plugin
navpart 3 collectors/ioping.plugin
navpart 3 collectors/freeipmi.plugin
navpart 3 collectors/nfacct.plugin
navpart 3 collectors/xenstat.plugin

View File

@ -39,6 +39,7 @@ dist_healthconfig_DATA = \
health.d/elasticsearch.conf \
health.d/entropy.conf \
health.d/fping.conf \
health.d/ioping.conf \
health.d/fronius.conf \
health.d/haproxy.conf \
health.d/httpcheck.conf \

View File

@ -0,0 +1,13 @@
template: disk_latency
families: *
on: ioping.latency
lookup: average -10s unaligned of average
units: ms
every: 10s
green: 500
red: 1000
warn: $this > $green OR $max > $red
crit: $this > $red
info: average round trip delay during the last 10 seconds
delay: down 30m multiplier 1.5 max 2h
to: sysadmin

View File

@ -718,6 +718,11 @@ if [ "${UID}" -eq 0 ]; then
run chmod 4750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/xenstat.plugin"
fi
if [ -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/ioping" ]; then
run chown root:${NETDATA_GROUP} "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/ioping"
run chmod 4750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/ioping"
fi
if [ -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/cgroup-network" ]; then
run chown "root:${NETDATA_GROUP}" "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/cgroup-network"
run chmod 4750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/cgroup-network"
@ -989,6 +994,7 @@ NETDATA_PREFIX="${NETDATA_PREFIX}"
NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS}"
NETDATA_ADDED_TO_GROUPS="${NETDATA_ADDED_TO_GROUPS}"
INSTALL_UID="${UID}"
NETDATA_GROUP="${NETDATA_GROUP}"
REINSTALL_COMMAND="${REINSTALL_COMMAND}"
RELEASE_CHANNEL="${RELEASE_CHANNEL}"
# This value is meant to be populated by autoupdater (if enabled)

View File

@ -195,7 +195,7 @@ run chown -R ${NETDATA_USER}:${NETDATA_GROUP} /opt/netdata
progress "fix plugin permissions"
for x in apps.plugin freeipmi.plugin cgroup-network
for x in apps.plugin freeipmi.plugin ioping cgroup-network
do
f="usr/libexec/netdata/plugins.d/${x}"

View File

@ -0,0 +1,18 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: GPL-3.0-or-later
. $(dirname "${0}")/../functions.sh "${@}" || exit 1
fetch "netdata-ioping-43d15a5" "https://github.com/netdata/ioping/tarball/master"
export CFLAGS="-static"
run make clean
run make -j$(find_processors)
run mkdir -p ${NETDATA_INSTALL_PATH}/usr/libexec/netdata/plugins.d/
run install -o root -g root -m 4750 ioping ${NETDATA_INSTALL_PATH}/usr/libexec/netdata/plugins.d/
if [ ${NETDATA_BUILD_WITH_DEBUG} -eq 0 ]
then
run strip ${NETDATA_INSTALL_PATH}/usr/libexec/netdata/plugins.d/ioping
fi

View File

@ -213,6 +213,12 @@ netdataDashboard.menu = {
info: 'Network latency statistics, via <b>fping</b>. <b>fping</b> is a program to send ICMP echo probes to network hosts, similar to <code>ping</code>, but much better performing when pinging multiple hosts. fping versions after 3.15 can be directly used as netdata plugins.'
},
'ioping': {
title: 'ioping',
icon: '<i class="fas fa-exchange-alt"></i>',
info: 'Disk latency statistics, via <b>ioping</b>. <b>ioping</b> is a program to read/write data probes from/to a disk.'
},
'httpcheck': {
title: 'Http Check',
icon: '<i class="fas fa-heartbeat"></i>',