]> arthur.barton.de Git - netdata.git/blob - plugins.d/cgroup-name.sh
cgroups are now on their own thread; cgroup names are controlled by plugins.d/cgroup...
[netdata.git] / plugins.d / cgroup-name.sh
1 #!/bin/bash
2
3 export PATH="${PATH}:/sbin:/usr/sbin:/usr/local/sbin"
4
5 NETDATA_CONFIG_DIR="${NETDATA_CONFIG_DIR-/etc/netdata}"
6 CONFIG="${NETDATA_CONFIG_DIR}/cgroups-names.conf"
7 CGROUP="${1}"
8 NAME=
9
10 if [ -z "${CGROUP}" ]
11         then
12         echo >&2 "${0}: called without a cgroup name. Nothing to do."
13         exit 1
14 fi
15
16 if [ -f "${CONFIG}" ]
17         then
18         NAME="$(cat "${CONFIG}" | grep "^${CGROUP}" | cut -d ' ' -f 2)"
19         if [ -z "${NAME}" ]
20                 then
21                 echo >&2 "${0}: cannot find cgroup '${CGROUP}' in '${CONFIG}'."
22         fi
23 else
24         echo >&2 "${0}: configuration file '${CONFIG}' is not available."
25 fi
26
27 if [ -z "${NAME}" ]
28         then
29         if [ ${#CGROUP} -gt 12 ]
30                 then
31                 NAME="${CGROUP:0:12}"
32         else
33                 NAME="${CGROUP}"
34         fi
35 fi
36
37 echo >&2 "${0}: cgroup '${CGROUP}' is named as '${NAME}'"
38 echo "${NAME}"