summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorIlya Mashchenko <ilya@netdata.cloud>2024-06-14 19:52:23 +0300
committerGitHub <noreply@github.com>2024-06-14 19:52:23 +0300
commite32c498941d5d92b4695626e805c84802c018038 (patch)
treed152929602f66e2525f6142501ccd1e5b0eb8dc4 /src
parent3c507b4edb796f5a5cc7c6bcabfd9142494977cd (diff)
sys_block_zram: don't use "/dev" (#17900)
sys_block_zram: don't use /dev
Diffstat (limited to 'src')
-rw-r--r--src/collectors/proc.plugin/sys_block_zram.c45
1 files changed, 20 insertions, 25 deletions
diff --git a/src/collectors/proc.plugin/sys_block_zram.c b/src/collectors/proc.plugin/sys_block_zram.c
index dac7cac0f4..81eb7be916 100644
--- a/src/collectors/proc.plugin/sys_block_zram.c
+++ b/src/collectors/proc.plugin/sys_block_zram.c
@@ -62,7 +62,7 @@ static inline void init_rrd(const char *name, ZRAM_DEVICE *d, int update_every)
"mem"
, chart_name
, chart_name
- , name
+ , "zram"
, "mem.zram_usage"
, "ZRAM Memory Usage"
, "MiB"
@@ -80,7 +80,7 @@ static inline void init_rrd(const char *name, ZRAM_DEVICE *d, int update_every)
"mem"
, chart_name
, chart_name
- , name
+ , "zram"
, "mem.zram_savings"
, "ZRAM Memory Savings"
, "MiB"
@@ -98,7 +98,7 @@ static inline void init_rrd(const char *name, ZRAM_DEVICE *d, int update_every)
"mem"
, chart_name
, chart_name
- , name
+ , "zram"
, "mem.zram_ratio"
, "ZRAM Compression Ratio (original to compressed)"
, "ratio"
@@ -115,7 +115,7 @@ static inline void init_rrd(const char *name, ZRAM_DEVICE *d, int update_every)
"mem"
, chart_name
, chart_name
- , name
+ , "zram"
, "mem.zram_efficiency"
, "ZRAM Efficiency"
, "percentage"
@@ -136,36 +136,31 @@ static int init_devices(DICTIONARY *devices, unsigned int zram_id, int update_ev
ZRAM_DEVICE device;
char filename[FILENAME_MAX + 1];
- snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/dev");
+ snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/sys/block");
DIR *dir = opendir(filename);
if (unlikely(!dir))
return 0;
- while ((de = readdir(dir)))
- {
- snprintfz(filename, FILENAME_MAX, "%s/dev/%s", netdata_configured_host_prefix, de->d_name);
- if (unlikely(stat(filename, &st) != 0))
- {
- collector_error("ZRAM : Unable to stat %s: %s", filename, strerror(errno));
+
+ while ((de = readdir(dir))) {
+ snprintfz(filename, FILENAME_MAX, "%s/sys/block/%s/mm_stat", netdata_configured_host_prefix, de->d_name);
+ if (unlikely(stat(filename, &st) != 0)) {
continue;
}
- if (major(st.st_rdev) == zram_id)
- {
- collector_info("ZRAM : Found device %s", filename);
- snprintfz(filename, FILENAME_MAX, "%s/sys/block/%s/mm_stat", netdata_configured_host_prefix, de->d_name);
- ff = procfile_open(filename, " \t:", PROCFILE_FLAG_DEFAULT);
- if (ff == NULL)
- {
- collector_error("ZRAM : Failed to open %s: %s", filename, strerror(errno));
- continue;
- }
- device.file = ff;
- init_rrd(de->d_name, &device, update_every);
- dictionary_set(devices, de->d_name, &device, sizeof(ZRAM_DEVICE));
- count++;
+ ff = procfile_open(filename, " \t:", PROCFILE_FLAG_DEFAULT);
+ if (ff == NULL) {
+ collector_error("ZRAM : Failed to open %s: %s", filename, strerror(errno));
+ continue;
}
+
+ device.file = ff;
+ init_rrd(de->d_name, &device, update_every);
+ dictionary_set(devices, de->d_name, &device, sizeof(ZRAM_DEVICE));
+ count++;
}
+
closedir(dir);
+
return count;
}