Add percentage of memory usage to analysis summary

This commit is contained in:
Carsten Grohmann 2020-01-31 22:10:11 +01:00
parent 3f0fc63144
commit 9470c552e6
2 changed files with 12 additions and 3 deletions

View File

@ -226,9 +226,10 @@ function goBack() {
<p>
The system has <span class="system_total_ram_kb"></span> physical memory and
<span class="swap_total_kb"></span> swap space. That's <span class="system_total_ramswap_kb"></span> total.
<span class="system_total_ram_used_kb"></span> out of <span class="system_total_ram_kb"></span> physical
memory and <span class="swap_used_kb"></span> out of <span class="swap_total_kb"></span> swap space
are in use.
<span class="system_total_used_percent text--append-suffix-percent"></span>
(<span class="system_total_ram_used_kb"></span> out of <span class="system_total_ram_kb"></span>) physical
memory and <span class="system_swap_used_percent text--append-suffix-percent"></span>
(<span class="swap_used_kb"></span> out of <span class="swap_total_kb"></span>) swap space are in use.
</p>
</div>

View File

@ -641,6 +641,9 @@ class OOMAnalyser(object):
# SwapUsed = SwapTotal - SwapFree - SwapCache
self.results['swap_used_kb'] = self.results['swap_total_kb'] - self.results['swap_free_kb'] - \
self.results['swap_cache_kb']
self.results['system_swap_used_percent'] = int(100 *
self.results['swap_total_kb'] /
self.results['swap_used_kb'])
def _calc_system_values(self):
"""Calculate system memory"""
@ -656,6 +659,11 @@ class OOMAnalyser(object):
total_rss_pages += self.results['_processes'][pid]['rss_pages']
self.results['system_total_ram_used_kb'] = total_rss_pages * self.results['page_size_kb']
self.results['system_total_used_percent'] = int(100 *
self.results['system_total_ram_used_kb'] /
self.results['system_total_ram_kb'])
def _determinate_platform_and_distribution(self):
"""Determinate platform and distribution"""
kernel_version = self.results.get('kernel_version', '')