0
0
Fork 0
mirror of https://github.com/netdata/netdata.git synced 2025-05-13 05:02:03 +00:00

uniform logging from all scripts

This commit is contained in:
Costa Tsaousis (ktsaou) 2016-10-20 22:39:16 +03:00
parent addb52bb18
commit 0a26e46c36
No known key found for this signature in database
GPG key ID: 29CA335889B9A863
24 changed files with 357 additions and 63 deletions

View file

@ -1,5 +1,11 @@
# no need for shebang - this file is loaded from charts.d.plugin
# netdata
# real-time performance and health monitoring, done right!
# (C) 2016 Costa Tsaousis <costa@tsaousis.gr>
# GPL v3+
#
# _update_every is a special variable - it holds the number of seconds
# between the calls of the _update() function
ap_update_every=

View file

@ -1,5 +1,11 @@
# no need for shebang - this file is loaded from charts.d.plugin
# netdata
# real-time performance and health monitoring, done right!
# (C) 2016 Costa Tsaousis <costa@tsaousis.gr>
# GPL v3+
#
# the URL to download apache status info
apache_url="http://127.0.0.1:80/server-status?auto"
apache_curl_opts=

View file

@ -1,5 +1,11 @@
# no need for shebang - this file is loaded from charts.d.plugin
# netdata
# real-time performance and health monitoring, done right!
# (C) 2016 Costa Tsaousis <costa@tsaousis.gr>
# GPL v3+
#
apcupsd_ip=127.0.0.1
apcupsd_port=3551

View file

@ -1,5 +1,10 @@
# no need for shebang - this file is loaded from charts.d.plugin
# netdata
# real-time performance and health monitoring, done right!
# (C) 2016 Costa Tsaousis <costa@tsaousis.gr>
# GPL v3+
#
# THIS PLUGIN IS OBSOLETE
# USE apps.plugin INSTEAD

View file

@ -1,5 +1,11 @@
# no need for shebang - this file is loaded from charts.d.plugin
# netdata
# real-time performance and health monitoring, done right!
# (C) 2016 Costa Tsaousis <costa@tsaousis.gr>
# GPL v3+
#
# if this chart is called X.chart.sh, then all functions and global variables
# must start with X_

View file

@ -1,5 +1,11 @@
# no need for shebang - this file is loaded from charts.d.plugin
# netdata
# real-time performance and health monitoring, done right!
# (C) 2016 Costa Tsaousis <costa@tsaousis.gr>
# GPL v3+
#
# if this chart is called X.chart.sh, then all functions and global variables
# must start with X_

View file

@ -1,5 +1,12 @@
# no need for shebang - this file is loaded from charts.d.plugin
# netdata
# real-time performance and health monitoring, done right!
# (C) 2016 Costa Tsaousis <costa@tsaousis.gr>
# GPL v3+
#
# Contributed by @jsveiga with PR #480
# the exim command to run
exim_command=

View file

@ -1,5 +1,12 @@
# no need for shebang - this file is loaded from charts.d.plugin
# netdata
# real-time performance and health monitoring, done right!
# (C) 2016 Costa Tsaousis <costa@tsaousis.gr>
# GPL v3+
#
# contributed by @paulfantom with PR #511
# if this chart is called X.chart.sh, then all functions and global variables
# must start with X_
hddtemp_host="localhost"

View file

@ -1,5 +1,11 @@
# no need for shebang - this file is loaded from charts.d.plugin
# netdata
# real-time performance and health monitoring, done right!
# (C) 2016 Costa Tsaousis <costa@tsaousis.gr>
# GPL v3+
#
load_average_update_every=5
load_priority=100

View file

@ -1,5 +1,11 @@
# no need for shebang - this file is loaded from charts.d.plugin
# netdata
# real-time performance and health monitoring, done right!
# (C) 2016 Costa Tsaousis <costa@tsaousis.gr>
# GPL v3+
#
mem_apps_apps=
# these are required for computing memory in bytes and cpu in seconds

View file

@ -1,5 +1,11 @@
# no need for shebang - this file is loaded from charts.d.plugin
# netdata
# real-time performance and health monitoring, done right!
# (C) 2016 Costa Tsaousis <costa@tsaousis.gr>
# GPL v3+
#
# http://dev.mysql.com/doc/refman/5.0/en/server-status-variables.html
#
# https://dev.mysql.com/doc/refman/5.1/en/show-status.html

View file

