summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6240127)
raw | patch | inline | side by side (parent: 6240127)
author | Florian Forster <octo@collectd.org> | |
Mon, 5 Sep 2016 09:56:04 +0000 (11:56 +0200) | ||
committer | Florian Forster <octo@collectd.org> | |
Wed, 14 Sep 2016 18:36:46 +0000 (20:36 +0200) |
src/hugepages.c | patch | blob | history |
diff --git a/src/hugepages.c b/src/hugepages.c
index 9fa535f019ba005be1fbad1b48e41563f83e9823..d129cbfead98b023bd64d55ea968ba93ae2679d7 100644 (file)
--- a/src/hugepages.c
+++ b/src/hugepages.c
struct entry_info {
char *d_name;
const char *node;
+ size_t page_size_kb;
gauge_t nr;
gauge_t surplus;
static int read_hugepage_entry(const char *path, const char *entry,
void *e_info) {
char path2[PATH_MAX];
- static const char partial_type_inst[] = "free_used";
char type_instance[PATH_MAX];
- char *strin;
struct entry_info *info = e_info;
double value;
return 0;
}
- /* Can now submit "used" and "free" values.
- * 0x2D is the ASCII "-" character, after which the string
- * contains "<size>kB"
- * The string passed as param 3 to submit_hp is of the format:
- * <type>-<partial_type_inst>-<size>kB
- */
- assert(strncmp(info->d_name, "hugepages-", strlen("hugepages-")) == 0);
- strin = info->d_name += strlen("hugepages-");
-
- ssnprintf(type_instance, sizeof(type_instance), "%s-%s", partial_type_inst,
- strin);
+ ssnprintf(type_instance, sizeof(type_instance), "free_used-%zukB",
+ info->page_size_kb);
submit_hp(info->node, type_instance, info->free,
(info->nr + info->surplus) - info->free);
continue;
}
+ long page_size = strtol(result->d_name + strlen(hugepages_dir),
+ /* endptr = */ NULL, /* base = */ 10);
+ if (errno != 0) {
+ char errbuf[1024];
+ ERROR("%s: failed to determine page size from directory name \"%s\": %s",
+ g_plugin_name, result->d_name,
+ sstrerror(errno, errbuf, sizeof(errbuf)));
+ continue;
+ }
+
/* /sys/devices/system/node/node?/hugepages/ */
ssnprintf(path2, sizeof(path2), "%s/%s", path, result->d_name);
walk_directory(path2, read_hugepage_entry,
&(struct entry_info){
- .d_name = result->d_name, .node = node,
+ .d_name = result->d_name,
+ .node = node,
+ .page_size_kb = (size_t)page_size,
},
/* hidden = */ 0);
errno = 0;