Remove redundant metric mem.used_mb and fix mem.used_real_mb

Per discussion in IRC:

http://eavesdrop.openstack.org/meetings/monasca/2017/monasca.2017-01-25-15.00.log.html

psutil changed 'used' memory to subtract buffers and cache in version 4.4.0:

6e4f0d3e53

This change will remove mem.used_mb and correct mem.used_real_mb to
be consistent both with older and newer versions of psutil.

Change-Id: Id0341bc64a46724e5e4f47997a2bfbd00960376c
This commit is contained in:
Brad Klein 2017-02-22 14:16:27 -07:00
parent ba1f5ebf23
commit 60a361fc76
2 changed files with 10 additions and 5 deletions

View File

@ -377,6 +377,7 @@ This section documents the system metrics that are sent by the Agent.
| 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
| mem.used_shared | | Mbytes of memory shared between separate processes and typically used for inter-process communication
| mem.used_real_mb | | Mbytes of memory currently in use less mem.used_buffers and mem.used_cached
### Disk
| Metric Name | Dimensions | Semantics |

View File

@ -31,9 +31,6 @@ 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)
@ -65,8 +62,15 @@ class Memory(checks.AgentCheck):
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),
mem_used_real = mem_info.used
if psutil.version_info < (4, 4, 0):
#
# pusutil versions prior to 4.4.0 didn't subtract buffers and
# cache, but starting in 4.4.0 psutil does.
#
mem_used_real = mem_used_real - mem_info.buffers - mem_info.cached
self.gauge('mem.used_real_mb', int(mem_used_real / 1048576),
dimensions=dimensions)
count += 1