Martin Sivák has uploaded a new change for review. Change subject: Add support for swap information to be used in policy ......................................................................
Add support for swap information to be used in policy This patch adds support for swap size and swap usage values to be collected by guest agent or qemu agent and used in memory calculations. Change-Id: If1f8ae4d090e27a41ee541acc9398cd1a56b459a Signed-off-by: Martin Sivak <[email protected]> --- M mom/Collectors/GuestQemuAgent.py M mom/HypervisorInterfaces/libvirtInterface.py M mom/HypervisorInterfaces/vdsmInterface.py 3 files changed, 18 insertions(+), 4 deletions(-) git pull ssh://gerrit.ovirt.org:29418/mom refs/changes/78/20978/1 diff --git a/mom/Collectors/GuestQemuAgent.py b/mom/Collectors/GuestQemuAgent.py index bfe9ae6..2e82a8e 100644 --- a/mom/Collectors/GuestQemuAgent.py +++ b/mom/Collectors/GuestQemuAgent.py @@ -126,6 +126,8 @@ unused = parse_int("^MemFree: (.*) kB", meminfo) buffers = parse_int("^Buffers: (.*) kB", meminfo) cached = parse_int("^Cached: (.*) kB", meminfo) + swap_total = parse_int("^SwapTotal: (.*) kB", meminfo) + swap_free = parse_int("^SwapFree: (.*) kB", meminfo) free = unused + buffers + cached # /proc/vmstat reports cumulative statistics so we must subtract the @@ -145,9 +147,12 @@ data = { 'mem_available': avail, 'mem_unused': unused, \ 'mem_free': free, 'swap_in': swap_in, 'swap_out': swap_out, \ - 'major_fault': majflt, 'minor_fault': minflt, } + 'major_fault': majflt, 'minor_fault': minflt, \ + 'swap_total': swap_total, \ + 'swap_usage': swap_total - swap_free } return data def getFields(self=None): return set(['mem_available', 'mem_unused', 'mem_free', - 'major_fault', 'minor_fault', 'swap_in', 'swap_out']) + 'major_fault', 'minor_fault', 'swap_in', 'swap_out', + 'swap_total', 'swap_usage']) diff --git a/mom/HypervisorInterfaces/libvirtInterface.py b/mom/HypervisorInterfaces/libvirtInterface.py index a1bf71b..0fe4012 100644 --- a/mom/HypervisorInterfaces/libvirtInterface.py +++ b/mom/HypervisorInterfaces/libvirtInterface.py @@ -189,6 +189,7 @@ 'is not active') for key in set(self.mem_stats.keys()) & set(info.keys()): ret[key] = info[key] + return ret def _setStatsFields(self): @@ -201,10 +202,12 @@ minor_fault - Total number of minor page faults swap_in - Total amount of memory swapped in (kB) swap_out - Total amount of memory swapped out (kB) + swap_total - Total size of attached swap space + swap_usage - Amount of used swap size """ self.mem_stats = { 'available': 'mem_available', 'unused': 'mem_unused', 'major_fault': 'major_fault', 'minor_fault': 'minor_fault', - 'swap_in': 'swap_in', 'swap_out': 'swap_out' } + 'swap_in': 'swap_in', 'swap_out': 'swap_out', } def getStatsFields(self): return set(self.mem_stats.values()) diff --git a/mom/HypervisorInterfaces/vdsmInterface.py b/mom/HypervisorInterfaces/vdsmInterface.py index 0543f61..ddf8981 100644 --- a/mom/HypervisorInterfaces/vdsmInterface.py +++ b/mom/HypervisorInterfaces/vdsmInterface.py @@ -107,6 +107,11 @@ ret['minor_fault'] = int(stats['pageflt']) - int(stats['majflt']) ret['swap_in'] = int(stats['swap_in']) ret['swap_out'] = int(stats['swap_out']) + + # get swap size and usage information if available + ret['swap_total'] = int(stats.get('swap_total', 0)) + ret['swap_usage'] = int(stats.get('swap_usage', 0)) + self.logger.debug('Memory stats: %s', ret) return ret except vdsmException, e: @@ -131,7 +136,8 @@ def getStatsFields(self=None): return set(['mem_available', 'mem_unused', 'mem_free', - 'major_fault', 'minor_fault', 'swap_in', 'swap_out']) + 'major_fault', 'minor_fault', 'swap_in', 'swap_out', + 'swap_total', 'swap_usage']) def getVmBalloonInfo(self, uuid): try: -- To view, visit http://gerrit.ovirt.org/20978 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If1f8ae4d090e27a41ee541acc9398cd1a56b459a Gerrit-PatchSet: 1 Gerrit-Project: mom Gerrit-Branch: master Gerrit-Owner: Martin Sivák <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
