Handle hostnames with upper-case letters
[webmin.git] / proc / index_cpu.cgi
1 #!/usr/local/bin/perl
2 # index_cpu.cgi
3
4 require './proc-lib.pl';
5 &ui_print_header(undef, $text{'index_title'}, "", "cpu", !$no_module_config, 1);
6
7 # Show CPU load and type
8 &index_links("cpu");
9 if (defined(&get_cpu_info)) {
10         print "<table>\n";
11         @c = &get_cpu_info();
12         if (@c) {
13                 print "<tr> <td><b>$text{'index_loadname'}</b></td>\n";
14                 print "<td>",&text('index_loadnums',
15                         "<tt>$c[0]</tt>", "<tt>$c[1]</tt>", "<tt>$c[2]</tt>"),
16                         "</td> </tr>\n";
17                 if (@c >= 5) {
18                         print "<tr> <td><b>$text{'index_cpuname'}</b></td>\n";
19                         print "<td>$c[4]\n";
20                         if ($c[4] !~ /Hz/) {
21                                 print "($c[3] MHz)\n";
22                                 }
23                         if ($c[7]) {
24                                 print ", $c[7] cores\n";
25                                 }
26                         print "</td> </tr>\n";
27                         }
28                 }
29         print "</table><br>\n";
30         }
31
32 print &ui_columns_start([ $text{'pid'}, $text{'owner'},
33                           $text{'cpu'}, $text{'command'} ], 100);
34 @procs = sort { $b->{'cpu'} <=> $a->{'cpu'} } &list_processes();
35 @procs = grep { &can_view_process($_->{'user'}) } @procs;
36 foreach $pr (@procs) {
37         $p = $pr->{'pid'};
38         local @cols;
39         if (&can_edit_process($pr->{'user'})) {
40                 push(@cols, "<a href=\"edit_proc.cgi?$p\">$p</a>");
41                 }
42         else {
43                 push(@cols, $p);
44                 }
45         push(@cols, $pr->{'user'});
46         push(@cols, $pr->{'cpu'});
47         push(@cols, &html_escape(cut_string($pr->{'args'})));
48         print &ui_columns_row(\@cols);
49         }
50 print &ui_columns_end();
51
52 &ui_print_footer("/", $text{'index'});
53