]> arthur.barton.de Git - netdata.git/blobdiff - plugins.d/cgroup-name.sh
cgroups are enabled/disabled using their new names (it was needed because docker...
[netdata.git] / plugins.d / cgroup-name.sh
index 8d207fd45868bb7f8b8323eab2e862b3712d9bb3..f0a89594ce32e7f50a0f9dd03aa9c9bf3bfc85c8 100755 (executable)
@@ -15,7 +15,7 @@ fi
 
 if [ -f "${CONFIG}" ]
        then
-       NAME="$(cat "${CONFIG}" | grep "^${CGROUP}" | cut -d ' ' -f 2)"
+       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}'."
@@ -24,11 +24,17 @@ else
        echo >&2 "${0}: configuration file '${CONFIG}' is not available."
 fi
 
+if [ -z "${NAME}" -a "${CGROUP:0:7}" = "docker/" ]
+       then
+       NAME="$(docker ps | grep "^${CGROUP:7:12}" | sed "s/[[:space:]]\+/ /g" | cut -d ' ' -f 2)"
+       [ -z "${NAME}" ] && NAME="${CGROUP:0:19}"
+fi
+
 if [ -z "${NAME}" ]
        then
-       if [ ${#CGROUP} -gt 12 ]
+       if [ ${#CGROUP} -gt 20 ]
                then
-               NAME="${CGROUP:0:12}"
+               NAME="${CGROUP:0:20}"
        else
                NAME="${CGROUP}"
        fi