@ -1,5 +1,11 @@
# no need for shebang - this file is loaded from charts.d.plugin
# netdata
# real-time performance and health monitoring, done right!
# (C) 2016 Costa Tsaousis <costa@tsaousis.gr>
# GPL v3+
#
# if this chart is called X.chart.sh, then all functions and global variables
# must start with X_

View file

@ -1,5 +1,11 @@
# no need for shebang - this file is loaded from charts.d.plugin
# netdata
# real-time performance and health monitoring, done right!
# (C) 2016 Costa Tsaousis <costa@tsaousis.gr>
# GPL v3+
#
# a space separated list of UPS names
# if empty, the list returned by 'upsc -l' will be used
nut_ups=

View file

@ -1,5 +1,11 @@
# no need for shebang - this file is loaded from charts.d.plugin
# netdata
# real-time performance and health monitoring, done right!
# (C) 2016 Costa Tsaousis <costa@tsaousis.gr>
# GPL v3+
#
opensips_opts="fifo get_statistics all"
opensips_cmd=
opensips_update_every=5

View file

@ -1,9 +1,13 @@
# no need for shebang - this file is loaded from charts.d.plugin
# if this chart is called X.chart.sh, then all functions and global variables
# must start with X_
# netdata
# real-time performance and health monitoring, done right!
# (C) 2016 Costa Tsaousis <costa@tsaousis.gr>
# GPL v3+
#
# Contributed by @safeie with PR #276
# first, you need open php-fpm status in php-fpm.conf
# first, you need open php-fpm status in php-fpm.conf
# second, you need add status location in nginx.conf
# you can see, https://easyengine.io/tutorials/php/fpm-status-page/

View file

@ -1,5 +1,11 @@
# no need for shebang - this file is loaded from charts.d.plugin
# netdata
# real-time performance and health monitoring, done right!
# (C) 2016 Costa Tsaousis <costa@tsaousis.gr>
# GPL v3+
#
# the postqueue command
# if empty, it will use the one found in the system path
postfix_postqueue=

View file

@ -1,5 +1,11 @@
# no need for shebang - this file is loaded from charts.d.plugin
# netdata
# real-time performance and health monitoring, done right!
# (C) 2016 Costa Tsaousis <costa@tsaousis.gr>
# GPL v3+
#
# sensors docs
# https://www.kernel.org/doc/Documentation/hwmon/sysfs-interface

View file

@ -1,5 +1,11 @@
# no need for shebang - this file is loaded from charts.d.plugin
# netdata
# real-time performance and health monitoring, done right!
# (C) 2016 Costa Tsaousis <costa@tsaousis.gr>
# GPL v3+
#
squid_host=
squid_port=
squid_url=

View file

@ -1,5 +1,12 @@
# no need for shebang - this file is loaded from charts.d.plugin
# netdata
# real-time performance and health monitoring, done right!
# (C) 2016 Costa Tsaousis <costa@tsaousis.gr>
# GPL v3+
#
# Contributed by @jgeromero with PR #277
# Description: Tomcat netdata charts.d plugin
# Author: Jorge Romero

View file

