summaryrefslogtreecommitdiffstats
path: root/collectors/cgroups.plugin
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2021-05-19 12:33:27 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-05-19 12:33:27 +0000
commit841395dd16f470e3c051a0a4fff5b91efc983c30 (patch)
tree4115f6eedcddda75067130b80acaff9e51612f49 /collectors/cgroups.plugin
parentAdding upstream version 1.30.1. (diff)
downloadnetdata-841395dd16f470e3c051a0a4fff5b91efc983c30.tar.xz
netdata-841395dd16f470e3c051a0a4fff5b91efc983c30.zip
Adding upstream version 1.31.0.upstream/1.31.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'collectors/cgroups.plugin')
-rw-r--r--collectors/cgroups.plugin/README.md54
-rwxr-xr-xcollectors/cgroups.plugin/cgroup-name.sh.in8
-rwxr-xr-xcollectors/cgroups.plugin/cgroup-network-helper.sh16
-rw-r--r--collectors/cgroups.plugin/cgroup-network.c2
-rw-r--r--collectors/cgroups.plugin/sys_fs_cgroup.c34
5 files changed, 102 insertions, 12 deletions
diff --git a/collectors/cgroups.plugin/README.md b/collectors/cgroups.plugin/README.md
index 21dbcae83..86776d6e0 100644
--- a/collectors/cgroups.plugin/README.md
+++ b/collectors/cgroups.plugin/README.md
@@ -147,6 +147,33 @@ Support per distribution:
|AMI|NO|[here](http://pastebin.com/FrxmptjL)|not a systemd system|
|CentOS 7.3.1611|NO|[here](http://pastebin.com/SpzgezAg)|can be enabled, see below|
+### Monitored systemd service metrics
+
+- CPU utilization
+- Used memory
+- RSS memory
+- Mapped memory
+- Cache memory
+- Writeback memory
+- Memory minor page faults
+- Memory major page faults
+- Memory charging activity
+- Memory uncharging activity
+- Memory limit failures
+- Swap memory used
+- Disk read bandwidth
+- Disk write bandwidth
+- Disk read operations
+- Disk write operations
+- Throttle disk read bandwidth
+- Throttle disk write bandwidth
+- Throttle disk read operations
+- Throttle disk write operations
+- Queued disk read operations
+- Queued disk write operations
+- Merged disk read operations
+- Merged disk write operations
+
### how to enable cgroup accounting on systemd systems that is by default disabled
You can verify there is no accounting enabled, by running `systemd-cgtop`. The program will show only resources for cgroup `/`, but all services will show nothing.
@@ -230,4 +257,31 @@ So, when a network interface or container stops, Netdata might log a few errors
6. obsolete charts will be removed from memory, 1 hour after the last user viewed them (configurable with `[global].cleanup obsolete charts after seconds = 3600` (at `netdata.conf`).
7. when obsolete charts are removed from memory they are also deleted from disk (configurable with `[global].delete obsolete charts files = yes`)
+### Monitored container metrics
+
+- CPU usage
+- CPU usage within the limits
+- CPU usage per core
+- Memory usage
+- Writeback memory
+- Memory activity
+- Memory page faults
+- Used memory
+- Used RAM within the limits
+- Memory utilization
+- Memory limit failures
+- I/O bandwidth (all disks)
+- Serviced I/O operations (all disks)
+- Throttle I/O bandwidth (all disks)
+- Throttle serviced I/O operations (all disks)
+- Queued I/O operations (all disks)
+- Merged I/O operations (all disks)
+- CPU pressure
+- Memory pressure
+- Memory full pressure
+- I/O pressure
+- I/O full pressure
+
+Network interfaces are monitored by means of the [proc plugin](/collectors/proc.plugin/README.md#monitored-network-interface-metrics).
+
[![analytics](https://www.google-analytics.com/collect?v=1&aip=1&t=pageview&_s=1&ds=github&dr=https%3A%2F%2Fgithub.com%2Fnetdata%2Fnetdata&dl=https%3A%2F%2Fmy-netdata.io%2Fgithub%2Fcollectors%2Fcgroups.plugin%2FREADME&_u=MAC~&cid=5792dfd7-8dc4-476b-af31-da2fdb9f93d2&tid=UA-64295674-3)](<>)
diff --git a/collectors/cgroups.plugin/cgroup-name.sh.in b/collectors/cgroups.plugin/cgroup-name.sh.in
index 19fbf3989..8ef8ab58e 100755
--- a/collectors/cgroups.plugin/cgroup-name.sh.in
+++ b/collectors/cgroups.plugin/cgroup-name.sh.in
@@ -428,6 +428,14 @@ if [ -z "${NAME}" ]; then
# systemd-nspawn
NAME="$(echo "${CGROUP}" | sed 's/.*machine.slice[_\/]\(.*\)\.service/\1/g')"
+ elif [[ ${CGROUP} =~ machine.slice_machine.*-lxc ]]; then
+ # libvirtd / lxc containers
+ # examples:
+ # before: machine.slice machine-lxc/x2d969/x2dhubud0xians01.scope
+ # after: lxc/hubud0xians01
+ # before: machine.slice_machine-lxc/x2d969/x2dhubud0xians01.scope/libvirt_init.scope
+ # after: lxc/hubud0xians01/libvirt_init
+ NAME="lxc/$(echo "${CGROUP}" | sed 's/machine.slice_machine.*-lxc//; s/\/x2d[[:digit:]]*//; s/\/x2d//g; s/\.scope//g')"
elif [[ ${CGROUP} =~ machine.slice_machine.*-qemu ]]; then
# libvirtd / qemu virtual machines
# NAME="$(echo ${CGROUP} | sed 's/machine.slice_machine.*-qemu//; s/\/x2d//; s/\/x2d/\-/g; s/\.scope//g')"
diff --git a/collectors/cgroups.plugin/cgroup-network-helper.sh b/collectors/cgroups.plugin/cgroup-network-helper.sh
index eb839ef57..1b60f452a 100755
--- a/collectors/cgroups.plugin/cgroup-network-helper.sh
+++ b/collectors/cgroups.plugin/cgroup-network-helper.sh
@@ -123,7 +123,7 @@ proc_pid_fdinfo_iff() {
find_tun_tap_interfaces_for_cgroup() {
local c="${1}" # the cgroup path
[ -d "${c}/emulator" ] && c="${c}/emulator" # check for 'emulator' subdirectory
- c="${c}/cgroup.procs" # make full path
+ c="${c}/cgroup.procs" # make full path
# for each pid of the cgroup
# find any tun/tap devices linked to the pid
@@ -168,18 +168,26 @@ virsh_find_all_interfaces_for_cgroup() {
then
local d
d="$(virsh_cgroup_to_domain_name "${c}")"
+ # convert hex to character
+ # e.g.: vm01\x2dweb => vm01-web (https://github.com/netdata/netdata/issues/11088#issuecomment-832618149)
+ d="$(printf '%b' "${d}")"
if [ ! -z "${d}" ]
then
debug "running: virsh domiflist ${d}; to find the network interfaces"
- # match only 'network' interfaces from virsh output
+ # 'virsh -r domiflist <domain>' example output
+ # Interface Type Source Model MAC
+ #--------------------------------------------------------------
+ # vnet3 bridge br0 virtio 52:54:00:xx:xx:xx
+ # vnet4 network default virtio 52:54:00:yy:yy:yy
+ # match only 'network' interfaces from virsh output
set_source "virsh"
"${virsh}" -r domiflist "${d}" |\
sed -n \
- -e "s|^\([^[:space:]]\+\)[[:space:]]\+network[[:space:]]\+\([^[:space:]]\+\)[[:space:]]\+[^[:space:]]\+[[:space:]]\+[^[:space:]]\+$|\1 \1_\2|p" \
- -e "s|^\([^[:space:]]\+\)[[:space:]]\+bridge[[:space:]]\+\([^[:space:]]\+\)[[:space:]]\+[^[:space:]]\+[[:space:]]\+[^[:space:]]\+$|\1 \1_\2|p"
+ -e "s|^[[:space:]]\?\([^[:space:]]\+\)[[:space:]]\+network[[:space:]]\+\([^[:space:]]\+\)[[:space:]]\+[^[:space:]]\+[[:space:]]\+[^[:space:]]\+$|\1 \1_\2|p" \
+ -e "s|^[[:space:]]\?\([^[:space:]]\+\)[[:space:]]\+bridge[[:space:]]\+\([^[:space:]]\+\)[[:space:]]\+[^[:space:]]\+[[:space:]]\+[^[:space:]]\+$|\1 \1_\2|p"
else
debug "no virsh domain extracted from cgroup ${c}"
fi
diff --git a/collectors/cgroups.plugin/cgroup-network.c b/collectors/cgroups.plugin/cgroup-network.c
index 921b14dfb..562d30663 100644
--- a/collectors/cgroups.plugin/cgroup-network.c
+++ b/collectors/cgroups.plugin/cgroup-network.c
@@ -453,7 +453,7 @@ void detect_veth_interfaces(pid_t pid) {
if(!eligible_ifaces(host)) {
errno = 0;
- error("there are no double-linked host interfaces available.");
+ info("there are no double-linked host interfaces available.");
goto cleanup;
}
diff --git a/collectors/cgroups.plugin/sys_fs_cgroup.c b/collectors/cgroups.plugin/sys_fs_cgroup.c
index ceffffe92..eea4d9ae7 100644
--- a/collectors/cgroups.plugin/sys_fs_cgroup.c
+++ b/collectors/cgroups.plugin/sys_fs_cgroup.c
@@ -142,7 +142,7 @@ static enum cgroups_type cgroups_try_detect_version()
enum cgroups_systemd_setting systemd_setting;
int cgroups2_available = 0;
- // 1. check if cgroups2 availible on system at all
+ // 1. check if cgroups2 available on system at all
FILE *f = mypopen("grep cgroup /proc/filesystems", &command_pid);
if (!f) {
error("popen failed");
@@ -160,7 +160,20 @@ static enum cgroups_type cgroups_try_detect_version()
if(!cgroups2_available)
return CGROUPS_V1;
- // 2. check systemd compiletime setting
+#if defined CGROUP2_SUPER_MAGIC
+ // 2. check filesystem type for the default mountpoint
+ char filename[FILENAME_MAX + 1];
+ snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/sys/fs/cgroup");
+ struct statfs fsinfo;
+ if (!statfs(filename, &fsinfo)) {
+ if (fsinfo.f_type == CGROUP2_SUPER_MAGIC)
+ return CGROUPS_V2;
+ if (fsinfo.f_type == CGROUP_SUPER_MAGIC)
+ return CGROUPS_V1;
+ }
+#endif
+
+ // 3. check systemd compiletime setting
if ((systemd_setting = cgroups_detect_systemd("systemd --version")) == SYSTEMD_CGROUP_ERR)
systemd_setting = cgroups_detect_systemd(SYSTEMD_CMD_RHEL);
@@ -168,13 +181,13 @@ static enum cgroups_type cgroups_try_detect_version()
return CGROUPS_AUTODETECT_FAIL;
if(systemd_setting == SYSTEMD_CGROUP_LEGACY || systemd_setting == SYSTEMD_CGROUP_HYBRID) {
- // curently we prefer V1 if HYBRID is set as it seems to be more feature complete
+ // currently we prefer V1 if HYBRID is set as it seems to be more feature complete
// in the future we might want to continue here if SYSTEMD_CGROUP_HYBRID
// and go ahead with V2
return CGROUPS_V1;
}
- // 3. if we are unified as on Fedora (default cgroups2 only mode)
+ // 4. if we are unified as on Fedora (default cgroups2 only mode)
// check kernel command line flag that can override that setting
f = fopen("/proc/cmdline", "r");
if (!f) {
@@ -1300,6 +1313,12 @@ static inline char *cgroup_chart_id_strdupz(const char *s) {
char *r = strdupz(s);
netdata_fix_chart_id(r);
+ // dots are used to distinguish chart type and id in streaming, so we should replace them
+ for (char *d = r; *d; d++) {
+ if (*d == '.')
+ *d = '-';
+ }
+
return r;
}
@@ -1469,7 +1488,7 @@ static inline struct cgroup *cgroup_add(const char *id) {
}
if(user_configurable) {
- // allow the user to enable/disable this individualy
+ // allow the user to enable/disable this individually
char option[FILENAME_MAX + 1];
snprintfz(option, FILENAME_MAX, "enable cgroup %s", cg->chart_title);
cg->enabled = (char) config_get_boolean("plugin:cgroups", option, def);
@@ -3996,9 +4015,10 @@ static void cgroup_main_cleanup(void *ptr) {
uv_mutex_unlock(&discovery_thread.mutex);
}
+ info("waiting for discovery thread to finish...");
+
while (!discovery_thread.exited && max > 0) {
max -= step;
- info("waiting for discovery thread to finish...");
sleep_usec(step);
}
@@ -4077,7 +4097,7 @@ void *cgroups_main(void *ptr) {
, NULL
, "cgroups"
, NULL
- , "NetData CGroups Plugin CPU usage"
+ , "Netdata CGroups Plugin CPU usage"
, "milliseconds/s"
, PLUGIN_CGROUPS_NAME
, "stats"