Improve check for entered OOM
The user input will be checked more detailed. Based on that a warning or an error message will be shown.
This commit is contained in:
parent
0b28630248
commit
91b32d63d7
@ -11,8 +11,9 @@
|
|||||||
margin: 0.67em 0;
|
margin: 0.67em 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#error_box {
|
#notify_box {
|
||||||
display: none;
|
display: none;
|
||||||
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.kbytes {
|
.kbytes {
|
||||||
@ -58,6 +59,15 @@
|
|||||||
overflow: auto;
|
overflow: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.notify-warning {
|
||||||
|
color: #9F6000;
|
||||||
|
background-color: #FEEFB3;
|
||||||
|
}
|
||||||
|
.notify-error {
|
||||||
|
color: #D8000C;
|
||||||
|
background-color: #FFD2D2;
|
||||||
|
}
|
||||||
|
|
||||||
/* Zebra-Layout */
|
/* Zebra-Layout */
|
||||||
tr:nth-child(odd) td:nth-child(2), tr:nth-child(odd) td:nth-child(3) {
|
tr:nth-child(odd) td:nth-child(2), tr:nth-child(odd) td:nth-child(3) {
|
||||||
background-color: #f2f2f2;
|
background-color: #f2f2f2;
|
||||||
@ -98,6 +108,10 @@ function goBack() {
|
|||||||
<button onclick="OOMAnalyser.oomAnalyser.copy_example()" title="Copy an example OOM into the input area">Insert example</button>
|
<button onclick="OOMAnalyser.oomAnalyser.copy_example()" title="Copy an example OOM into the input area">Insert example</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<div class="terminal" id="notify_box"></div>
|
||||||
|
</p>
|
||||||
|
|
||||||
<div id="analysis">
|
<div id="analysis">
|
||||||
|
|
||||||
<h2>Step 2 - Results</h2>
|
<h2>Step 2 - Results</h2>
|
||||||
@ -465,11 +479,6 @@ function goBack() {
|
|||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="error_box">
|
|
||||||
<h2>Error messages</h2>
|
|
||||||
<div class="terminal" id="__terminal__"></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<hr/>
|
<hr/>
|
||||||
|
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
@ -507,4 +516,4 @@ function goBack() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -35,8 +35,22 @@ def toggle(element_id):
|
|||||||
|
|
||||||
def error(msg):
|
def error(msg):
|
||||||
"""Unhide the error box and add the error message"""
|
"""Unhide the error box and add the error message"""
|
||||||
show_element("error_box")
|
notify_box = document.getElementById('notify_box')
|
||||||
print("ERROR: ", msg)
|
notify_box.style.display = 'block'
|
||||||
|
notification = document.createElement('div')
|
||||||
|
notification.classList.add('notify-error')
|
||||||
|
notification.innerHTML = 'ERROR: {}<br>'.format(msg)
|
||||||
|
notify_box.appendChild(notification)
|
||||||
|
|
||||||
|
|
||||||
|
def warning(msg):
|
||||||
|
"""Unhide the error box and add the warning message"""
|
||||||
|
notify_box = document.getElementById('notify_box')
|
||||||
|
notify_box.style.display = 'block'
|
||||||
|
notification = document.createElement('div')
|
||||||
|
notification.classList.add('notify-warning')
|
||||||
|
notification.innerHTML = 'WARNING: {}<br>'.format(msg)
|
||||||
|
notify_box.appendChild(notification)
|
||||||
|
|
||||||
|
|
||||||
class OOM(object):
|
class OOM(object):
|
||||||
@ -49,7 +63,9 @@ class OOM(object):
|
|||||||
|
|
||||||
i = 0
|
i = 0
|
||||||
lines = []
|
lines = []
|
||||||
complete = False
|
|
||||||
|
state = "unknown"
|
||||||
|
"""State of the OOM after initial parsing"""
|
||||||
|
|
||||||
def __init__(self, text):
|
def __init__(self, text):
|
||||||
# use Unix LF only
|
# use Unix LF only
|
||||||
@ -57,13 +73,14 @@ class OOM(object):
|
|||||||
|
|
||||||
# Split into lines
|
# Split into lines
|
||||||
oom_lines = []
|
oom_lines = []
|
||||||
inside_oom = False
|
begin_found = False
|
||||||
|
end_found = False
|
||||||
|
|
||||||
for line in text.split('\n'):
|
for line in text.split('\n'):
|
||||||
|
|
||||||
if "invoked oom-killer:" in line:
|
if "invoked oom-killer:" in line:
|
||||||
inside_oom = True
|
begin_found = True
|
||||||
elif not inside_oom:
|
elif not begin_found:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Remove leading timestamps
|
# Remove leading timestamps
|
||||||
@ -77,11 +94,18 @@ class OOM(object):
|
|||||||
|
|
||||||
# next line will not be part of the oom anymore
|
# next line will not be part of the oom anymore
|
||||||
if "Killed process" in line:
|
if "Killed process" in line:
|
||||||
inside_oom = False
|
end_found = True
|
||||||
break
|
break
|
||||||
|
|
||||||
self.i = 0
|
self.i = 0
|
||||||
self.complete = not inside_oom
|
|
||||||
|
if begin_found and end_found:
|
||||||
|
self.state = "oom_complete"
|
||||||
|
elif begin_found and not end_found:
|
||||||
|
self.state = "oom_started"
|
||||||
|
else:
|
||||||
|
self.state = "oom_invalid"
|
||||||
|
|
||||||
self.lines = oom_lines
|
self.lines = oom_lines
|
||||||
self.text = '\n'.join(oom_lines)
|
self.text = '\n'.join(oom_lines)
|
||||||
|
|
||||||
@ -416,7 +440,7 @@ Killed process 6576 (java) total-vm:33914892kB, anon-rss:20629004kB, file-rss:0k
|
|||||||
content = content.strip()
|
content = content.strip()
|
||||||
element.textContent = content
|
element.textContent = content
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
show_element('error_box')
|
show_element('notify_box')
|
||||||
|
|
||||||
def _set_defaults(self, clean_oom=True):
|
def _set_defaults(self, clean_oom=True):
|
||||||
"""\
|
"""\
|
||||||
@ -426,6 +450,7 @@ Killed process 6576 (java) total-vm:33914892kB, anon-rss:20629004kB, file-rss:0k
|
|||||||
document.getElementById('textarea_oom').value = "<paste your OOM here>"
|
document.getElementById('textarea_oom').value = "<paste your OOM here>"
|
||||||
|
|
||||||
hide_element("analysis")
|
hide_element("analysis")
|
||||||
|
hide_element("notify_box")
|
||||||
show_element("input")
|
show_element("input")
|
||||||
|
|
||||||
self.lines = []
|
self.lines = []
|
||||||
@ -434,10 +459,11 @@ Killed process 6576 (java) total-vm:33914892kB, anon-rss:20629004kB, file-rss:0k
|
|||||||
element = document.getElementById(item)
|
element = document.getElementById(item)
|
||||||
element.textContent = ""
|
element.textContent = ""
|
||||||
|
|
||||||
# empty terminal
|
# clear notification box
|
||||||
element = document.getElementById('__terminal__')
|
element = document.getElementById('notify_box')
|
||||||
element.textContent = ""
|
while element.firstChild:
|
||||||
hide_element('error_box')
|
element.removeChild(element.firstChild)
|
||||||
|
hide_element('notify_box')
|
||||||
|
|
||||||
# remove svg charts
|
# remove svg charts
|
||||||
for element_id in ('svg_swap', 'svg_ram'):
|
for element_id in ('svg_swap', 'svg_ram'):
|
||||||
@ -697,8 +723,16 @@ Killed process 6576 (java) total-vm:33914892kB, anon-rss:20629004kB, file-rss:0k
|
|||||||
oom_text = element.value
|
oom_text = element.value
|
||||||
self.oom = OOM(oom_text)
|
self.oom = OOM(oom_text)
|
||||||
|
|
||||||
if not self.oom.complete:
|
if self.oom.state == "oom_complete":
|
||||||
error('The inserted test is not a valid OOM!')
|
pass
|
||||||
|
elif self.oom.state == "oom_started":
|
||||||
|
warning('The inserted OOM is incomplete - only the beginning has found.')
|
||||||
|
warning('The result may be incomplete!')
|
||||||
|
elif self.oom.state == "oom_invalid":
|
||||||
|
error('The inserted text is not a valid OOM!')
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
error('Invalid state "{}" after the OOM has formally checked!'.format(self.oom.state))
|
||||||
return
|
return
|
||||||
|
|
||||||
self._extract_from_oom_text()
|
self._extract_from_oom_text()
|
||||||
|
Loading…
Reference in New Issue
Block a user