diff options
Diffstat (limited to 'collectors/debugfs.plugin')
-rw-r--r-- | collectors/debugfs.plugin/debugfs_plugin.c | 3 | ||||
-rw-r--r-- | collectors/debugfs.plugin/debugfs_plugin.h | 1 | ||||
-rw-r--r-- | collectors/debugfs.plugin/debugfs_zswap.c | 28 | ||||
-rw-r--r-- | collectors/debugfs.plugin/metadata.yaml | 395 | ||||
-rw-r--r-- | collectors/debugfs.plugin/metrics.csv | 12 | ||||
-rw-r--r-- | collectors/debugfs.plugin/multi_metadata.yaml | 233 | ||||
-rw-r--r-- | collectors/debugfs.plugin/sys_devices_virtual_powercap.c | 217 |
7 files changed, 630 insertions, 259 deletions
diff --git a/collectors/debugfs.plugin/debugfs_plugin.c b/collectors/debugfs.plugin/debugfs_plugin.c index 1c5bf106..c189f908 100644 --- a/collectors/debugfs.plugin/debugfs_plugin.c +++ b/collectors/debugfs.plugin/debugfs_plugin.c @@ -20,6 +20,9 @@ static struct debugfs_module { .func = do_debugfs_extfrag}, { .name = "/sys/kernel/debug/zswap", .enabled = CONFIG_BOOLEAN_YES, .func = do_debugfs_zswap}, + // Linux powercap metrics is here because it needs privilege to read each RAPL zone + { .name = "/sys/devices/virtual/powercap", .enabled = CONFIG_BOOLEAN_YES, + .func = do_sys_devices_virtual_powercap}, // The terminator { .name = NULL, .enabled = CONFIG_BOOLEAN_NO, .func = NULL} diff --git a/collectors/debugfs.plugin/debugfs_plugin.h b/collectors/debugfs.plugin/debugfs_plugin.h index c53187d6..903e4a19 100644 --- a/collectors/debugfs.plugin/debugfs_plugin.h +++ b/collectors/debugfs.plugin/debugfs_plugin.h @@ -9,6 +9,7 @@ int do_debugfs_extfrag(int update_every, const char *name); int do_debugfs_zswap(int update_every, const char *name); +int do_sys_devices_virtual_powercap(int update_every, const char *name); void debugfs2lower(char *name); const char *debugfs_rrdset_type_name(RRDSET_TYPE chart_type); const char *debugfs_rrd_algorithm_name(RRD_ALGORITHM algorithm); diff --git a/collectors/debugfs.plugin/debugfs_zswap.c b/collectors/debugfs.plugin/debugfs_zswap.c index c8fc0f03..502a04f1 100644 --- a/collectors/debugfs.plugin/debugfs_zswap.c +++ b/collectors/debugfs.plugin/debugfs_zswap.c @@ -38,7 +38,7 @@ static struct netdata_zswap_metric zswap_calculated_metrics[] = { .charttype = RRDSET_TYPE_LINE, .enabled = CONFIG_BOOLEAN_YES, .chart_created = CONFIG_BOOLEAN_NO, - .prio = NETDATA_CHART_PRIO_SYSTEM_ZSWAP_COMPRESS_RATIO, + .prio = NETDATA_CHART_PRIO_MEM_ZSWAP_COMPRESS_RATIO, .divisor = 100, .convertv = NULL, .value = -1}, @@ -71,7 +71,7 @@ static struct netdata_zswap_metric zswap_independent_metrics[] = { .charttype = RRDSET_TYPE_AREA, .enabled = CONFIG_BOOLEAN_YES, .chart_created = CONFIG_BOOLEAN_NO, - .prio = NETDATA_CHART_PRIO_SYSTEM_ZSWAP_POOL_TOT_SIZE, + .prio = NETDATA_CHART_PRIO_MEM_ZSWAP_POOL_TOT_SIZE, .divisor = 1, .convertv = NULL, .value = -1}, @@ -84,7 +84,7 @@ static struct netdata_zswap_metric zswap_independent_metrics[] = { .charttype = RRDSET_TYPE_AREA, .enabled = CONFIG_BOOLEAN_YES, .chart_created = CONFIG_BOOLEAN_NO, - .prio = NETDATA_CHART_PRIO_SYSTEM_ZSWAP_STORED_PAGE, + .prio = NETDATA_CHART_PRIO_MEM_ZSWAP_STORED_PAGE, .divisor = 1, .convertv = pages_to_bytes, .value = -1}, @@ -97,7 +97,7 @@ static struct netdata_zswap_metric zswap_independent_metrics[] = { .charttype = RRDSET_TYPE_LINE, .enabled = CONFIG_BOOLEAN_YES, .chart_created = CONFIG_BOOLEAN_NO, - .prio = NETDATA_CHART_PRIO_SYSTEM_ZSWAP_POOL_LIM_HIT, + .prio = NETDATA_CHART_PRIO_MEM_ZSWAP_POOL_LIM_HIT, .divisor = 1, .convertv = NULL, .value = -1}, @@ -110,7 +110,7 @@ static struct netdata_zswap_metric zswap_independent_metrics[] = { .charttype = RRDSET_TYPE_AREA, .enabled = CONFIG_BOOLEAN_YES, .chart_created = CONFIG_BOOLEAN_NO, - .prio = NETDATA_CHART_PRIO_SYSTEM_ZSWAP_WRT_BACK_PAGES, + .prio = NETDATA_CHART_PRIO_MEM_ZSWAP_WRT_BACK_PAGES, .divisor = 1, .convertv = pages_to_bytes, .value = -1}, @@ -123,7 +123,7 @@ static struct netdata_zswap_metric zswap_independent_metrics[] = { .charttype = RRDSET_TYPE_AREA, .enabled = CONFIG_BOOLEAN_YES, .chart_created = CONFIG_BOOLEAN_NO, - .prio = NETDATA_CHART_PRIO_SYSTEM_ZSWAP_SAME_FILL_PAGE, + .prio = NETDATA_CHART_PRIO_MEM_ZSWAP_SAME_FILL_PAGE, .divisor = 1, .convertv = pages_to_bytes, .value = -1}, @@ -136,7 +136,7 @@ static struct netdata_zswap_metric zswap_independent_metrics[] = { .charttype = RRDSET_TYPE_LINE, .enabled = CONFIG_BOOLEAN_YES, .chart_created = CONFIG_BOOLEAN_NO, - .prio = NETDATA_CHART_PRIO_SYSTEM_ZSWAP_DUPP_ENTRY, + .prio = NETDATA_CHART_PRIO_MEM_ZSWAP_DUPP_ENTRY, .divisor = 1, .convertv = NULL, .value = -1}, @@ -175,7 +175,7 @@ static struct netdata_zswap_metric zswap_rejected_metrics[] = { .charttype = RRDSET_TYPE_STACKED, .enabled = CONFIG_BOOLEAN_YES, .chart_created = CONFIG_BOOLEAN_NO, - .prio = NETDATA_CHART_PRIO_SYSTEM_ZSWAP_REJECTS, + .prio = NETDATA_CHART_PRIO_MEM_ZSWAP_REJECTS, .divisor = 1, .convertv = NULL, .value = -1}, @@ -188,7 +188,7 @@ static struct netdata_zswap_metric zswap_rejected_metrics[] = { .charttype = RRDSET_TYPE_STACKED, .enabled = CONFIG_BOOLEAN_YES, .chart_created = CONFIG_BOOLEAN_NO, - .prio = NETDATA_CHART_PRIO_SYSTEM_ZSWAP_REJECTS, + .prio = NETDATA_CHART_PRIO_MEM_ZSWAP_REJECTS, .divisor = 1, .convertv = NULL, .value = -1}, @@ -201,7 +201,7 @@ static struct netdata_zswap_metric zswap_rejected_metrics[] = { .charttype = RRDSET_TYPE_STACKED, .enabled = CONFIG_BOOLEAN_YES, .chart_created = CONFIG_BOOLEAN_NO, - .prio = NETDATA_CHART_PRIO_SYSTEM_ZSWAP_REJECTS, + .prio = NETDATA_CHART_PRIO_MEM_ZSWAP_REJECTS, .divisor = 1, .convertv = NULL, .value = -1}, @@ -214,7 +214,7 @@ static struct netdata_zswap_metric zswap_rejected_metrics[] = { .charttype = RRDSET_TYPE_STACKED, .enabled = CONFIG_BOOLEAN_YES, .chart_created = CONFIG_BOOLEAN_NO, - .prio = NETDATA_CHART_PRIO_SYSTEM_ZSWAP_REJECTS, + .prio = NETDATA_CHART_PRIO_MEM_ZSWAP_REJECTS, .divisor = 1, .convertv = NULL, .value = -1}, @@ -227,7 +227,7 @@ static struct netdata_zswap_metric zswap_rejected_metrics[] = { .charttype = RRDSET_TYPE_STACKED, .enabled = CONFIG_BOOLEAN_YES, .chart_created = CONFIG_BOOLEAN_NO, - .prio = NETDATA_CHART_PRIO_SYSTEM_ZSWAP_REJECTS, + .prio = NETDATA_CHART_PRIO_MEM_ZSWAP_REJECTS, .divisor = 1, .convertv = NULL, .value = -1}, @@ -266,7 +266,7 @@ zswap_send_chart(struct netdata_zswap_metric *metric, int update_every, const ch { fprintf( stdout, - "CHART system.zswap_%s '' '%s' '%s' 'zswap' '' '%s' %d %d '%s' 'debugfs.plugin' '%s'\n", + "CHART mem.zswap_%s '' '%s' '%s' 'zswap' '' '%s' %d %d '%s' 'debugfs.plugin' '%s'\n", metric->chart_id, metric->title, metric->units, @@ -291,7 +291,7 @@ static void zswap_send_dimension(struct netdata_zswap_metric *metric) static void zswap_send_begin(struct netdata_zswap_metric *metric) { - fprintf(stdout, "BEGIN system.zswap_%s\n", metric->chart_id); + fprintf(stdout, "BEGIN mem.zswap_%s\n", metric->chart_id); } static void zswap_send_set(struct netdata_zswap_metric *metric) diff --git a/collectors/debugfs.plugin/metadata.yaml b/collectors/debugfs.plugin/metadata.yaml new file mode 100644 index 00000000..d3bf0a0d --- /dev/null +++ b/collectors/debugfs.plugin/metadata.yaml @@ -0,0 +1,395 @@ +plugin_name: debugfs.plugin +modules: + - meta: + plugin_name: debugfs.plugin + module_name: /sys/kernel/debug/extfrag + monitored_instance: + name: System Memory Fragmentation + link: 'https://www.kernel.org/doc/html/next/admin-guide/sysctl/vm.html' + categories: + - data-collection.linux-systems.memory-metrics + icon_filename: 'microchip.svg' + related_resources: + integrations: + list: [] + info_provided_to_referring_integrations: + description: '' + keywords: + - extfrag + - extfrag_threshold + - memory fragmentation + most_popular: false + overview: + data_collection: + metrics_description: 'Collects memory fragmentation statistics from the Linux kernel' + method_description: 'Parse data from `debugfs` file' + supported_platforms: + include: + - Linux + exclude: [] + multi_instance: false + additional_permissions: + description: > + This integration requires read access to files under `/sys/kernel/debug/extfrag`, which are accessible + only to the root user by default. Netdata uses Linux Capabilities to give the plugin access to + debugfs. `CAP_DAC_READ_SEARCH` is added automatically during installation. This capability allows bypassing + file read permission checks and directory read and execute permission checks. If file capabilities are not + usable, then the plugin is instead installed with the SUID bit set in permissions so that it runs as root. + default_behavior: + auto_detection: + description: > + Assuming that debugfs is mounted and the required permissions are available, this integration will + automatically run by default. + limits: + description: '' + performance_impact: + description: '' + setup: + prerequisites: + list: + - title: 'filesystem' + description: > + The debugfs filesystem must be mounted on your host for plugin to collect data. + You can run the command-line (`sudo mount -t debugfs none /sys/kernel/debug/`) to mount it locally. + It is also recommended to modify your fstab (5) avoiding necessity to mount the filesystem + before starting netdata. + configuration: + file: + name: 'netdata.conf' + section_name: '[plugin:debugfs]' + description: 'This is netdata main configuration file.' + options: + description: '' + folding: + title: 'Config options' + enabled: true + list: + - name: update every + description: Data collection frequency. + default_value: 1 + required: false + - name: command options + description: Additinal parameters for collector + default_value: "" + required: false + examples: + folding: + enabled: true + title: '' + list: [] + troubleshooting: + problems: + list: [] + alerts: [] + metrics: + folding: + title: Metrics + enabled: false + description: "Monitor the overall memory fragmentation of the system." + availability: [] + scopes: + - name: node + description: "Memory fragmentation statistics for each NUMA node in the system." + labels: + - name: numa_node + description: The NUMA node the metrics are associated with. + metrics: + - name: mem.fragmentation_index_dma + description: Memory fragmentation index for each order + unit: "index" + chart_type: line + dimensions: + - name: order0 + - name: order1 + - name: order2 + - name: order3 + - name: order4 + - name: order5 + - name: order6 + - name: order7 + - name: order8 + - name: order9 + - name: order10 + - name: mem.fragmentation_index_dma32 + description: Memory fragmentation index for each order + unit: "index" + chart_type: line + dimensions: + - name: order0 + - name: order1 + - name: order2 + - name: order3 + - name: order4 + - name: order5 + - name: order6 + - name: order7 + - name: order8 + - name: order9 + - name: order10 + - name: mem.fragmentation_index_normal + description: Memory fragmentation index for each order + unit: "index" + chart_type: line + dimensions: + - name: order0 + - name: order1 + - name: order2 + - name: order3 + - name: order4 + - name: order5 + - name: order6 + - name: order7 + - name: order8 + - name: order9 + - name: order10 + - meta: + plugin_name: debugfs.plugin + module_name: /sys/kernel/debug/zswap + monitored_instance: + name: Linux ZSwap + link: 'https://www.kernel.org/doc/html/latest/admin-guide/mm/zswap.html' + categories: + - data-collection.linux-systems.memory-metrics + icon_filename: 'microchip.svg' + related_resources: + integrations: + list: [] + info_provided_to_referring_integrations: + description: '' + keywords: + - swap + - zswap + - frontswap + - swap cache + most_popular: false + overview: + data_collection: + metrics_description: > + Collects zswap performance metrics on Linux systems. + method_description: 'Parse data from `debugfs file.' + supported_platforms: + include: + - Linux + exclude: [] + multi_instance: false + additional_permissions: + description: > + This integration requires read access to files under `/sys/kernel/debug/zswap`, which are accessible + only to the root user by default. Netdata uses Linux Capabilities to give the plugin access to + debugfs. `CAP_DAC_READ_SEARCH` is added automatically during installation. This capability allows bypassing + file read permission checks and directory read and execute permission checks. If file capabilities are not + usable, then the plugin is instead installed with the SUID bit set in permissions so that it runs as root. + default_behavior: + auto_detection: + description: > + Assuming that debugfs is mounted and the required permissions are available, this integration will + automatically detect whether or not the system is using zswap. + limits: + description: '' + performance_impact: + description: '' + setup: + prerequisites: + list: + - title: 'filesystem' + description: > + The debugfs filesystem must be mounted on your host for plugin to collect data. + You can run the command-line (`sudo mount -t debugfs none /sys/kernel/debug/`) to mount it locally. + It is also recommended to modify your fstab (5) avoiding necessity to mount the filesystem + before starting netdata. + configuration: + file: + name: 'netdata.conf' + section_name: '[plugin:debugfs]' + description: 'This is netdata main configuration file.' + options: + description: '' + folding: + title: 'Config options' + enabled: true + list: + - name: update every + description: Data collection frequency. + default_value: 1 + required: false + - name: command options + description: Additinal parameters for collector + default_value: "" + required: false + examples: + folding: + enabled: true + title: '' + list: [] + troubleshooting: + problems: + list: [] + alerts: [] + metrics: + folding: + title: Metrics + enabled: false + description: "Monitor the performance statistics of zswap." + availability: [] + scopes: + - name: global + description: "Global zswap performance metrics." + labels: [] + metrics: + - name: system.zswap_pool_compression_ratio + description: Zswap compression ratio + unit: "ratio" + chart_type: line + dimensions: + - name: compression_ratio + - name: system.zswap_pool_compressed_size + description: Zswap compressed bytes currently stored + unit: "bytes" + chart_type: area + dimensions: + - name: compressed_size + - name: system.zswap_pool_raw_size + description: Zswap uncompressed bytes currently stored + unit: "bytes" + chart_type: area + dimensions: + - name: uncompressed_size + - name: system.zswap_rejections + description: Zswap rejections + unit: "rejections/s" + chart_type: stacked + dimensions: + - name: compress_poor + - name: kmemcache_fail + - name: alloc_fail + - name: reclaim_fail + - name: system.zswap_pool_limit_hit + description: Zswap pool limit was reached + unit: "events/s" + chart_type: line + dimensions: + - name: limit + - name: system.zswap_written_back_raw_bytes + description: Zswap uncomressed bytes written back when pool limit was reached + unit: "bytes/s" + chart_type: area + dimensions: + - name: written_back + - name: system.zswap_same_filled_raw_size + description: Zswap same-value filled uncompressed bytes currently stored + unit: "bytes" + chart_type: area + dimensions: + - name: same_filled + - name: system.zswap_duplicate_entry + description: Zswap duplicate store was encountered + unit: "entries/s" + chart_type: line + dimensions: + - name: duplicate + - meta: + plugin_name: debugfs.plugin + module_name: intel_rapl + monitored_instance: + name: Power Capping + link: 'https://www.kernel.org/doc/html/next/power/powercap/powercap.html' + categories: + - data-collection.linux-systems.kernel-metrics + icon_filename: 'powersupply.svg' + related_resources: + integrations: + list: [] + info_provided_to_referring_integrations: + description: '' + keywords: + - power capping + - energy + most_popular: false + overview: + data_collection: + metrics_description: > + Collects power capping performance metrics on Linux systems. + method_description: 'Parse data from `debugfs file.' + supported_platforms: + include: + - Linux + exclude: [] + multi_instance: false + additional_permissions: + description: > + This integration requires read access to files under `/sys/devices/virtual/powercap`, which are accessible + only to the root user by default. Netdata uses Linux Capabilities to give the plugin access to + debugfs. `CAP_DAC_READ_SEARCH` is added automatically during installation. This capability allows bypassing + file read permission checks and directory read and execute permission checks. If file capabilities are not + usable, then the plugin is instead installed with the SUID bit set in permissions so that it runs as root. + default_behavior: + auto_detection: + description: > + Assuming that debugfs is mounted and the required permissions are available, this integration will + automatically detect whether or not the system is using zswap. + limits: + description: '' + performance_impact: + description: '' + setup: + prerequisites: + list: + - title: 'filesystem' + description: > + The debugfs filesystem must be mounted on your host for plugin to collect data. + You can run the command-line (`sudo mount -t debugfs none /sys/kernel/debug/`) to mount it locally. + It is also recommended to modify your fstab (5) avoiding necessity to mount the filesystem + before starting netdata. + configuration: + file: + name: 'netdata.conf' + section_name: '[plugin:debugfs]' + description: 'This is netdata main configuration file.' + options: + description: '' + folding: + title: 'Config options' + enabled: true + list: + - name: update every + description: Data collection frequency. + default_value: 1 + required: false + - name: command options + description: Additinal parameters for collector + default_value: "" + required: false + examples: + folding: + enabled: true + title: '' + list: [] + troubleshooting: + problems: + list: [] + alerts: [] + metrics: + folding: + title: Metrics + enabled: false + description: "Monitor the Intel RAPL zones Consumption." + availability: [] + scopes: + - name: global + description: "Global Intel RAPL zones." + labels: [] + metrics: + - name: cpu.powercap_intel_rapl_zone + description: Intel RAPL Zone Power Consumption + unit: "Watts" + chart_type: line + dimensions: + - name: Power + - name: cpu.powercap_intel_rapl_subzones + description: Intel RAPL Subzones Power Consumption + unit: "Watts" + chart_type: line + dimensions: + - name: dram + - name: core + - name: uncore diff --git a/collectors/debugfs.plugin/metrics.csv b/collectors/debugfs.plugin/metrics.csv deleted file mode 100644 index a2138394..00000000 --- a/collectors/debugfs.plugin/metrics.csv +++ /dev/null @@ -1,12 +0,0 @@ -metric,scode,dimensions,unit,description,chart_type,labels,plugin,module -mem.fragmentation_index_dma,node,"order0, order1, order2, order3, order4, order5, order6, order7, order8, order9, order10",index,Memory fragmentation index for each order,line,numa_node,debugfs.plugin,/sys/kernel/debug/extfrag -mem.fragmentation_index_dma32,node,"order0, order1, order2, order3, order4, order5, order6, order7, order8, order9, order10",index,Memory fragmentation index for each order,line,numa_node,debugfs.plugin,/sys/kernel/debug/extfrag -mem.fragmentation_index_normal,node,"order0, order1, order2, order3, order4, order5, order6, order7, order8, order9, order10",index,Memory fragmentation index for each order,line,numa_node,debugfs.plugin,/sys/kernel/debug/extfrag -system.zswap_pool_compression_ratio,,compression_ratio,ratio,Zswap compression ratio,line,,debugfs.plugin,/sys/kernel/debug/zswap -system.zswap_pool_compressed_size,,compressed_size,bytes,Zswap compressed bytes currently stored,area,,debugfs.plugin,/sys/kernel/debug/zswap -system.zswap_pool_raw_size,,uncompressed_size,bytes,Zswap uncompressed bytes currently stored,area,,debugfs.plugin,/sys/kernel/debug/zswap -system.zswap_rejections,,"compress_poor, kmemcache_fail, alloc_fail, reclaim_fail",rejections/s,Zswap rejections,stacked,,debugfs.plugin,/sys/kernel/debug/zswap -system.zswap_pool_limit_hit,,limit,events/s,Zswap pool limit was reached,line,,debugfs.plugin,/sys/kernel/debug/zswap -system.zswap_written_back_raw_bytes,,written_back,bytes/s,Zswap uncomressed bytes written back when pool limit was reached,area,,debugfs.plugin,/sys/kernel/debug/zswap -system.zswap_same_filled_raw_size,,same_filled,bytes,Zswap same-value filled uncompressed bytes currently stored,area,,debugfs.plugin,/sys/kernel/debug/zswap -system.zswap_duplicate_entry,,duplicate,entries/s,Zswap duplicate store was encountered,line,,debugfs.plugin,/sys/kernel/debug/zswap diff --git a/collectors/debugfs.plugin/multi_metadata.yaml b/collectors/debugfs.plugin/multi_metadata.yaml deleted file mode 100644 index 652aff7a..00000000 --- a/collectors/debugfs.plugin/multi_metadata.yaml +++ /dev/null @@ -1,233 +0,0 @@ -name: debugfs.plugin -modules: - - meta: - plugin_name: debugfs.plugin - module_name: /sys/kernel/debug/extfrag - monitored_instance: - name: debugfs /sys/kernel/debug/extfrag - link: '' - categories: [] - icon_filename: '' - related_resources: - integrations: - list: [] - info_provided_to_referring_integrations: - description: '' - keywords: [] - most_popular: false - overview: - data_collection: - metrics_description: '' - method_description: '' - supported_platforms: - include: [] - exclude: [] - multi-instance: true - additional_permissions: - description: '' - default_behavior: - auto_detection: - description: '' - limits: - description: '' - performance_impact: - description: '' - setup: - prerequisites: - list: [] - configuration: - file: - name: '' - description: '' - options: - description: '' - folding: - title: '' - enabled: true - list: [] - examples: - folding: - enabled: true - title: '' - list: [] - troubleshooting: - problems: - list: [] - alerts: [] - metrics: - folding: - title: Metrics - enabled: false - description: "" - availability: [] - scopes: - - name: node - description: "" - labels: - - name: numa_node - description: TBD - metrics: - - name: mem.fragmentation_index_dma - description: Memory fragmentation index for each order - unit: "index" - chart_type: line - dimensions: - - name: order0 - - name: order1 - - name: order2 - - name: order3 - - name: order4 - - name: order5 - - name: order6 - - name: order7 - - name: order8 - - name: order9 - - name: order10 - - name: mem.fragmentation_index_dma32 - description: Memory fragmentation index for each order - unit: "index" - chart_type: line - dimensions: - - name: order0 - - name: order1 - - name: order2 - - name: order3 - - name: order4 - - name: order5 - - name: order6 - - name: order7 - - name: order8 - - name: order9 - - name: order10 - - name: mem.fragmentation_index_normal - description: Memory fragmentation index for each order - unit: "index" - chart_type: line - dimensions: - - name: order0 - - name: order1 - - name: order2 - - name: order3 - - name: order4 - - name: order5 - - name: order6 - - name: order7 - - name: order8 - - name: order9 - - name: order10 - - meta: - plugin_name: debugfs.plugin - module_name: /sys/kernel/debug/zswap - monitored_instance: - name: debugfs /sys/kernel/debug/zswap - link: '' - categories: [] - icon_filename: '' - related_resources: - integrations: - list: [] - info_provided_to_referring_integrations: - description: '' - keywords: [] - most_popular: false - overview: - data_collection: - metrics_description: '' - method_description: '' - supported_platforms: - include: [] - exclude: [] - multi-instance: true - additional_permissions: - description: '' - default_behavior: - auto_detection: - description: '' - limits: - description: '' - performance_impact: - description: '' - setup: - prerequisites: - list: [] - configuration: - file: - name: '' - description: '' - options: - description: '' - folding: - title: '' - enabled: true - list: [] - examples: - folding: - enabled: true - title: '' - list: [] - troubleshooting: - problems: - list: [] - alerts: [] - metrics: - folding: - title: Metrics - enabled: false - description: "" - availability: [] - scopes: - - name: global - description: "" - labels: [] - metrics: - - name: system.zswap_pool_compression_ratio - description: Zswap compression ratio - unit: "ratio" - chart_type: line - dimensions: - - name: compression_ratio - - name: system.zswap_pool_compressed_size - description: Zswap compressed bytes currently stored - unit: "bytes" - chart_type: area - dimensions: - - name: compressed_size - - name: system.zswap_pool_raw_size - description: Zswap uncompressed bytes currently stored - unit: "bytes" - chart_type: area - dimensions: - - name: uncompressed_size - - name: system.zswap_rejections - description: Zswap rejections - unit: "rejections/s" - chart_type: stacked - dimensions: - - name: compress_poor - - name: kmemcache_fail - - name: alloc_fail - - name: reclaim_fail - - name: system.zswap_pool_limit_hit - description: Zswap pool limit was reached - unit: "events/s" - chart_type: line - dimensions: - - name: limit - - name: system.zswap_written_back_raw_bytes - description: Zswap uncomressed bytes written back when pool limit was reached - unit: "bytes/s" - chart_type: area - dimensions: - - name: written_back - - name: system.zswap_same_filled_raw_size - description: Zswap same-value filled uncompressed bytes currently stored - unit: "bytes" - chart_type: area - dimensions: - - name: same_filled - - name: system.zswap_duplicate_entry - description: Zswap duplicate store was encountered - unit: "entries/s" - chart_type: line - dimensions: - - name: duplicate diff --git a/collectors/debugfs.plugin/sys_devices_virtual_powercap.c b/collectors/debugfs.plugin/sys_devices_virtual_powercap.c new file mode 100644 index 00000000..5f22b19e --- /dev/null +++ b/collectors/debugfs.plugin/sys_devices_virtual_powercap.c @@ -0,0 +1,217 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +#include "debugfs_plugin.h" + +struct zone_t { + char *zone_chart_id; + char *subzone_chart_id; + char *name; + char *path; + + unsigned long long max_energy_range_uj; + unsigned long long energy_uj; + + struct zone_t *subzones; + + struct zone_t *prev, *next; +}; + +static struct zone_t *rapl_zones = NULL; + +static bool get_measurement(const char *path, unsigned long long *energy_uj) { + return read_single_number_file(path, energy_uj) == 0; +} + +static struct zone_t *get_rapl_zone(const char *control_type __maybe_unused, struct zone_t *parent __maybe_unused, const char *dirname) { + char temp[FILENAME_MAX + 1]; + snprintfz(temp, FILENAME_MAX, "%s/%s", dirname, "name"); + + char name[FILENAME_MAX + 1] = ""; + if (read_file(temp, name, sizeof(name) - 1) != 0) + return NULL; + + char *trimmed = trim(name); + if (unlikely(trimmed == NULL || trimmed[0] == 0)) + return NULL; + + snprintfz(temp, FILENAME_MAX, "%s/%s", dirname, "max_energy_range_uj"); + unsigned long long max_energy_range_uj = 0; + if (unlikely(read_single_number_file(temp, &max_energy_range_uj) != 0)) { + collector_error("Cannot read %s", temp); + return NULL; + } + + snprintfz(temp, FILENAME_MAX, "%s/%s", dirname, "energy_uj"); + unsigned long long energy_uj; + if (unlikely(!get_measurement(temp, &energy_uj))) { + collector_info("%s: Cannot read %s", trimmed, temp); + return NULL; + } + + struct zone_t *zone = callocz(1, sizeof(*zone)); + + zone->name = strdupz(trimmed); + zone->path = strdupz(temp); + + zone->max_energy_range_uj = max_energy_range_uj; + zone->energy_uj = energy_uj; + + collector_info("Found zone: \"%s\"", zone->name); + + return zone; +} + +static struct zone_t *look_for_rapl_zones(const char *control_type, struct zone_t *parent, const char *path, int depth) { + if(depth > 2) + return NULL; + + struct zone_t *base = NULL; + + DIR *dir = opendir(path); + if (unlikely(dir == NULL)) + return NULL; + + struct dirent *de = NULL; + while ((de = readdir(dir))) { + if (de->d_type != DT_DIR || de->d_name[0] == '.') + continue; + + if(strncmp(de->d_name, "intel-rapl:", 11) != 0) + continue; + + char zone_path[FILENAME_MAX + 1]; + snprintfz(zone_path, FILENAME_MAX, "%s/%s", path, de->d_name); + + struct zone_t *zone = get_rapl_zone(control_type, parent, zone_path); + if(zone) { + DOUBLE_LINKED_LIST_APPEND_ITEM_UNSAFE(base, zone, prev, next); + + if(!parent) + zone->subzones = look_for_rapl_zones(control_type, zone, zone_path, depth + 1); + } + } + + closedir(dir); + return base; +} + +static struct zone_t *get_main_rapl_zones(void) { + struct zone_t *base = NULL; + + char dirname[FILENAME_MAX + 1]; + snprintfz(dirname, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/sys/devices/virtual/powercap"); + + DIR *dir = opendir(dirname); + if (unlikely(dir == NULL)) + return 0; + + struct dirent *de = NULL; + while ((de = readdir(dir))) { + if (de->d_type != DT_DIR || de->d_name[0] == '.') + continue; + + if(strncmp(de->d_name, "intel-rapl", 10) != 0) + continue; + + char control_type_path[FILENAME_MAX + 1]; + snprintfz(control_type_path, FILENAME_MAX, "%s/%s", dirname, de->d_name); + + collector_info("Looking at control type \"%s\"", de->d_name); + struct zone_t *zone = look_for_rapl_zones(de->d_name, NULL, control_type_path, 0); + if(zone) + DOUBLE_LINKED_LIST_APPEND_LIST_UNSAFE(base, zone, prev, next); + } + closedir(dir); + + return base; +} + +int do_sys_devices_virtual_powercap(int update_every, const char *name __maybe_unused) { + + if (unlikely(!rapl_zones)) { + rapl_zones = get_main_rapl_zones(); + if (unlikely(!rapl_zones)) { + collector_info("Failed to find powercap zones."); + return 1; + } + } + + for(struct zone_t *zone = rapl_zones; zone ; zone = zone->next) { + if(!zone->zone_chart_id) { + char id[1000 + 1]; + snprintf(id, 1000, "cpu.powercap_intel_rapl_zone_%s", zone->name); + zone->zone_chart_id = strdupz(id); + + fprintf(stdout, + "CHART '%s' '' 'Intel RAPL Zone Power Consumption' 'Watts' 'powercap' '%s' '%s' %d %d '' 'debugfs.plugin' 'intel_rapl'\n", + zone->zone_chart_id, + "cpu.powercap_intel_rapl_zone", + debugfs_rrdset_type_name(RRDSET_TYPE_LINE), + NETDATA_CHART_PRIO_POWERCAP, + update_every); + + fprintf(stdout, + "CLABEL 'zone' '%s' 0\n" + "CLABEL_COMMIT\n", + zone->name); + + fprintf(stdout, + "DIMENSION 'power' '' %s 1 1000000 ''\n", + debugfs_rrd_algorithm_name(RRD_ALGORITHM_INCREMENTAL)); + + // for the sub-zones + snprintf(id, 1000, "cpu.powercap_intel_rapl_subzones_%s", zone->name); + zone->subzone_chart_id = strdupz(id); + fprintf(stdout, + "CHART '%s' '' 'Intel RAPL Subzones Power Consumption' 'Watts' 'powercap' '%s' '%s' %d %d '' 'debugfs.plugin' 'intel_rapl'\n", + zone->subzone_chart_id, + "cpu.powercap_intel_rapl_subzones", + debugfs_rrdset_type_name(RRDSET_TYPE_LINE), + NETDATA_CHART_PRIO_POWERCAP + 1, + update_every); + + fprintf(stdout, + "CLABEL 'zone' '%s' 0\n" + "CLABEL_COMMIT\n", + zone->name); + + for(struct zone_t *subzone = zone->subzones; subzone ; subzone = subzone->next) { + fprintf(stdout, + "DIMENSION '%s' '' %s 1 1000000 ''\n", + subzone->name, + debugfs_rrd_algorithm_name(RRD_ALGORITHM_INCREMENTAL)); + } + } + + if(get_measurement(zone->path, &zone->energy_uj)) { + fprintf(stdout, + "BEGIN '%s'\n" + "SET power = %lld\n" + "END\n" + , zone->zone_chart_id + , zone->energy_uj); + } + + if(zone->subzones) { + fprintf(stdout, + "BEGIN '%s'\n", + zone->subzone_chart_id); + + for (struct zone_t *subzone = zone->subzones; subzone; subzone = subzone->next) { + if(get_measurement(subzone->path, &subzone->energy_uj)) { + fprintf(stdout, + "SET '%s' = %lld\n", + subzone->name, + subzone->energy_uj); + } + } + + fprintf(stdout, "END\n"); + } + + } + + fflush(stdout); + + return 0; +} |