From 527eaa4cf64aa4bb68d94abb261fa4f78aaf6a85 Mon Sep 17 00:00:00 2001 From: Carsten Grohmann Date: Mon, 3 Feb 2020 06:18:40 +0100 Subject: [PATCH] Use classes selectors to simplify handling --- OOMAnalyser.html | 64 ++++++++++++++++++++++++------------------------ OOMAnalyser.py | 18 +++----------- 2 files changed, 36 insertions(+), 46 deletions(-) diff --git a/OOMAnalyser.html b/OOMAnalyser.html index aad3b2e..506fa44 100644 --- a/OOMAnalyser.html +++ b/OOMAnalyser.html @@ -411,7 +411,7 @@ function goBack() { HighMem/MovableOnly - + Number of pages in the High Memory Area or marked movable for Contiguous Memory Allocator (CMA).
HighMem pages are also counted in the total page number. @@ -419,22 +419,22 @@ function goBack() { Reserved pages - + Number of reserved pages CMA reserved pages - 0 + 0 Pages reserved for Contiguous Memory Allocator (CMA) Pagetable Cache - 0 + 0 Number of pages in pagetable cache Number of pages with hardware errors - 0 + 0 Pages with uncorrectable memory errors @@ -445,41 +445,41 @@ function goBack() { Active anonymous memory
(active_anon) - + Recently used anonymous memory.
These memory pages will usually not swapped out. Inactive anonymous memory
(inactive_anon) - + Least recently used anonymous memory.
These memory pages can be swapped out. Isolated anonymous memory
(isolated_anon) - + Memory isolation is used to separate memory between different virtual machines. Active Pagecache
(active_file) - + Pagecache that has been used more recently and usually not reclaimed unless absolutely necessary. Inactive Pagecache
(inactive_file) - + Pagecache which has been less recently used. It can be reclaimed without huge performance impact. Isolated Pagecache
(isolated_file) - + Memory isolation is used to separate memory between different virtual machines. Unevictable Pages
(unevictable) - + Unevictable memory. It can't be swapped out because the pages are owned by ramfs or protected by mlock(3) / shmctl(SHM_LOCK). @@ -488,14 +488,14 @@ function goBack() { Dirty Pages
(dirty) - + Memory which is waiting to get written back to the disk. [1] Writeback
(writeback) - + Memory which is actively being written back to the disk. [1] @@ -503,12 +503,12 @@ function goBack() { Unstable
(unstable) - + Not yet committed to stable storage. Slab Reclaimable
(slab_reclaimable) - + Slab is a in-kernel data structures cache. Part of Slab, that might be reclaimed, such as caches. [1] @@ -519,7 +519,7 @@ function goBack() { Slab Unreclaimable
(slab_unreclaimable) - + Part of Slab, that cannot be reclaimed on memory pressure. [1] @@ -527,7 +527,7 @@ function goBack() { Mapped
(mapped) - + Files which have been mapped into memory (with mmap(2)), such as libraries. @@ -536,7 +536,7 @@ function goBack() { Shared Memory
(shmem) - + Amount of memory consumed in tmpfs(5) @@ -546,7 +546,7 @@ function goBack() { Pagetables
(pagetables) - + Amount of memory dedicated to the lowest level of pagetables. [1] @@ -554,7 +554,7 @@ function goBack() { Bounce
(bounce) - + Memory used for block device "bounce buffers". [1] @@ -562,22 +562,22 @@ function goBack() { free
(free) - + free_pcp
(free_pcp) - + free_cma
(free_cma) - + Total Pagecache - + @@ -588,17 +588,17 @@ function goBack() { Kernel - + Distribution - + Guessed from the kernel version Platform - + Guessed from the kernel version @@ -616,7 +616,7 @@ function goBack() { -

+                

             
         
 
@@ -626,7 +626,7 @@ function goBack() {
         
             
             
-                

+                

             
         
 
@@ -638,7 +638,7 @@ function goBack() {
         
             
             
-                

+                

             
         
 
@@ -650,7 +650,7 @@ function goBack() {
         
             
             
-                

+                

             
         
 
diff --git a/OOMAnalyser.py b/OOMAnalyser.py
index 2edf1cf..9c81266 100644
--- a/OOMAnalyser.py
+++ b/OOMAnalyser.py
@@ -913,18 +913,7 @@ Killed process 6576 (java) total-vm:33914892kB, anon-rss:20629004kB, file-rss:0k
 
         The content won't be formatted. Only suffixes for pages and kbytes are added in the singular or plural.
         """
-        element_by_id = document.getElementById(item)
-        if element_by_id:
-            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
-        # __pragma__ ('notconv')
-
+        elements = document.getElementsByClassName(item)
         for element in elements:
             content = self.oom_details.get(item, '')
             if isinstance(content, str):
@@ -992,8 +981,9 @@ Killed process 6576 (java) total-vm:33914892kB, anon-rss:20629004kB, file-rss:0k
             element.classList.remove('js-text--display-none')
 
         for item in self.mem_modinfo_entries:
-            element = document.getElementById(item)
-            element.textContent = ""
+            elements = document.getElementsByClassName(item)
+            for element in elements:
+                element.textContent = ""
 
         # clear notification box
         element = document.getElementById('notify_box')