summaryrefslogtreecommitdiffstats
path: root/plugins.d/cgroup-name.sh
diff options
context:
space:
mode:
authorFederico Ceratto <federico.ceratto@gmail.com>2018-03-27 21:28:27 +0000
committerFederico Ceratto <federico.ceratto@gmail.com>2018-03-27 21:28:27 +0000
commiteb7cc2640201f168bbd9a05799fd2dbe823bb57c (patch)
tree1f88da02b7ee3c16ced7b5f7dc4aadb190766e7c /plugins.d/cgroup-name.sh
parentRelease v. 1.9.0+dfsg-1 to Unstable (diff)
parentNew upstream version 1.10.0+dfsg (diff)
downloadnetdata-eb7cc2640201f168bbd9a05799fd2dbe823bb57c.tar.xz
netdata-eb7cc2640201f168bbd9a05799fd2dbe823bb57c.zip
Update upstream source from tag 'upstream/1.10.0+dfsg'
Update to upstream version '1.10.0+dfsg' with Debian dir fa5485f3d9aea3038a19eff06ba33374ac5c5d7c
Diffstat (limited to 'plugins.d/cgroup-name.sh')
-rwxr-xr-xplugins.d/cgroup-name.sh52
1 files changed, 39 insertions, 13 deletions
diff --git a/plugins.d/cgroup-name.sh b/plugins.d/cgroup-name.sh
index acdd6f4f..3c8ad720 100755
--- a/plugins.d/cgroup-name.sh
+++ b/plugins.d/cgroup-name.sh
@@ -94,6 +94,23 @@ function docker_get_name_api {
return 0
}
+function docker_get_name {
+ local id="${1}"
+ if hash docker 2>/dev/null
+ then
+ docker_get_name_classic "${id}"
+ else
+ docker_get_name_api "${id}" || docker_get_name_classic "${id}"
+ fi
+ if [ -z "${NAME}" ]
+ then
+ warning "cannot find the name of docker container '${id}'"
+ NAME="${id:0:12}"
+ else
+ info "docker container '${id}' is named '${NAME}'"
+ fi
+}
+
if [ -z "${NAME}" ]
then
if [[ "${CGROUP}" =~ ^.*docker[-_/\.][a-fA-F0-9]+[-_\.]?.*$ ]]
@@ -105,20 +122,29 @@ if [ -z "${NAME}" ]
if [ ! -z "${DOCKERID}" -a \( ${#DOCKERID} -eq 64 -o ${#DOCKERID} -eq 12 \) ]
then
- if hash docker 2>/dev/null
- then
- docker_get_name_classic ${DOCKERID}
- else
- docker_get_name_api ${DOCKERID} || docker_get_name_classic ${DOCKERID}
- fi
- if [ -z "${NAME}" ]
- then
- warning "cannot find the name of docker container '${DOCKERID}'"
- NAME="${DOCKERID:0:12}"
- else
- info "docker container '${DOCKERID}' is named '${NAME}'"
- fi
+ docker_get_name "${DOCKERID}"
+ else
+ error "a docker id cannot be extracted from docker cgroup '${CGROUP}'."
+ fi
+ elif [[ "${CGROUP}" =~ ^.*kubepods[_/].*[_/]pod[a-fA-F0-9-]+[_/][a-fA-F0-9]+$ ]]
+ then
+ # kubernetes
+
+ DOCKERID="$( echo "${CGROUP}" | sed "s|^.*kubepods[_/].*[_/]pod[a-fA-F0-9-]\+[_/]\([a-fA-F0-9]\+\)$|\1|" )"
+ # echo "DOCKERID=${DOCKERID}"
+
+ if [ ! -z "${DOCKERID}" -a \( ${#DOCKERID} -eq 64 -o ${#DOCKERID} -eq 12 \) ]
+ then
+ docker_get_name "${DOCKERID}"
+ else
+ error "a docker id cannot be extracted from kubernetes cgroup '${CGROUP}'."
fi
+ elif [[ "${CGROUP}" =~ machine.slice[_/].*\.service ]]
+ then
+ # systemd-nspawn
+
+ NAME="$(echo ${CGROUP} | sed 's/.*machine.slice[_\/]\(.*\)\.service/\1/g')"
+
elif [[ "${CGROUP}" =~ machine.slice_machine.*-qemu ]]
then
# libvirtd / qemu virtual machines