Add used memory metrics to memory plugin

Includes both used, and used-buffers-cached to match
the results of the free command

Change-Id: I7dbfb9f7f0fb94c88f66cbc2e6004dd9b518de24
This commit is contained in:
Ryan Bak 2016-05-02 14:21:23 -06:00
parent 9c686978dc
commit f38478b348
2 changed files with 13 additions and 1 deletions

View File

@ -108,6 +108,8 @@ This section documents the system metrics that are sent by the Agent. This sect
| mem.swap_used_mb | | Mbytes of total swap memory used
| mem.total_mb | | Total Mbytes of memory
| mem.usable_mb | | Total Mbytes of usable memory
| mem.used_mb | | Mbytes of used memory
| mem.used_real_mb | | Mbytes of used memory, excluding buffers and cached. This metric is only submitted if both buffers and cached usage is available.
| mem.usable_perc | | Percentage of total memory that is usable
| mem.used_buffers | | Number of buffers in Mbytes being used by the kernel for block io
| mem.used_cached | | Mbytes of memory used for the page cache

View File

@ -31,6 +31,9 @@ class Memory(checks.AgentCheck):
self.gauge('mem.usable_mb',
int(mem_info.available / 1048576),
dimensions=dimensions)
self.gauge('mem.used_mb',
int(mem_info.used / 1048576),
dimensions=dimensions)
self.gauge('mem.usable_perc',
float(100 - mem_info.percent),
dimensions=dimensions)
@ -47,7 +50,7 @@ class Memory(checks.AgentCheck):
float(100 - swap_info.percent),
dimensions=dimensions)
count = 8
count = 9
if hasattr(mem_info, 'buffers') and mem_info.buffers:
self.gauge('mem.used_buffers',
int(mem_info.buffers / 1048576),
@ -60,6 +63,13 @@ class Memory(checks.AgentCheck):
dimensions=dimensions)
count += 1
if (hasattr(mem_info, 'buffers') and mem_info.buffers and
hasattr(mem_info, 'cached') and mem_info.cached):
self.gauge('mem.used_real_mb',
int((mem_info.used - mem_info.buffers - mem_info.cached) / 1048576),
dimensions=dimensions)
count += 1
if hasattr(mem_info, 'shared') and mem_info.shared:
self.gauge('mem.used_shared',
int(mem_info.shared / 1048576),