@ -5,7 +5,7 @@
# (C) 2016 Costa Tsaousis <costa@tsaousis.gr>
# GPL v3+
#
# Script the send alarm notifications for netdata
# Script to send alarm notifications for netdata
#
# Features:
# - multiple notification methods
@ -20,14 +20,56 @@
# - telegram.org notifications
#
me="${0}"
export PATH="${PATH}:/sbin:/usr/sbin:/usr/local/sbin"
export LC_ALL=C
# -----------------------------------------------------------------------------
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 "${@}"
exit 1
}
debug=0
debug() {
[ $debug -eq 1 ] && log DEBUG "${@}"
}
# -----------------------------------------------------------------------------
# check for BASH v4+ (required for associative arrays)
[ $(( ${BASH_VERSINFO[0]} )) -lt 4 ] && \
echo >&2 "${me}: BASH version 4 or later is required (this is ${BASH_VERSION})." && \
exit 1
fatal "BASH version 4 or later is required (this is ${BASH_VERSION})."
# -----------------------------------------------------------------------------
# defaults to allow running this script by hand
NETDATA_CONFIG_DIR="${NETDATA_CONFIG_DIR-/etc/netdata}"
NETDATA_CACHE_DIR="${NETDATA_CACHE_DIR-/var/cache/netdata}"
[ -z "${NETDATA_REGISTRY_URL}" ] && NETDATA_REGISTRY_URL="https://registry.my-netdata.io"
@ -62,14 +104,14 @@ info="${18}" # a short description of the alarm
# don't do anything if this is not WARNING, CRITICAL or CLEAR
if [ "${status}" != "WARNING" -a "${status}" != "CRITICAL" -a "${status}" != "CLEAR" ]
then
echo >&2 "${me}: not sending notification for ${status} on '${chart}.${name}'"
info "not sending notification for ${status} on '${chart}.${name}'"
exit 1
fi
# don't do anything if this is CLEAR, but it was not WARNING or CRITICAL
if [ "${old_status}" != "WARNING" -a "${old_status}" != "CRITICAL" -a "${status}" = "CLEAR" ]
then
echo >&2 "${me}: not sending notification for ${status} on '${chart}.${name}' (last status was ${old_status})"
info "not sending notification for ${status} on '${chart}.${name}' (last status was ${old_status})"
exit 1
fi
@ -262,8 +304,7 @@ fi
# check that we have at least a method enabled
if [ "${SEND_EMAIL}" != "YES" -a "${SEND_PUSHOVER}" != "YES" -a "${SEND_TELEGRAM}" != "YES" -a "${SEND_SLACK}" != "YES" ]
then
echo >&2 "All notification methods are disabled. Not sending a notification."
exit 1
fatal "All notification methods are disabled. Not sending a notification."
fi
# -----------------------------------------------------------------------------
@ -372,10 +413,10 @@ send_email() {
if [ $ret -eq 0 ]
then
echo >&2 "${me}: Sent email notification for: ${host} ${chart}.${name} is ${status} to '${to_email}'"
info "sent email notification for: ${host} ${chart}.${name} is ${status} to '${to_email}'"
return 0
else
echo >&2 "${me}: Failed to send email notification for: ${host} ${chart}.${name} is ${status} to '${to_email}' with error code ${ret}."
error "failed to send email notification for: ${host} ${chart}.${name} is ${status} to '${to_email}' with error code ${ret}."
return 1
fi
fi
@ -417,10 +458,10 @@ send_pushover() {
if [ "${httpcode}" == "200" ]
then
echo >&2 "${me}: Sent pushover notification for: ${host} ${chart}.${name} is ${status} to '${user}'"
info "sent pushover notification for: ${host} ${chart}.${name} is ${status} to '${user}'"
sent=$((sent + 1))
else
echo >&2 "${me}: Failed to send pushover notification for: ${host} ${chart}.${name} is ${status} to '${user}' with HTTP error code ${httpcode}."
error "failed to send pushover notification for: ${host} ${chart}.${name} is ${status} to '${user}' with HTTP error code ${httpcode}."
fi
done
@ -452,13 +493,13 @@ send_telegram() {
if [ "${httpcode}" == "200" ]
then
echo >&2 "${me}: Sent telegram notification for: ${host} ${chart}.${name} is ${status} to '${chatid}'"
info "sent telegram notification for: ${host} ${chart}.${name} is ${status} to '${chatid}'"
sent=$((sent + 1))
elif [ "${httpcode}" == "401" ]
then
echo >&2 "${me}: Failed to send telegram notification for: ${host} ${chart}.${name} is ${status} to '${chatid}': Wrong bot token."
error "failed to send telegram notification for: ${host} ${chart}.${name} is ${status} to '${chatid}': Wrong bot token."
else
echo >&2 "${me}: Failed to send telegram notification for: ${host} ${chart}.${name} is ${status} to '${chatid}' with HTTP error code ${httpcode}."
error "failed to send telegram notification for: ${host} ${chart}.${name} is ${status} to '${chatid}' with HTTP error code ${httpcode}."
fi
done
@ -520,10 +561,10 @@ EOF
httpcode=$(${curl} --write-out %{http_code} --silent --output /dev/null -X POST --data-urlencode "payload=${payload}" "${webhook}")
if [ "${httpcode}" == "200" ]
then
echo >&2 "${me}: Sent slack notification for: ${host} ${chart}.${name} is ${status} to '${channel}'"
info "sent slack notification for: ${host} ${chart}.${name} is ${status} to '${channel}'"
sent=$((sent + 1))
else
echo >&2 "${me}: Failed to send slack notification for: ${host} ${chart}.${name} is ${status} to '${channel}', with HTTP error code ${httpcode}."
error "failed to send slack notification for: ${host} ${chart}.${name} is ${status} to '${channel}', with HTTP error code ${httpcode}."
fi
done

View file

@ -1,17 +1,66 @@
#!/usr/bin/env bash
# netdata
# real-time performance and health monitoring, done right!
# (C) 2016 Costa Tsaousis <costa@tsaousis.gr>
# GPL v3+
#
# Script to find a better name for cgroups
#
export PATH="${PATH}:/sbin:/usr/sbin:/usr/local/sbin"
export LC_ALL=C
# -----------------------------------------------------------------------------
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 "${@}"
exit 1
}
debug=0
debug() {
[ $debug -eq 1 ] && log DEBUG "${@}"
}
# -----------------------------------------------------------------------------
NETDATA_CONFIG_DIR="${NETDATA_CONFIG_DIR-/etc/netdata}"
CONFIG="${NETDATA_CONFIG_DIR}/cgroups-names.conf"
CGROUP="${1}"
NAME=
# -----------------------------------------------------------------------------
if [ -z "${CGROUP}" ]
then
echo >&2 "${0}: called without a cgroup name. Nothing to do."
exit 1
fatal "called without a cgroup name. Nothing to do."
fi
if [ -f "${CONFIG}" ]
@ -19,15 +68,15 @@ if [ -f "${CONFIG}" ]
NAME="$(grep "^${CGROUP} " "${CONFIG}" | sed "s/[[:space:]]\+/ /g" | cut -d ' ' -f 2)"
if [ -z "${NAME}" ]
then
echo >&2 "${0}: cannot find cgroup '${CGROUP}' in '${CONFIG}'."
info "cannot find cgroup '${CGROUP}' in '${CONFIG}'."
fi
#else
# echo >&2 "${0}: configuration file '${CONFIG}' is not available."
# info "configuration file '${CONFIG}' is not available."
fi
function get_name_classic {
local DOCKERID="$1"
echo >&2 "Running command: docker ps --filter=id=\"${DOCKERID}\" --format=\"{{.Names}}\""
info "Running command: docker ps --filter=id=\"${DOCKERID}\" --format=\"{{.Names}}\""
NAME="$( docker ps --filter=id="${DOCKERID}" --format="{{.Names}}" )"
return 0
}
@ -36,10 +85,10 @@ function get_name_api {
local DOCKERID="$1"
if [ ! -S "/var/run/docker.sock" ]
then
echo >&2 "Can't find /var/run/docker.sock"
warning "Can't find /var/run/docker.sock"
return 1
fi
echo >&2 "Running API command: /containers/${DOCKERID}/json"
info "Running API command: /containers/${DOCKERID}/json"
JSON=$(echo -e "GET /containers/${DOCKERID}/json HTTP/1.0\r\n" | nc -U /var/run/docker.sock | egrep '^{.*')
NAME=$(echo $JSON | jq -r .Name,.Config.Hostname | grep -v null | head -n1 | sed 's|^/||')
return 0
@ -62,10 +111,10 @@ if [ -z "${NAME}" ]
fi
if [ -z "${NAME}" ]
then
echo >&2 "Cannot find the name of docker container '${DOCKERID}'"
warning "cannot find the name of docker container '${DOCKERID}'"
NAME="${DOCKERID:0:12}"
else
echo >&2 "Docker container '${DOCKERID}' is named '${NAME}'"
info "docker container '${DOCKERID}' is named '${NAME}'"
fi
fi
fi
@ -74,5 +123,5 @@ if [ -z "${NAME}" ]
[ ${#NAME} -gt 100 ] && NAME="${NAME:0:100}"
fi
echo >&2 "${0}: cgroup '${CGROUP}' is called '${NAME}'"
info "cgroup '${CGROUP}' is called '${NAME}'"
echo "${NAME}"

View file

@ -1,5 +1,17 @@
#!/usr/bin/env bash
# netdata
# real-time performance and health monitoring, done right!
# (C) 2016 Costa Tsaousis <costa@tsaousis.gr>
# GPL v3+
#
# charts.d.plugin allows easy development of BASH plugins
#
# if you need to run parallel charts.d processes, link this file to a different name
# in the same directory, with a .plugin suffix and netdata will start both of them,
# each will have a different config file and modules configuration directory.
#
export PATH="${PATH}:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
PROGRAM_FILE="$0"
@ -7,12 +19,6 @@ PROGRAM_NAME="$(basename $0)"
PROGRAM_NAME="${PROGRAM_NAME/.plugin}"
MODULE_NAME="main"
# if you need to run parallel charts.d processes
# just link this files with a different name
# in the same directory, with a .plugin suffix
# netdata will start multiple of them
# each will have a different config file
# -----------------------------------------------------------------------------
# create temp dir

View file

@ -1,17 +1,10 @@
#!/usr/bin/env bash
me="${0}"
# 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
NETDATA_CONFIG_DIR="${NETDATA_CONFIG_DIR-/etc/netdata}"
# -----------------------------------------------------------------------------
# netdata
# real-time performance and health monitoring, done right!
# (C) 2016 Costa Tsaousis <costa@tsaousis.gr>
# GPL v3+
#
# This plugin requires a special version of fping.
# Get it from https://github.com/ktsaou/fping
# and build it, like this:
@ -29,6 +22,58 @@ NETDATA_CONFIG_DIR="${NETDATA_CONFIG_DIR-/etc/netdata}"
# Then, create /etc/netdata/fping.conf
# and set the configuration options given below
export PATH="${PATH}:/sbin:/usr/sbin:/usr/local/sbin"
export LC_ALL=C
# -----------------------------------------------------------------------------
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 "${@}"
}
# -----------------------------------------------------------------------------
# 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
NETDATA_CONFIG_DIR="${NETDATA_CONFIG_DIR-/etc/netdata}"
# -----------------------------------------------------------------------------
# configuration options
# can be overwritten at /etc/netdata/fping.conf
@ -48,29 +93,23 @@ ping_every="$((update_every * 1000 / 2))"
retries=1
# -----------------------------------------------------------------------------
# load the configuration file
if [ ! -f "${NETDATA_CONFIG_DIR}/fping.conf" ]
then
echo >&2 "${me}: configuration file '${NETDATA_CONFIG_DIR}/fping.conf' not found - nothing to do."
echo "DISABLE"
exit 1
fatal "configuration file '${NETDATA_CONFIG_DIR}/fping.conf' not found - nothing to do."
fi
source "${NETDATA_CONFIG_DIR}/fping.conf"
if [ -z "${hosts}" ]
then
echo >&2 "${me}: no hosts configued in '${NETDATA_CONFIG_DIR}/fping.conf' - nothing to do."
echo "DISABLE"
exit 1
fatal "no hosts configued in '${NETDATA_CONFIG_DIR}/fping.conf' - nothing to do."
fi
if [ -z "${fping}" -o ! -x "${fping}" ]
then
echo >&2 "${me}: command '${fping}' is not executable - cannot proceed."
echo "DISABLE"
exit 1
fatal "command '${fping}' is not executable - cannot proceed."
fi
# the fping options we will use
@ -80,6 +119,4 @@ options=( -N -l -R -Q ${update_every} -p ${ping_every} -r ${retries} ${hosts} )
exec "${fping}" "${options[@]}"
# if we cannot execute fping, stop
echo >&2 "${me}: command '${fping} ${options[@]}' failed to be executed."
echo "DISABLE"
exit 1
fatal "command '${fping} ${options[@]}' failed to be executed."

View file

@ -1,11 +1,59 @@
#!/usr/bin/env bash
# netdata
# real-time performance and health monitoring, done right!
# (C) 2016 Costa Tsaousis <costa@tsaousis.gr>
# GPL v3+
#
# This script is a helper to allow netdata collect tc data
# parsing tc output has been implemented in C, inside netdata
# This script allows setting names to dimensions.
export PATH="${PATH}:/sbin:/usr/sbin:/usr/local/sbin"
export LC_ALL=C
PROGRAM_FILE="$0"
PROGRAM_NAME="$(basename $0)"
PROGRAM_NAME="${PROGRAM_NAME/.plugin}"
# -----------------------------------------------------------------------------
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 "${@}"
exit 1
}
debug=0
debug() {
[ $debug -eq 1 ] && log DEBUG "${@}"
}
# -----------------------------------------------------------------------------
plugins_dir="${NETDATA_PLUGINS_DIR}"
[ -z "$plugins_dir" ] && plugins_dir="$( dirname $PROGRAM_FILE )"
@ -39,8 +87,7 @@ loopsleepms() {
if [ -z "${tc}" -o ! -x "${tc}" ]
then
echo >&2 "${PROGRAM_NAME}: Cannot find command 'tc' in this system."
exit 1
fatal "cannot find command 'tc' in this system."
fi
devices=