MCPcopy Create free account
hub / github.com/corosync/corosync / percent_mem_used_get

Function percent_mem_used_get

exec/mon.c:322–344  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

320}
321
322static int32_t percent_mem_used_get(void)
323{
324 sg_mem_stats *mem_stats;
325 sg_swap_stats *swap_stats;
326 long long total, freemem;
327
328#ifdef HAVE_LIBSTATGRAB_GE_090
329 mem_stats = sg_get_mem_stats(NULL);
330 swap_stats = sg_get_swap_stats(NULL);
331#else
332 mem_stats = sg_get_mem_stats();
333 swap_stats = sg_get_swap_stats();
334#endif
335
336 if (mem_stats == NULL || swap_stats == NULL) {
337 log_printf (LOGSYS_LEVEL_ERROR, "Unable to get memory stats: %s",
338 sg_str_error(sg_get_error()));
339 return -1;
340 }
341 total = mem_stats->total + swap_stats->total;
342 freemem = mem_stats->free + swap_stats->free;
343 return ((total - freemem) * 100) / total;
344}
345
346static void mem_update_stats_fn (void *data)
347{

Callers 1

mem_update_stats_fnFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected