Skip to content

Commit

Permalink
in_process_exporter_metrics: convert rss memory from pages to bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
Bettina Riedl committed Sep 25, 2024
1 parent c69a6df commit 09989e7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions plugins/in_process_exporter_metrics/pe.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ struct flb_pe {
struct flb_input_instance *ins; /* input instance */
struct mk_list *metrics; /* enabled metrics */
int enabled_flag; /* indicate enabled metrics */
long page_size; /* page size for converting number of pages to bytes */

/*
* Metrics Contexts
Expand Down
2 changes: 2 additions & 0 deletions plugins/in_process_exporter_metrics/pe_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ struct flb_pe *flb_pe_config_create(struct flb_input_instance *ins,
return NULL;
}

ctx->page_size = sysconf(_SC_PAGESIZE);

return ctx;
}

Expand Down
2 changes: 2 additions & 0 deletions plugins/in_process_exporter_metrics/pe_process.c
Original file line number Diff line number Diff line change
Expand Up @@ -1106,6 +1106,8 @@ static int process_update(struct flb_pe *ctx)
tmp = entry->str;
/* Collect the number of RSS per process */
if (pe_utils_str_to_uint64(tmp, &val) != -1) {
/* convert RSS memory in number of pages to bytes */
val = val * ctx->page_size;
cmt_gauge_set(ctx->memory_bytes, ts, val, 4, (char *[]){ name, pid_str, ppid_str, "rss" });
}

Expand Down

0 comments on commit 09989e7

Please sign in to comment.