  [% META title = 'Resources &raquo; Process Status' meta_refresh = 60 -%]

<!-- BEGIN [% template.name %] -->
	[% # PROCESS dumper.tt dump = data %]

	<h3>Process status [[% cmd %]]</h3>
	
	[% headers = [ 'user' 'pid' 'cpu' '%mem' 'vsv' 'rss' 'start' 'time' 'cmd'
        'owner' ];
		
		cfg = c.cfg('settings');
		is_sysadmin = ( cfg.item('_centre') == cfg.sysadmin_centre ) ? 1 : 0;
		headers.push('kill') IF is_sysadmin;
	%]
	
	<form action="[% c.query.self_url %]" method="post">
		<table class="indent">
			<tr>
				[% FOREACH h IN headers %]
				<th>[% h %]</th>
				[% END %]
			</tr>
			[% FOREACH row IN data;
				class = row.7.match('0:00') ? 'grey' : 'normal';
				pid   = row.1;
				owner = row.9;
			%]
				<tr class="[% class %]">
				  [% FOREACH col IN row %]<td>[% col %]</td>[% END %]
				  <td>
					[% IF owner.match('zombie') AND is_sysadmin %]
						<input type="checkbox" name="pid" value="[% pid %]" />
					[% ELSE; '<span class="white">--</span>'; END %]
				  </td>
				</tr>
			[% END %]
			<tr class="borderless">
				<td colspan="3">
					[% site.html.back_button %]
					<input type='submit' value='Refresh' name='.submit' class='button' />
				</td>
                <td colspan="4">
                    <span class="grey">[seconds until auto refresh:
                        <span id="refresh"></span>]</span>
                </td>
				<td colspan="4" align="right">
					[% IF is_sysadmin %]
						<span class="bold">kill selected:</span>
						<input type='submit' value='Go' name='.submit' class='button' />
					[% END %]
				</td>
			</tr>
		</table>
    </form>

	<h4>Definitions (man ps):</h4>
	<dl>
		<dt>%cpu</dt>
		<dd>cpu utilization of the process in "##.#" format.
			Currently, it is the CPU time used divided by the time the
			process has been running (cputime/realtime ratio),
			expressed as a percentage. It will not add up to 100%
			unless you are lucky.</dd>
		<dt>%mem</dt>
		<dd>ratio of the process's resident set size  to the physical
			memory on the machine, expressed as a percentage.</dd>
		<dt>vsv</dt>
		<dd>virtual memory size of the process in KiB
			1024-byte units). Device mappings are currently excluded;
			this is subject to change.</dd>
		<dt>rss</dt>
		<dd>resident set size, the non-swapped physical memory that a
			task has used (in kiloBytes).</dd>
		<dt>start</dt>
		<dd>time the command started. If the process was started less
			than 24 hours ago, the output format is "HH:MM:SS", else
			it is "  mmm dd" (where mmm is a three-letter month name).</dd>
		<dt>time</dt>
		<dd>cumulative CPU time, "[dd-]hh:mm:ss" format.</dd>
	</dl>
<!-- END [% template.name %] -->