sys_fs_cgroup.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // SPDX-License-Identifier: GPL-3.0-or-later
  2. #ifndef NETDATA_SYS_FS_CGROUP_H
  3. #define NETDATA_SYS_FS_CGROUP_H 1
  4. #include "daemon/common.h"
  5. #if (TARGET_OS == OS_LINUX)
  6. #define NETDATA_PLUGIN_HOOK_LINUX_CGROUPS \
  7. { \
  8. .name = "PLUGIN[cgroups]", \
  9. .config_section = CONFIG_SECTION_PLUGINS, \
  10. .config_name = "cgroups", \
  11. .enabled = 1, \
  12. .thread = NULL, \
  13. .init_routine = NULL, \
  14. .start_routine = cgroups_main \
  15. },
  16. extern void *cgroups_main(void *ptr);
  17. #define CGROUP_OPTIONS_DISABLED_DUPLICATE 0x00000001
  18. #define CGROUP_OPTIONS_SYSTEM_SLICE_SERVICE 0x00000002
  19. #define CGROUP_OPTIONS_IS_UNIFIED 0x00000004
  20. typedef struct netdata_ebpf_cgroup_shm_header {
  21. int cgroup_root_count;
  22. int cgroup_max;
  23. int systemd_enabled;
  24. size_t body_length;
  25. } netdata_ebpf_cgroup_shm_header_t;
  26. #define CGROUP_EBPF_NAME_SHARED_LENGTH 256
  27. typedef struct netdata_ebpf_cgroup_shm_body {
  28. // Considering what is exposed in this link https://en.wikipedia.org/wiki/Comparison_of_file_systems#Limits
  29. // this length is enough to store what we want.
  30. char name[CGROUP_EBPF_NAME_SHARED_LENGTH];
  31. uint32_t hash;
  32. uint32_t options;
  33. int enabled;
  34. char path[FILENAME_MAX + 1];
  35. } netdata_ebpf_cgroup_shm_body_t;
  36. typedef struct netdata_ebpf_cgroup_shm {
  37. netdata_ebpf_cgroup_shm_header_t *header;
  38. netdata_ebpf_cgroup_shm_body_t *body;
  39. } netdata_ebpf_cgroup_shm_t;
  40. #define NETDATA_SHARED_MEMORY_EBPF_CGROUP_NAME "netdata_shm_cgroup_ebpf"
  41. #define NETDATA_NAMED_SEMAPHORE_EBPF_CGROUP_NAME "/netdata_sem_cgroup_ebpf"
  42. #include "../proc.plugin/plugin_proc.h"
  43. #else // (TARGET_OS == OS_LINUX)
  44. #define NETDATA_PLUGIN_HOOK_LINUX_CGROUPS
  45. #endif // (TARGET_OS == OS_LINUX)
  46. extern char *parse_k8s_data(struct label **labels, char *data);
  47. #endif //NETDATA_SYS_FS_CGROUP_H