diff options
Diffstat (limited to '')
-rw-r--r-- | collectors/ioping.plugin/integrations/ioping.md | 9 | ||||
-rwxr-xr-x | collectors/ioping.plugin/ioping.plugin.in | 120 |
2 files changed, 87 insertions, 42 deletions
diff --git a/collectors/ioping.plugin/integrations/ioping.md b/collectors/ioping.plugin/integrations/ioping.md index 4c16d2e3a..39a07ed62 100644 --- a/collectors/ioping.plugin/integrations/ioping.md +++ b/collectors/ioping.plugin/integrations/ioping.md @@ -4,6 +4,7 @@ meta_yaml: "https://github.com/netdata/netdata/edit/master/collectors/ioping.plu sidebar_label: "IOPing" learn_status: "Published" learn_rel_path: "Data Collection/Synthetic Checks" +most_popular: False message: "DO NOT EDIT THIS FILE DIRECTLY, IT IS GENERATED BY THE COLLECTOR'S metadata.yaml FILE" endmeta--> @@ -108,10 +109,10 @@ sudo ./edit-config ioping.conf | Name | Description | Default | Required | |:----|:-----------|:-------|:--------:| -| update_every | Data collection frequency. | 1s | False | -| destination | The directory/file/device to ioping. | | True | -| request_size | The request size in bytes to ioping the destination (symbolic modifiers are supported) | 4k | False | -| ioping_opts | Options passed to `ioping` commands. | -T 1000000 | False | +| update_every | Data collection frequency. | 1s | no | +| destination | The directory/file/device to ioping. | | yes | +| request_size | The request size in bytes to ioping the destination (symbolic modifiers are supported) | 4k | no | +| ioping_opts | Options passed to `ioping` commands. | -T 1000000 | no | </details> diff --git a/collectors/ioping.plugin/ioping.plugin.in b/collectors/ioping.plugin/ioping.plugin.in index d1283bad9..171e384db 100755 --- a/collectors/ioping.plugin/ioping.plugin.in +++ b/collectors/ioping.plugin/ioping.plugin.in @@ -9,7 +9,7 @@ # 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 PATH="${PATH}:/sbin:/usr/sbin:/usr/local/sbin:@sbindir_POST@" export LC_ALL=C usage="$(basename "$0") [install] [-h] [-e] @@ -93,60 +93,103 @@ if [ "$INSTALL" == "1" ] fi # ----------------------------------------------------------------------------- +# logging PROGRAM_NAME="$(basename "${0}")" -LOG_LEVEL_ERR=1 -LOG_LEVEL_WARN=2 -LOG_LEVEL_INFO=3 -LOG_LEVEL="$LOG_LEVEL_INFO" - -set_log_severity_level() { - case ${NETDATA_LOG_SEVERITY_LEVEL,,} in - "info") LOG_LEVEL="$LOG_LEVEL_INFO";; - "warn" | "warning") LOG_LEVEL="$LOG_LEVEL_WARN";; - "err" | "error") LOG_LEVEL="$LOG_LEVEL_ERR";; +# these should be the same with syslog() priorities +NDLP_EMERG=0 # system is unusable +NDLP_ALERT=1 # action must be taken immediately +NDLP_CRIT=2 # critical conditions +NDLP_ERR=3 # error conditions +NDLP_WARN=4 # warning conditions +NDLP_NOTICE=5 # normal but significant condition +NDLP_INFO=6 # informational +NDLP_DEBUG=7 # debug-level messages + +# the max (numerically) log level we will log +LOG_LEVEL=$NDLP_INFO + +set_log_min_priority() { + case "${NETDATA_LOG_LEVEL,,}" in + "emerg" | "emergency") + LOG_LEVEL=$NDLP_EMERG + ;; + + "alert") + LOG_LEVEL=$NDLP_ALERT + ;; + + "crit" | "critical") + LOG_LEVEL=$NDLP_CRIT + ;; + + "err" | "error") + LOG_LEVEL=$NDLP_ERR + ;; + + "warn" | "warning") + LOG_LEVEL=$NDLP_WARN + ;; + + "notice") + LOG_LEVEL=$NDLP_NOTICE + ;; + + "info") + LOG_LEVEL=$NDLP_INFO + ;; + + "debug") + LOG_LEVEL=$NDLP_DEBUG + ;; esac } -set_log_severity_level - -logdate() { - date "+%Y-%m-%d %H:%M:%S" -} +set_log_min_priority log() { - local status="${1}" - shift + local level="${1}" + shift 1 - echo >&2 "$(logdate): ${PROGRAM_NAME}: ${status}: ${*}" + [[ -n "$level" && -n "$LOG_LEVEL" && "$level" -gt "$LOG_LEVEL" ]] && return + systemd-cat-native --log-as-netdata --newline="--NEWLINE--" <<EOFLOG +INVOCATION_ID=${NETDATA_INVOCATION_ID} +SYSLOG_IDENTIFIER=${PROGRAM_NAME} +PRIORITY=${level} +THREAD_TAG=ioping.plugin +ND_LOG_SOURCE=collector +MESSAGE=${MODULE_NAME}: ${*//\\n/--NEWLINE--} + +EOFLOG + # AN EMPTY LINE IS NEEDED ABOVE } info() { - [[ -n "$LOG_LEVEL" && "$LOG_LEVEL_INFO" -gt "$LOG_LEVEL" ]] && return - log INFO "${@}" + log "$NDLP_INFO" "${@}" } warning() { - [[ -n "$LOG_LEVEL" && "$LOG_LEVEL_WARN" -gt "$LOG_LEVEL" ]] && return - log WARNING "${@}" + log "$NDLP_WARN" "${@}" } error() { - [[ -n "$LOG_LEVEL" && "$LOG_LEVEL_ERR" -gt "$LOG_LEVEL" ]] && return - log ERROR "${@}" + log "$NDLP_ERR" "${@}" } -fatal() { - log FATAL "${@}" +disable() { + log "${@}" echo "DISABLE" - exit 1 + exit 1 +} + +fatal() { + disable "$NDLP_ALERT" "${@}" } -debug=0 debug() { - [ $debug -eq 1 ] && log DEBUG "${@}" + log "$NDLP_DEBUG" "${@}" } # ----------------------------------------------------------------------------- @@ -194,35 +237,36 @@ ioping_opts="-T 1000000" 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}'..." + debug "Loading config file '${CONFIG}'..." source "${CONFIG}" - [ $? -ne 0 ] && error "Failed to load config file '${CONFIG}'." + [ $? -ne 0 ] && warn "Failed to load config file '${CONFIG}'." elif [[ $CONFIG =~ ^$NETDATA_USER_CONFIG_DIR ]]; then - warning "Cannot find file '${CONFIG}'." + debug "Cannot find file '${CONFIG}'." fi done if [ -z "${destination}" ] then - fatal "destination is not configured - nothing to do." + disable $NDLP_DEBUG "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'" + disable $NDLP_ERR "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." + disable $NDLP_ERR "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[*]}" +debug "starting ioping: ${ioping} ${options[*]}" + exec "${ioping}" "${options[@]}" # if we cannot execute ioping, stop -fatal "command '${ioping} ${options[*]}' failed to be executed (returned code $?)." +error "command '${ioping} ${options[*]}' failed to be executed (returned code $?)." |