summaryrefslogtreecommitdiffstats
path: root/plugins.d
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--plugins.d/Makefile.am1
-rw-r--r--plugins.d/Makefile.in6
-rwxr-xr-xplugins.d/cgroup-name.sh75
-rwxr-xr-xplugins.d/charts.d.plugin12
4 files changed, 88 insertions, 6 deletions
diff --git a/plugins.d/Makefile.am b/plugins.d/Makefile.am
index a89ee4cdd..a717cbed1 100644
--- a/plugins.d/Makefile.am
+++ b/plugins.d/Makefile.am
@@ -8,6 +8,7 @@ dist_plugins_DATA = \
$(NULL)
dist_plugins_SCRIPTS = \
+ cgroup-name.sh \
charts.d.dryrun-helper.sh \
charts.d.plugin \
node.d.plugin \
diff --git a/plugins.d/Makefile.in b/plugins.d/Makefile.in
index 3b4e5198f..c74997688 100644
--- a/plugins.d/Makefile.in
+++ b/plugins.d/Makefile.in
@@ -186,6 +186,8 @@ OPTIONAL_MATH_CLFAGS = @OPTIONAL_MATH_CLFAGS@
OPTIONAL_MATH_LIBS = @OPTIONAL_MATH_LIBS@
OPTIONAL_NFACCT_CLFAGS = @OPTIONAL_NFACCT_CLFAGS@
OPTIONAL_NFACCT_LIBS = @OPTIONAL_NFACCT_LIBS@
+OPTIONAL_UUID_CLFAGS = @OPTIONAL_UUID_CLFAGS@
+OPTIONAL_UUID_LIBS = @OPTIONAL_UUID_LIBS@
OPTIONAL_ZLIB_CLFAGS = @OPTIONAL_ZLIB_CLFAGS@
OPTIONAL_ZLIB_LIBS = @OPTIONAL_ZLIB_LIBS@
PACKAGE = @PACKAGE@
@@ -207,6 +209,8 @@ PTHREAD_LIBS = @PTHREAD_LIBS@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
+UUID_CFLAGS = @UUID_CFLAGS@
+UUID_LIBS = @UUID_LIBS@
VERSION = @VERSION@
ZLIB_CFLAGS = @ZLIB_CFLAGS@
ZLIB_LIBS = @ZLIB_LIBS@
@@ -267,6 +271,7 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
+varlibdir = @varlibdir@
webdir = @webdir@
#
@@ -278,6 +283,7 @@ dist_plugins_DATA = \
$(NULL)
dist_plugins_SCRIPTS = \
+ cgroup-name.sh \
charts.d.dryrun-helper.sh \
charts.d.plugin \
node.d.plugin \
diff --git a/plugins.d/cgroup-name.sh b/plugins.d/cgroup-name.sh
new file mode 100755
index 000000000..8ce64b3d7
--- /dev/null
+++ b/plugins.d/cgroup-name.sh
@@ -0,0 +1,75 @@
+#!/bin/bash
+
+export PATH="${PATH}:/sbin:/usr/sbin:/usr/local/sbin"
+export LC_ALL=C
+
+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
+fi
+
+if [ -f "${CONFIG}" ]
+ then
+ NAME="$(cat "${CONFIG}" | grep "^${CGROUP} " | sed "s/[[:space:]]\+/ /g" | cut -d ' ' -f 2)"
+ if [ -z "${NAME}" ]
+ then
+ echo >&2 "${0}: cannot find cgroup '${CGROUP}' in '${CONFIG}'."
+ fi
+#else
+# echo >&2 "${0}: configuration file '${CONFIG}' is not available."
+fi
+
+function get_name_classic {
+ DOCKERID=$1
+ echo >&2 "Running command: docker ps --filter=id=\"${DOCKERID}\" --format=\"{{.Names}}\""
+ NAME="$( docker ps --filter=id="${DOCKERID}" --format="{{.Names}}" )"
+}
+
+function get_name_api {
+ DOCKERID=$1
+ if [ ! -S "/var/run/docker.sock" ]
+ then
+ echo >&2 "Can't find /var/run/docker.sock"
+ return
+ fi
+ echo >&2 "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|^/||')
+}
+
+if [ -z "${NAME}" ]
+ then
+ if [[ "${CGROUP}" =~ ^.*docker[-/\.][a-fA-F0-9]+[-\.]?.*$ ]]
+ then
+ DOCKERID="$( echo "${CGROUP}" | sed "s|^.*docker[-/]\([a-fA-F0-9]\+\)[-\.]\?.*$|\1|" )"
+
+ if [ ! -z "${DOCKERID}" -a \( ${#DOCKERID} -eq 64 -o ${#DOCKERID} -eq 12 \) ]
+ then
+ if hash docker 2>/dev/null
+ then
+ get_name_classic $DOCKERID
+ else
+ get_name_api $DOCKERID
+ fi
+ if [ -z "${NAME}" ]
+ then
+ echo >&2 "Cannot find the name of docker container '${DOCKERID}'"
+ NAME="${DOCKERID:0:12}"
+ else
+ echo >&2 "Docker container '${DOCKERID}' is named '${NAME}'"
+ fi
+ fi
+ fi
+
+ [ -z "${NAME}" ] && NAME="${CGROUP}"
+ [ ${#NAME} -gt 50 ] && NAME="${NAME:0:50}"
+fi
+
+echo >&2 "${0}: cgroup '${CGROUP}' is called '${NAME}'"
+echo "${NAME}"
diff --git a/plugins.d/charts.d.plugin b/plugins.d/charts.d.plugin
index 27b294709..2824fa3c6 100755
--- a/plugins.d/charts.d.plugin
+++ b/plugins.d/charts.d.plugin
@@ -84,7 +84,7 @@ time_divisor=50
# number of seconds to run without restart
# after this time, charts.d.plugin will exit
# netdata will restart it
-restart_timeout=$[3600 * 4]
+restart_timeout=$((3600 * 4))
# check if the charts.d plugins are using global variables
# they should not.
@@ -247,7 +247,7 @@ float2int() {
# echo >&2 "value='${1}' f='${f}', m='${m}'"
# the length of the multiplier - 1
- l=$[ ${#m} - 1 ]
+ l=$(( ${#m} - 1 ))
# check if the number is in scientific notation
if [[ ${f} =~ ^[[:space:]]*(-)?[0-9.]+(e|E)(\+|-)[0-9]+ ]]
@@ -269,7 +269,7 @@ float2int() {
# strip leading zeros from the integer part
# base 10 convertion
- a=$[10#$a]
+ a=$((10#$a))
# check the length of the decimal part
# against the length of the multiplier
@@ -281,16 +281,16 @@ float2int() {
elif [ ${#b} -lt ${l} ]
then
# too few digits - pad with zero on the right
- local z="00000000000000000000000" r=$[l - ${#b}]
+ local z="00000000000000000000000" r=$((l - ${#b}))
b="${b}${z:0:${r}}"
fi
# strip leading zeros from the decimal part
# base 10 convertion
- b=$[10#$b]
+ b=$((10#$b))
# store the result
- FLOAT2INT_RESULT=$[ (a * m) + b ]
+ FLOAT2INT_RESULT=$(( (a * m) + b ))
#echo >&2 "FLOAT2INT_RESULT='${FLOAT2INT_RESULT}'"
}