Set a single value to several places

Prior this change items are set to html elements with id of the same
name. Now OOMDisplay._set_item() searches for elements with same-named
id or with item name listed in class attribute.

This allows to set one value to several places to once.

Additional suffixes for pages and kbytes are added in the singular or
plural automatically.
This commit is contained in:
Carsten Grohmann 2020-01-06 22:11:51 +01:00
parent fe3aed9815
commit 3dc965e8ff
2 changed files with 132 additions and 103 deletions

View File

@ -8,20 +8,33 @@
<style> <style>
/* Use BEM (Block__Element--Modifier) naming convention */ /* Use BEM (Block__Element--Modifier) naming convention */
.text--append-suffix-kbytes { .js-text--append-suffix-kbyte {
text-align: right; text-align: right;
} }
.text--append-suffix-kbytes::after { .js-text--append-suffix-kbyte::after {
content: " kByte";
}
.js-text--append-suffix-kbytes {
text-align: right;
}
.js-text--append-suffix-kbytes::after {
content: " kBytes"; content: " kBytes";
} }
.text--append-suffix-pages { .js-text--append-suffix-pages {
text-align: right; text-align: right;
} }
.text--append-suffix-pages::after { .js-text--append-suffix-pages::after {
content: " pages"; content: " pages";
} }
.js-text--append-suffix-page {
text-align: right;
}
.js-text--append-suffix-page::after {
content: " page";
}
.text--append-suffix-percent { .text--append-suffix-percent {
text-align: right; text-align: right;
} }
@ -196,26 +209,22 @@ function goBack() {
<h3>Summary</h3> <h3>Summary</h3>
<div id="explanation"> <div id="explanation">
<p> <p>
The process &quot;<span id="explain_trigger_proc_name"></span>&quot; (pid <span id="explain_trigger_proc_pid"></span>) The process &quot;<span class="trigger_proc_name"></span>&quot; (PID <span class="trigger_proc_pid"></span>)
requested <span class="text--append-suffix-kbytes" id="explain_trigger_proc_requested_memory_pages_kb"></span> requested <span class="trigger_proc_requested_memory_pages_kb"></span>
(<span class="text--append-suffix-pages" id="explain_trigger_proc_requested_memory_pages"></span>) memory. (<span class="trigger_proc_requested_memory_pages"></span>) memory.
The system couldn't satisfy this request and started the OOM killer to free memory. The OOM killer The system couldn't satisfy this request and started the OOM killer to free memory. The OOM killer
calculates a score for each process and terminates the process with the highest score. calculates a score for each process and terminates the process with the highest score
&quot;<span class="killed_proc_name"></span>&quot; (PID <span class="killed_proc_pid"></span>) to satisfy the initial
It terminates &quot;<span id="explain_killed_proc_name"></span>&quot; (pid memory request.
<span id="explain_killed_proc_pid"></span>) to satisfy the initial memory request.
</p> </p>
<p> <p>
The terminated process uses <span class="text--append-suffix-kbytes" id="explain_killed_proc_rss_kb"></span> The terminated process uses <span class="killed_proc_rss_kb"></span>
(<span class="text--append-suffix-percent" id="explain_killed_proc_rss_percent"></span>) resident memory (<span class="killed_proc_rss_percent text--append-suffix-percent"></span>) resident memory
and has an OOM score of <span id="explain_killed_proc_score"></span>. and has an OOM score of <span class="killed_proc_score"></span>.
<p> <p>
The system has <span class="text--append-suffix-kbytes" id="explain_ram_kb"></span> The system has <span id="system_total_ram_kb"></span> physical memory and
(<span class="text--append-suffix-pages" id="explain_ram_pages"></span> * <span class="swap_total_kb"></span> swap space. That's <span class="system_total_ramswap_kb"></span> total.
<span class="text--append-suffix-kbytes" id="explain_page_size"></span>)
physical memory and <span class="text--append-suffix-kbytes" id="explain_swap_total_kb"></span> swap space.
That's <span class="text--append-suffix-kbytes" id="explain_total_memory_kb"></span> total.
</p> </p>
<!-- <!--
r'^Killed process \d+ \(.*\) total-vm:(?P<system_total_vm_kb>\d+)kB, anon-rss:(?P<system_anon_rss_kb>\d+)kB, ' r'^Killed process \d+ \(.*\) total-vm:(?P<system_total_vm_kb>\d+)kB, anon-rss:(?P<system_anon_rss_kb>\d+)kB, '
@ -256,31 +265,31 @@ r'^Killed process \d+ \(.*\) total-vm:(?P<system_total_vm_kb>\d+)kB, anon-rss:(?
</tr> </tr>
<tr> <tr>
<td></td> <td></td>
<td class="text--align-right"><span id="trigger_proc_name"></span> (PID <span id="trigger_proc_pid"></span>)</td> <td class="text--align-right"><span class="trigger_proc_name"></span> (PID <span class="trigger_proc_pid"></span>)</td>
<td>This process requests memory and is triggering thereby the OOM situation.</td> <td>This process requests memory and is triggering thereby the OOM situation.</td>
</tr> </tr>
<tr> <tr>
<td>Memory allocation flags<br>(gfp_mask)</td> <td>Memory allocation flags<br>(gfp_mask)</td>
<td id="trigger_proc_gfp_mask" class="text--align-right"></td> <td class="trigger_proc_gfp_mask text--align-right"></td>
<td>These flags are used to control the kernel internal memory allocation<br> <td>These flags are used to control the kernel internal memory allocation<br>
GFP stands for <code>__get_free_pages()</code>.</td> GFP stands for <code>__get_free_pages()</code>.</td>
</tr> </tr>
<tr> <tr>
<td>Node mask to show on which CPU Cores this process can run<br>(nodemask)</td> <td>Node mask to show on which CPU Cores this process can run<br>(nodemask)</td>
<td id="trigger_proc_nodemask" class="text--align-right"></td> <td class="trigger_proc_nodemask text--align-right"></td>
<td>Bit mask indicating the cores on which the process can run.</td> <td>Bit mask indicating the cores on which the process can run.</td>
</tr> </tr>
<tr> <tr>
<td>Requested memory<br>(order)</td> <td>Requested memory<br>(order)</td>
<td class="text--align-right"> <td class="text--align-right">
<span id="trigger_proc_requested_memory_pages"></span> (2<span class="text__superscript" id="trigger_proc_order"></span>) pages / <span class="trigger_proc_requested_memory_pages"></span> (2<span class="trigger_proc_order text__superscript"></span>) pages /
<span class="text--append-suffix-kbytes" id="trigger_proc_requested_memory_pages_kb"></span> <span class="trigger_proc_requested_memory_pages_kb"></span>
</td> </td>
<td>The kernel specifies the requested number of pages as exponent of power of two. <td>The kernel specifies the requested number of pages as exponent of power of two.
</tr> </tr>
<tr> <tr>
<td>Adjust oom-killer score<br>(oom_score_adj)</td> <td>Adjust oom-killer score<br>(oom_score_adj)</td>
<td id="trigger_proc_oomscore" class="text--align-right"></td> <td class="trigger_proc_oomscore text--align-right"></td>
<td> <td>
This value is added to the badness score before it's used to determine the process to be killed. This value is added to the badness score before it's used to determine the process to be killed.
</td> </td>
@ -293,22 +302,25 @@ r'^Killed process \d+ \(.*\) total-vm:(?P<system_total_vm_kb>\d+)kB, anon-rss:(?
</tr> </tr>
<tr> <tr>
<td></td> <td></td>
<td class="text--align-right"><span id="killed_proc_name"></span> (PID <span id="killed_proc_pid"></span>)</td> <td class="text--align-right">
<span class="killed_proc_name"></span>
(PID <span class="killed_proc_pid"></span>)
</td>
<td>Process killed by Linux kernel to satisfy the memory request.</td> <td>Process killed by Linux kernel to satisfy the memory request.</td>
</tr> </tr>
<tr> <tr>
<td>OOM Score<br>(score)</td> <td>OOM Score<br>(score)</td>
<td id="killed_proc_score" class="text--align-right"></td> <td class="killed_proc_score text--align-right"></td>
<td>Programs with the highest OOM score are terminated first.</td> <td>Programs with the highest OOM score are terminated first.</td>
</tr> </tr>
<tr> <tr>
<td>Virtual Memory <br> (total_vm) </td> <td>Virtual Memory <br> (total_vm) </td>
<td id="killed_proc_vm_kb" class="text--append-suffix-kbytes"></td> <td class="killed_proc_vm_kb"></td>
<td>Virtual memory used by this process.</td> <td>Virtual memory used by this process.</td>
</tr> </tr>
<tr> <tr>
<td>Resident anonymous memory <br> (rss) </td> <td>Resident anonymous memory <br> (rss) </td>
<td class="text--append-suffix-kbytes" id="killed_proc_rss_kb"></td> <td class="killed_proc_rss_kb"></td>
<td>Part of the virtual process memory mapped into RAM.</td> <td>Part of the virtual process memory mapped into RAM.</td>
</tr> </tr>
@ -336,13 +348,13 @@ r'^Killed process \d+ \(.*\) total-vm:(?P<system_total_vm_kb>\d+)kB, anon-rss:(?
</tr> </tr>
<tr> <tr>
<td>RAM pages</td> <td>RAM pages</td>
<td id="ram_pages" class="text--append-suffix-pages"></td> <td class="ram_pages"></td>
<td>Total number of RAM pages <td>Total number of RAM pages
</td> </td>
</tr> </tr>
<tr> <tr>
<td>HighMem/MovableOnly</td> <td>HighMem/MovableOnly</td>
<td id="highmem_pages" class="text--append-suffix-pages"></td> <td id="highmem_pages"></td>
<td>Number of pages in the High Memory Area or marked movable for Contiguous Memory Allocator (CMA). <td>Number of pages in the High Memory Area or marked movable for Contiguous Memory Allocator (CMA).
<br> <br>
HighMem pages are also counted in the total page number. HighMem pages are also counted in the total page number.
@ -350,25 +362,25 @@ r'^Killed process \d+ \(.*\) total-vm:(?P<system_total_vm_kb>\d+)kB, anon-rss:(?
</tr> </tr>
<tr> <tr>
<td>Reserved pages</td> <td>Reserved pages</td>
<td id="reserved_pages" class="text--append-suffix-pages"></td> <td id="reserved_pages"></td>
<td>Number of reserved pages <td>Number of reserved pages
</td> </td>
</tr> </tr>
<tr> <tr>
<td>CMA reserved pages</td> <td>CMA reserved pages</td>
<td id="cma_pages" class="text--append-suffix-pages">0</td> <td id="cma_pages">0</td>
<td>Pages reserved for Contiguous Memory Allocator (CMA) <td>Pages reserved for Contiguous Memory Allocator (CMA)
</td> </td>
</tr> </tr>
<tr> <tr>
<td>Pagetable Cache</td> <td>Pagetable Cache</td>
<td id="pagetablecache_pages" class="text--append-suffix-pages">0</td> <td id="pagetablecache_pages">0</td>
<td>Number of pages in pagetable cache <td>Number of pages in pagetable cache
</td> </td>
</tr> </tr>
<tr> <tr>
<td>Number of pages with hardware errors</td> <td>Number of pages with hardware errors</td>
<td id="hwpoisoned_pages" class="text--append-suffix-pages">0</td> <td id="hwpoisoned_pages">0</td>
<td>Pages with uncorrectable memory errors <td>Pages with uncorrectable memory errors
</td> </td>
</tr> </tr>
@ -382,41 +394,41 @@ r'^Killed process \d+ \(.*\) total-vm:(?P<system_total_vm_kb>\d+)kB, anon-rss:(?
</tr> </tr>
<tr> <tr>
<td>Active anonymous memory <br> (active_anon) </td> <td>Active anonymous memory <br> (active_anon) </td>
<td id="active_anon_pages" class="text--append-suffix-pages"></td> <td id="active_anon_pages"></td>
<td>Recently used anonymous memory.<br> <td>Recently used anonymous memory.<br>
These memory pages will usually not swapped out. These memory pages will usually not swapped out.
</td> </td>
</tr> </tr>
<tr> <tr>
<td>Inactive anonymous memory <br> (inactive_anon)</td> <td>Inactive anonymous memory <br> (inactive_anon)</td>
<td id="inactive_anon_pages" class="text--append-suffix-pages"></td> <td id="inactive_anon_pages"></td>
<td>Least recently used anonymous memory.<br> <td>Least recently used anonymous memory.<br>
These memory pages can be swapped out. These memory pages can be swapped out.
</td> </td>
</tr> </tr>
<tr> <tr>
<td>Isolated anonymous memory <br> (isolated_anon)</td> <td>Isolated anonymous memory <br> (isolated_anon)</td>
<td id="isolated_anon_pages" class="text--append-suffix-pages"></td> <td id="isolated_anon_pages"></td>
<td>Memory isolation is used to separate memory between different virtual machines.</td> <td>Memory isolation is used to separate memory between different virtual machines.</td>
</tr> </tr>
<tr> <tr>
<td>Active Pagecache <br> (active_file)</td> <td>Active Pagecache <br> (active_file)</td>
<td id="active_file_pages" class="text--append-suffix-pages"></td> <td id="active_file_pages"></td>
<td>Pagecache that has been used more recently and usually not reclaimed unless absolutely necessary.</td> <td>Pagecache that has been used more recently and usually not reclaimed unless absolutely necessary.</td>
</tr> </tr>
<tr> <tr>
<td>Inactive Pagecache <br> (inactive_file)</td> <td>Inactive Pagecache <br> (inactive_file)</td>
<td id="inactive_file_pages" class="text--append-suffix-pages"></td> <td id="inactive_file_pages"></td>
<td>Pagecache which has been less recently used. It can be reclaimed without huge performance impact.</td> <td>Pagecache which has been less recently used. It can be reclaimed without huge performance impact.</td>
</tr> </tr>
<tr> <tr>
<td>Isolated Pagecache <br> (isolated_file)</td> <td>Isolated Pagecache <br> (isolated_file)</td>
<td id="isolated_file_pages" class="text--append-suffix-pages"></td> <td id="isolated_file_pages"></td>
<td>Memory isolation is used to separate memory between different virtual machines.</td> <td>Memory isolation is used to separate memory between different virtual machines.</td>
</tr> </tr>
<tr> <tr>
<td>Unevictable Pages <br> (unevictable)</td> <td>Unevictable Pages <br> (unevictable)</td>
<td id="unevictable_pages" class="text--append-suffix-pages"></td> <td id="unevictable_pages"></td>
<td>Unevictable memory. It can't be swapped out because the pages are owned by ramfs or protected by <td>Unevictable memory. It can't be swapped out because the pages are owned by ramfs or protected by
<a href="http://man7.org/linux/man-pages/man3/mlock.5.html" target="_blank">mlock(3)</a> / <a href="http://man7.org/linux/man-pages/man3/mlock.5.html" target="_blank">mlock(3)</a> /
<a href="http://man7.org/linux/man-pages/man2/shmctl.2.html" target="_blank">shmctl(SHM_LOCK)</a>. <a href="http://man7.org/linux/man-pages/man2/shmctl.2.html" target="_blank">shmctl(SHM_LOCK)</a>.
@ -425,14 +437,14 @@ r'^Killed process \d+ \(.*\) total-vm:(?P<system_total_vm_kb>\d+)kB, anon-rss:(?
</tr> </tr>
<tr> <tr>
<td>Dirty Pages <br> (dirty)</td> <td>Dirty Pages <br> (dirty)</td>
<td id="dirty_pages" class="text--append-suffix-pages"></td> <td id="dirty_pages"></td>
<td>Memory which is waiting to get written back to the disk. <td>Memory which is waiting to get written back to the disk.
<a class="a__footnote" href="#footnote-proc5">[1]</a> <a class="a__footnote" href="#footnote-proc5">[1]</a>
</td> </td>
</tr> </tr>
<tr> <tr>
<td>Writeback <br> (writeback)</td> <td>Writeback <br> (writeback)</td>
<td id="writeback_pages" class="text--append-suffix-pages"></td> <td id="writeback_pages"></td>
<td> <td>
Memory which is actively being written back to the disk. Memory which is actively being written back to the disk.
<a class="a__footnote" href="#footnote-proc5">[1]</a> <a class="a__footnote" href="#footnote-proc5">[1]</a>
@ -440,12 +452,12 @@ r'^Killed process \d+ \(.*\) total-vm:(?P<system_total_vm_kb>\d+)kB, anon-rss:(?
</tr> </tr>
<tr> <tr>
<td>Unstable <br> (unstable)</td> <td>Unstable <br> (unstable)</td>
<td id="unstable_pages" class="text--append-suffix-pages"></td> <td id="unstable_pages"></td>
<td>Not yet committed to stable storage.</td> <td>Not yet committed to stable storage.</td>
</tr> </tr>
<tr> <tr>
<td>Slab Reclaimable <br> (slab_reclaimable)</td> <td>Slab Reclaimable <br> (slab_reclaimable)</td>
<td id="slab_reclaimable_pages" class="text--append-suffix-pages"></td> <td id="slab_reclaimable_pages"></td>
<td> <td>
Slab is a in-kernel data structures cache. Part of Slab, that might be reclaimed, such as caches. Slab is a in-kernel data structures cache. Part of Slab, that might be reclaimed, such as caches.
<a class="a__footnote" href="#footnote-proc5">[1]</a> <a class="a__footnote" href="#footnote-proc5">[1]</a>
@ -456,7 +468,7 @@ r'^Killed process \d+ \(.*\) total-vm:(?P<system_total_vm_kb>\d+)kB, anon-rss:(?
</tr> </tr>
<tr> <tr>
<td>Slab Unreclaimable <br> (slab_unreclaimable)</td> <td>Slab Unreclaimable <br> (slab_unreclaimable)</td>
<td id="slab_unreclaimable_pages" class="text--append-suffix-pages"></td> <td id="slab_unreclaimable_pages"></td>
<td> <td>
Part of Slab, that cannot be reclaimed on memory pressure. Part of Slab, that cannot be reclaimed on memory pressure.
<a class="a__footnote" href="#footnote-proc5">[1]</a> <a class="a__footnote" href="#footnote-proc5">[1]</a>
@ -464,7 +476,7 @@ r'^Killed process \d+ \(.*\) total-vm:(?P<system_total_vm_kb>\d+)kB, anon-rss:(?
</tr> </tr>
<tr> <tr>
<td>Mapped <br> (mapped)</td> <td>Mapped <br> (mapped)</td>
<td id="mapped_pages" class="text--append-suffix-pages"></td> <td id="mapped_pages"></td>
<td> <td>
Files which have been mapped into memory (with Files which have been mapped into memory (with
<a href="http://man7.org/linux/man-pages/man2/mmap.2.html">mmap(2)</a>), such as libraries. <a href="http://man7.org/linux/man-pages/man2/mmap.2.html">mmap(2)</a>), such as libraries.
@ -473,7 +485,7 @@ r'^Killed process \d+ \(.*\) total-vm:(?P<system_total_vm_kb>\d+)kB, anon-rss:(?
</tr> </tr>
<tr> <tr>
<td>Shared Memory <br> (shmem)</td> <td>Shared Memory <br> (shmem)</td>
<td id="shmem_pages" class="text--append-suffix-pages"></td> <td id="shmem_pages"></td>
<td> <td>
Amount of memory consumed in Amount of memory consumed in
<a href="http://man7.org/linux/man-pages/man5/tmpfs.5.html">tmpfs(5)</a> <a href="http://man7.org/linux/man-pages/man5/tmpfs.5.html">tmpfs(5)</a>
@ -483,7 +495,7 @@ r'^Killed process \d+ \(.*\) total-vm:(?P<system_total_vm_kb>\d+)kB, anon-rss:(?
</tr> </tr>
<tr> <tr>
<td>Pagetables <br> (pagetables)</td> <td>Pagetables <br> (pagetables)</td>
<td id="pagetables_pages" class="text--append-suffix-pages"></td> <td id="pagetables_pages"></td>
<td> <td>
Amount of memory dedicated to the lowest level of pagetables. Amount of memory dedicated to the lowest level of pagetables.
<a class="a__footnote" href="#footnote-proc5">[1]</a> <a class="a__footnote" href="#footnote-proc5">[1]</a>
@ -491,7 +503,7 @@ r'^Killed process \d+ \(.*\) total-vm:(?P<system_total_vm_kb>\d+)kB, anon-rss:(?
</tr> </tr>
<tr> <tr>
<td>Bounce <br> (bounce)</td> <td>Bounce <br> (bounce)</td>
<td id="bounce_pages" class="text--append-suffix-pages"></td> <td id="bounce_pages"></td>
<td> <td>
Memory used for block device "bounce buffers". Memory used for block device "bounce buffers".
<a class="a__footnote" href="#footnote-proc5">[1]</a> <a class="a__footnote" href="#footnote-proc5">[1]</a>
@ -499,22 +511,22 @@ r'^Killed process \d+ \(.*\) total-vm:(?P<system_total_vm_kb>\d+)kB, anon-rss:(?
</tr> </tr>
<tr> <tr>
<td>free <br> (free)</td> <td>free <br> (free)</td>
<td id="free_pages" class="text--append-suffix-pages"></td> <td id="free_pages"></td>
<td></td> <td></td>
</tr> </tr>
<tr> <tr>
<td>free_pcp <br> (free_pcp)</td> <td>free_pcp <br> (free_pcp)</td>
<td id="free_pcp_pages" class="text--append-suffix-pages"></td> <td id="free_pcp_pages"></td>
<td></td> <td></td>
</tr> </tr>
<tr> <tr>
<td>free_cma <br> (free_cma)</td> <td>free_cma <br> (free_cma)</td>
<td id="free_cma_pages" class="text--append-suffix-pages"></td> <td id="free_cma_pages"></td>
<td></td> <td></td>
</tr> </tr>
<tr> <tr>
<td>Total Pagecache</td> <td>Total Pagecache</td>
<td id="pagecache_total_pages" class="text--append-suffix-pages"></td> <td id="pagecache_total_pages"></td>
<td></td> <td></td>
</tr> </tr>
@ -527,21 +539,21 @@ r'^Killed process \d+ \(.*\) total-vm:(?P<system_total_vm_kb>\d+)kB, anon-rss:(?
</tr> </tr>
<tr> <tr>
<td>Swap Total</td> <td>Swap Total</td>
<td id="swap_total_kb" class="text--append-suffix-kbytes"></td> <td class="swap_total_kb"></td>
<td>Total amount of swap space available. <td>Total amount of swap space available.
<a class="a__footnote" href="#footnote-proc5">[1]</a> <a class="a__footnote" href="#footnote-proc5">[1]</a>
</td> </td>
</tr> </tr>
<tr> <tr>
<td>Swap Free</td> <td>Swap Free</td>
<td id="swap_free_kb" class="text--append-suffix-kbytes"></td> <td class="swap_free_kb"></td>
<td>Amount of swap space that is currently unused. <td>Amount of swap space that is currently unused.
<a class="a__footnote" href="#footnote-proc5">[1]</a> <a class="a__footnote" href="#footnote-proc5">[1]</a>
</td> </td>
</tr> </tr>
<tr> <tr>
<td>Swap Cached</td> <td>Swap Cached</td>
<td id="swap_cache_kb" class="text--append-suffix-kbytes"></td> <td class="swap_cache_kb"></td>
<td>Memory that once was swapped out, is swapped back in <td>Memory that once was swapped out, is swapped back in
but still also is in the swap file. (If memory pressure but still also is in the swap file. (If memory pressure
is high, these pages don't need to be swapped out is high, these pages don't need to be swapped out
@ -552,7 +564,7 @@ r'^Killed process \d+ \(.*\) total-vm:(?P<system_total_vm_kb>\d+)kB, anon-rss:(?
</tr> </tr>
<tr> <tr>
<td>Swap Used</td> <td>Swap Used</td>
<td id="swap_used_kb" class="text--append-suffix-kbytes"></td> <td class="swap_used_kb"></td>
<td>Amount of used swap space w/o cached swap <br> <td>Amount of used swap space w/o cached swap <br>
(<code>SwapUsed = SwapTotal - SwapFree -SwapCache</code>) (<code>SwapUsed = SwapTotal - SwapFree -SwapCache</code>)
</td> </td>
@ -580,7 +592,7 @@ r'^Killed process \d+ \(.*\) total-vm:(?P<system_total_vm_kb>\d+)kB, anon-rss:(?
</tr> </tr>
<tr> <tr>
<td>Page size</td> <td>Page size</td>
<td id="page_size" class="text--append-suffix-kbytes"></td> <td class="page_size_kb"></td>
<td>Guessed</td> <td>Guessed</td>
</tr> </tr>

View File

@ -607,7 +607,7 @@ class OOMAnalyser(object):
"""Calculate all values related with the trigger process""" """Calculate all values related with the trigger process"""
self.results['trigger_proc_requested_memory_pages'] = 2 ** self.results['trigger_proc_order'] self.results['trigger_proc_requested_memory_pages'] = 2 ** self.results['trigger_proc_order']
self.results['trigger_proc_requested_memory_pages_kb'] = self.results['trigger_proc_requested_memory_pages'] *\ self.results['trigger_proc_requested_memory_pages_kb'] = self.results['trigger_proc_requested_memory_pages'] *\
self.results['page_size'] self.results['page_size_kb']
# process gfp_mask # process gfp_mask
if self.results['trigger_proc_gfp_flags'] != '<not found>': # None has been is converted to '<not found>' if self.results['trigger_proc_gfp_flags'] != '<not found>': # None has been is converted to '<not found>'
flags = self.results['trigger_proc_gfp_flags'] flags = self.results['trigger_proc_gfp_flags']
@ -627,16 +627,33 @@ class OOMAnalyser(object):
"""Calculate all values related with the killed process""" """Calculate all values related with the killed process"""
self.results['killed_proc_rss_kb'] = self.results['_processes'][self.results['killed_proc_pid']]['rss'] self.results['killed_proc_rss_kb'] = self.results['_processes'][self.results['killed_proc_pid']]['rss']
self.results['killed_proc_vm_kb'] = self.results['_processes'][self.results['killed_proc_pid']]['total_vm'] self.results['killed_proc_vm_kb'] = self.results['_processes'][self.results['killed_proc_pid']]['total_vm']
self.results['killed_proc_rss_percent'] = int(100 *
self.results['killed_proc_rss_kb'] /
self.results['system_total_ram_kb'])
def _calc_swap_values(self): def _calc_swap_values(self):
"""Calculate all swap related values""" """Calculate all swap related values"""
self.results['swap_cache_kb'] = self.results['swap_cache_pages'] * self.results['page_size'] self.results['swap_cache_kb'] = self.results['swap_cache_pages'] * self.results['page_size_kb']
del self.results['swap_cache_pages'] del self.results['swap_cache_pages']
# SwapUsed = SwapTotal - SwapFree - SwapCache # SwapUsed = SwapTotal - SwapFree - SwapCache
self.results['swap_used_kb'] = self.results['swap_total_kb'] - self.results['swap_free_kb'] - \ self.results['swap_used_kb'] = self.results['swap_total_kb'] - self.results['swap_free_kb'] - \
self.results['swap_cache_kb'] self.results['swap_cache_kb']
def _calc_system_values(self):
"""Calculate system memory"""
# educated guess
self.results['page_size_kb'] = 4
# calculate remaining explanation values
self.results['system_total_ram_kb'] = self.results['ram_pages'] * self.results['page_size_kb']
self.results['system_total_ramswap_kb'] = self.results['system_total_ram_kb'] + self.results['swap_total_kb']
self.results['system_total_ram_used_kb'] = self.results['system_total_vm_kb'] + \
self.results['system_anon_rss_kb'] + \
self.results['system_file_rss_kb'] + \
self.results['system_shmem_rss_kb']
def _determinate_platform_and_distribution(self): def _determinate_platform_and_distribution(self):
"""Determinate platform and distribution""" """Determinate platform and distribution"""
kernel_version = self.results.get('kernel_version', '') kernel_version = self.results.get('kernel_version', '')
@ -666,15 +683,14 @@ class OOMAnalyser(object):
@see: self.results @see: self.results
""" """
# educated guess
self.results['page_size'] = 4
self._convert_numeric_results_to_integer() self._convert_numeric_results_to_integer()
self._convert_numeric_process_values_to_integer() self._convert_numeric_process_values_to_integer()
self._determinate_platform_and_distribution()
self._calc_system_values()
self._calc_trigger_process_values() self._calc_trigger_process_values()
self._calc_killed_process_values() self._calc_killed_process_values()
self._calc_swap_values() self._calc_swap_values()
self._determinate_platform_and_distribution()
def analyse(self): def analyse(self):
"""Extract and calculate values from the given OOM object""" """Extract and calculate values from the given OOM object"""
@ -881,25 +897,49 @@ Killed process 6576 (java) total-vm:33914892kB, anon-rss:20629004kB, file-rss:0k
element = document.getElementById('version') element = document.getElementById('version')
element.textContent = "v{}".format(VERSION) element.textContent = "v{}".format(VERSION)
def _set_single_item(self, item): def _set_item(self, item):
""" """
Set content of a single item to the HTML element with the same name. Paste the content into HTML elements with the ID / Class that matches the item name.
The content won't be formatted. The content won't be formatted. Only suffixes for pages and kbytes are added in the singular or plural.
""" """
element = document.getElementById(item) element_by_id = document.getElementById(item)
if not element: if element_by_id:
print("ERROR: HTML element not found: ", item) elements = [element_by_id]
else:
elements = document.getElementsByClassName(item)
# __pragma__ ('tconv')
if not elements:
print("ERROR: No HTML element found to set item {}".format(item))
return return
# __pragma__ ('notconv')
content = self.oom_details.get(item, '') for element in elements:
if isinstance(content, str): content = self.oom_details.get(item, '')
content = content.strip() if isinstance(content, str):
element.textContent = content content = content.strip()
element.textContent = content
if content == '<not found>': if content == '<not found>':
row = element.parentNode row = element.parentNode
row.classList.add('js-text--display-none') row.classList.add('js-text--display-none')
if item.endswith('_pages') and isinstance(content, int):
if content == 1:
element.classList.add('js-text--append-suffix-page')
element.classList.remove('js-text--append-suffix-pages')
else:
element.classList.add('js-text--append-suffix-pages')
element.classList.remove('js-text--append-suffix-page')
if item.endswith('_kb') and isinstance(content, int):
if content == 1:
element.classList.add('js-text--append-suffix-kbyte')
element.classList.remove('js-text--append-suffix-kbytes')
else:
element.classList.add('js-text--append-suffix-kbytes')
element.classList.remove('js-text--append-suffix-kbyte')
if DEBUG: if DEBUG:
show_element('notify_box') show_element('notify_box')
@ -1120,34 +1160,11 @@ Killed process 6576 (java) total-vm:33914892kB, anon-rss:20629004kB, file-rss:0k
hide_element('input') hide_element('input')
show_element('analysis') show_element('analysis')
# copy entries for explanation section
for i in ('killed_proc_name', 'killed_proc_pid', 'killed_proc_rss_kb', 'killed_proc_score', 'page_size',
'ram_pages', 'swap_total_kb', 'swap_used_kb', 'trigger_proc_name', 'trigger_proc_pid',
'trigger_proc_requested_memory_pages', 'trigger_proc_requested_memory_pages_kb',
):
self.oom_details['explain_'+i] = self.oom_details.get(i)
# calculate remaining explanation values
self.oom_details['explain_ram_kb'] = self.oom_details['ram_pages'] * self.oom_details['page_size']
self.oom_details['explain_killed_proc_rss_percent'] = int(100 *
self.oom_details['explain_killed_proc_rss_kb'] /
self.oom_details['explain_ram_kb'])
self.oom_details['explain_total_memory_kb'] = self.oom_details['explain_ram_kb'] + \
self.oom_details['swap_total_kb']
# self.oom_details['explain_used_memory_kb'] = 42
# self.oom_details['explain_used_memory_percent'] = 42
# self.oom_details['explain_swap_used_percent'] = int(100 *
# self.oom_details['swap_used_kb'] /
# self.oom_details['swap_total_kb'])
for item in self.oom_details.keys(): for item in self.oom_details.keys():
# ignore internal items # ignore internal items
if item.startswith('_'): if item.startswith('_'):
continue continue
self._set_single_item(item) self._set_item(item)
# generate swap usage diagram # generate swap usage diagram
svg_swap = self.svg_generate_bar_chart( svg_swap = self.svg_generate_bar_chart(