Replace plain text process table by an HTML table
and mark the trigger process and the killed process.
This commit is contained in:
		
							parent
							
								
									c62d3952da
								
							
						
					
					
						commit
						54e4f566a4
					
				@ -66,6 +66,47 @@
 | 
			
		||||
            width: 100%;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        .pstable__table--noborder * {
 | 
			
		||||
            border: none;
 | 
			
		||||
            text-align: right;
 | 
			
		||||
            background-color: unset;
 | 
			
		||||
            padding-left: 5px;
 | 
			
		||||
            padding-right: 5px;
 | 
			
		||||
            table-layout: auto;
 | 
			
		||||
            white-space: nowrap;
 | 
			
		||||
        }
 | 
			
		||||
        .pstable__table--noborder thead {
 | 
			
		||||
            font-weight: bold;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /* Align last both columns to left in the process table */
 | 
			
		||||
        .pstable__table--noborder td:nth-of-type(9) {
 | 
			
		||||
            text-align: left;
 | 
			
		||||
        }
 | 
			
		||||
        .pstable__table--noborder td:nth-of-type(10) {
 | 
			
		||||
            text-align: left;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        .js-pstable__killedproc--bgcolor {
 | 
			
		||||
            background-color: #FFD2D2;
 | 
			
		||||
        }
 | 
			
		||||
        .js-pstable__triggerproc--bgcolor {
 | 
			
		||||
            background-color: #FEEFB3;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        .pstable__row-pid--width {
 | 
			
		||||
            width: 4ch;
 | 
			
		||||
        }
 | 
			
		||||
        .pstable__row-numeric--width {
 | 
			
		||||
            width: 6ch;
 | 
			
		||||
        }
 | 
			
		||||
        .pstable__row-pages--width {
 | 
			
		||||
            width: 12ch;
 | 
			
		||||
        }
 | 
			
		||||
        .pstable__row-oom-score-adj--width {
 | 
			
		||||
            width: 16ch;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        th {
 | 
			
		||||
            font-weight: bold;
 | 
			
		||||
            font-size: large;
 | 
			
		||||
@ -582,12 +623,29 @@ function goBack() {
 | 
			
		||||
        </tr>
 | 
			
		||||
 | 
			
		||||
        <tr>
 | 
			
		||||
            <th scope="row" colspan="3">Process Table</th>
 | 
			
		||||
            <th colspan="3" scope="row">Process Table</th>
 | 
			
		||||
        </tr>
 | 
			
		||||
        <tr>
 | 
			
		||||
            <td></td>
 | 
			
		||||
            <td colspan="2" class="terminal">
 | 
			
		||||
                <pre class="process_table"></pre>
 | 
			
		||||
            <td class="terminal " colspan="2">
 | 
			
		||||
                <table class="pstable__table--noborder">
 | 
			
		||||
                    <thead>
 | 
			
		||||
                        <tr>
 | 
			
		||||
                            <td class="pstable__row-pid--width">pid</td>
 | 
			
		||||
                            <td class="pstable__row-numeric--width">uid</td>
 | 
			
		||||
                            <td class="pstable__row-numeric--width">tgid</td>
 | 
			
		||||
                            <td class="pstable__row-pages--width">total_vm</td>
 | 
			
		||||
                            <td class="pstable__row-pages--width">rss</td>
 | 
			
		||||
                            <td class="pstable__row-pages--width">nr_ptes</td>
 | 
			
		||||
                            <td class="pstable__row-pages--width">swapents</td>
 | 
			
		||||
                            <td class="pstable__row-oom-score-adj--width">oom_score_adj</td>
 | 
			
		||||
                            <td>name</td>
 | 
			
		||||
                            <td></td>
 | 
			
		||||
                        </tr>
 | 
			
		||||
                    </thead>
 | 
			
		||||
                    <tbody id="process_table">
 | 
			
		||||
                    </tbody>
 | 
			
		||||
                </table>
 | 
			
		||||
            </td>
 | 
			
		||||
        </tr>
 | 
			
		||||
 | 
			
		||||
@ -684,6 +742,7 @@ function goBack() {
 | 
			
		||||
        <li>Add a textual summary of the analysis</li>
 | 
			
		||||
        <li>Fix calculation of requested memory in kBytes</li>
 | 
			
		||||
        <li>Fix issue that prevents units from being copied</li>
 | 
			
		||||
        <li>Show additional information in process table</li>
 | 
			
		||||
        <li>...</li>
 | 
			
		||||
    </ol>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -337,11 +337,6 @@ class OOMAnalyser(object):
 | 
			
		||||
        r')?',
 | 
			
		||||
        re.MULTILINE)
 | 
			
		||||
 | 
			
		||||
    REC_PROCESS_TABLE = re.compile(
 | 
			
		||||
        r'^\[ pid \].*(?:\n)'
 | 
			
		||||
        r'(^(\[[ \d]+.+)(?:\n))+',
 | 
			
		||||
        re.MULTILINE)
 | 
			
		||||
 | 
			
		||||
    REC_PROCESS_LINE = re.compile(
 | 
			
		||||
        r'^\[(?P<pid>[ \d]+)\]\s+(?P<uid>\d+)\s+(?P<tgid>\d+)\s+(?P<total_vm_pages>\d+)\s+(?P<rss_pages>\d+)\s+'
 | 
			
		||||
        r'(?P<nr_ptes_pages>\d+)\s+(?P<swapents_pages>\d+)\s+(?P<oom_score_adj>-?\d+)\s+(?P<name>.+)\s*')
 | 
			
		||||
@ -464,12 +459,9 @@ class OOMAnalyser(object):
 | 
			
		||||
                gd = match.groupdict()
 | 
			
		||||
                self.results.update(match.groupdict())
 | 
			
		||||
 | 
			
		||||
        for groupname, rec in [('mem_node_info', self.REC_MEM_NODEINFO),
 | 
			
		||||
                               ('process_table', self.REC_PROCESS_TABLE),
 | 
			
		||||
                               ]:
 | 
			
		||||
            match = rec.search(self.oom_entity.text)
 | 
			
		||||
            if match:
 | 
			
		||||
                self.results[groupname] = match.group()
 | 
			
		||||
        match = self.REC_MEM_NODEINFO.search(self.oom_entity.text)
 | 
			
		||||
        if match:
 | 
			
		||||
            self.results['mem_node_info'] = match.group()
 | 
			
		||||
 | 
			
		||||
        self.results['hardware_info'] = self._extract_block_from_next_pos('Hardware name:')
 | 
			
		||||
 | 
			
		||||
@ -599,6 +591,7 @@ class OOMAnalyser(object):
 | 
			
		||||
                except:
 | 
			
		||||
                    error('Converting process parameter "{}={}" to integer failed'.format(item, process[item]))
 | 
			
		||||
 | 
			
		||||
            converted['name'] = process['name']
 | 
			
		||||
            pid_int = int(pid_str)
 | 
			
		||||
            del ps[pid_str]
 | 
			
		||||
            ps[pid_int] = converted
 | 
			
		||||
@ -955,6 +948,45 @@ Killed process 6576 (java) total-vm:33914892kB, anon-rss:20629004kB, file-rss:0k
 | 
			
		||||
 | 
			
		||||
        toc_content.innerHTML = new_toc
 | 
			
		||||
 | 
			
		||||
    def update_process_table(self):
 | 
			
		||||
        """
 | 
			
		||||
        Re-create the process table with additional information
 | 
			
		||||
        """
 | 
			
		||||
        new_table = ''
 | 
			
		||||
        table_content = document.getElementById('process_table')
 | 
			
		||||
 | 
			
		||||
        for pid in self.oom_details['_processes'].keys():
 | 
			
		||||
            if pid == self.oom_details['trigger_proc_pid']:
 | 
			
		||||
                comment = 'trigger process'
 | 
			
		||||
                css_class = 'class="js-pstable__triggerproc--bgcolor"'
 | 
			
		||||
                # css_class = 'class="js-pstable__killedproc--bgcolor"'
 | 
			
		||||
            elif pid == self.oom_details['killed_proc_pid']:
 | 
			
		||||
                comment = 'killed process'
 | 
			
		||||
                css_class = 'class="js-pstable__killedproc--bgcolor"'
 | 
			
		||||
            else:
 | 
			
		||||
                comment = ''
 | 
			
		||||
                css_class = ''
 | 
			
		||||
            process = self.oom_details['_processes'][pid]
 | 
			
		||||
            line = """
 | 
			
		||||
            <tr {}>
 | 
			
		||||
                <td>{}</td>
 | 
			
		||||
                <td>{}</td>
 | 
			
		||||
                <td>{}</td>
 | 
			
		||||
                <td>{}</td>
 | 
			
		||||
                <td>{}</td>
 | 
			
		||||
                <td>{}</td>
 | 
			
		||||
                <td>{}</td>
 | 
			
		||||
                <td>{}</td>
 | 
			
		||||
                <td>{}</td>
 | 
			
		||||
                <td>{}</td>
 | 
			
		||||
            </tr>
 | 
			
		||||
            """.format(css_class, pid, process['uid'], process['tgid'], process['total_vm_pages'], process['rss_pages'],
 | 
			
		||||
                       process['nr_ptes_pages'], process['swapents_pages'], process['oom_score_adj'], process['name'],
 | 
			
		||||
                       comment)
 | 
			
		||||
            new_table += line
 | 
			
		||||
 | 
			
		||||
        table_content.innerHTML = new_table
 | 
			
		||||
 | 
			
		||||
    def set_HTML_defaults(self, clean_oom=True):
 | 
			
		||||
        """Reset the HTML document but don't clean elements"""
 | 
			
		||||
        if clean_oom:
 | 
			
		||||
@ -977,6 +1009,11 @@ Killed process 6576 (java) total-vm:33914892kB, anon-rss:20629004kB, file-rss:0k
 | 
			
		||||
        while element.firstChild:
 | 
			
		||||
            element.removeChild(element.firstChild)
 | 
			
		||||
 | 
			
		||||
        # clear process table
 | 
			
		||||
        element = document.getElementById('process_table')
 | 
			
		||||
        while element.firstChild:
 | 
			
		||||
            element.removeChild(element.firstChild)
 | 
			
		||||
 | 
			
		||||
        # remove svg charts
 | 
			
		||||
        for element_id in ('svg_swap', 'svg_ram'):
 | 
			
		||||
            element = document.getElementById(element_id)
 | 
			
		||||
@ -1153,6 +1190,9 @@ Killed process 6576 (java) total-vm:33914892kB, anon-rss:20629004kB, file-rss:0k
 | 
			
		||||
                continue
 | 
			
		||||
            self._set_item(item)
 | 
			
		||||
 | 
			
		||||
        # generate process table
 | 
			
		||||
        self.update_process_table()
 | 
			
		||||
 | 
			
		||||
        # generate swap usage diagram
 | 
			
		||||
        svg_swap = self.svg_generate_bar_chart(
 | 
			
		||||
            ('Swap Used', self.oom_details['swap_used_kb']),
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user