#!/usr/local/bin/perl
# index_cpu.cgi

require './proc-lib.pl';
&header($text{'index_title'}, "", "size", !$no_module_config, 1);
print "<hr>\n";

&index_links("size");
if (defined(&get_memory_info)) {
	@m = &get_memory_info();
	if (@m) {
		print &text('index_mem', "<tt>$m[0]</tt>",
			    "<tt>$m[1]</tt>"),"\n";
		print "&nbsp;&nbsp;",&text('index_swap', "<tt>$m[2]</tt>",
					   "<tt>$m[3]</tt>"),"<p>\n";
		}
	}
print "<table border width=100%>\n";
print "<tr $tb> <td><b>$text{'pid'}</b></td> <td><b>$text{'owner'}</b></td>\n";
print "<td><b>$text{'size'}</b></td> <td><b>$text{'command'}</b></td> </tr>\n";
@procs = sort { $b->{'size'} <=> $a->{'size'} } &list_processes();
@procs = grep { !$hide{$_->{'user'}} } @procs;
@procs = grep { $_->{'user'} eq $remote_user } @procs if ($user_processes_only);
foreach $pr (@procs) {
	$p = $pr->{'pid'};
	if ($access{'edit'}) {
		print "<tr $cb> <td><a href=\"edit_proc.cgi?$p\">$p</a></td>\n";
		}
	else {
		print "<tr $cb> <td>$p</td>\n";
		}
	print "<td>$pr->{'user'}</td>\n";
	print "<td nowrap>$pr->{'size'}</td>\n";
	print "<td>",&html_escape(&cut_string($pr->{'args'})),
	      "</td> </tr>\n";
	}
print "</table><p>\n";

print "<hr>\n";
&footer("/", $text{'index'});

