2 # Show server or domain information
4 BEGIN { push(@INC, ".."); };
9 if (&get_product_name() eq "usermin") {
15 %text = &load_language($current_theme);
17 foreach $o (split(/\0/, $in{'open'})) {
22 $prehead = defined(&WebminCore::theme_prehead) ?
23 &capture_function_output(\&WebminCore::theme_prehead) : "";
24 &popup_header(undef, $prehead);
28 if (&get_product_name() eq 'webmin') {
29 print "<a href=http://www.webmin.com/ target=_new><img src=images/webmin-blue.png border=0></a><p>\n";
33 # Show general system information
34 print "<table width=70%>\n";
36 # Ask status module for collected info
37 &foreign_require("system-status");
38 $info = &system_status::get_collected_info();
41 $ip = $info && $info->{'ips'} ? $info->{'ips'}->[0]->[0] :
42 &to_ipaddress(get_system_hostname());
43 $ip = " ($ip)" if ($ip);
44 print "<tr> <td><b>$text{'right_host'}</b></td>\n";
45 print "<td>",&get_system_hostname(),$ip,"</td> </tr>\n";
48 print "<tr> <td><b>$text{'right_os'}</b></td>\n";
49 if ($gconfig{'os_version'} eq '*') {
50 print "<td>$gconfig{'real_os_type'}</td> </tr>\n";
53 print "<td>$gconfig{'real_os_type'} $gconfig{'real_os_version'}</td> </tr>\n";
57 print "<tr> <td><b>$text{'right_webmin'}</b></td>\n";
58 print "<td>",&get_webmin_version(),"</td> </tr>\n";
61 $tm = localtime(time());
62 print "<tr> <td><b>$text{'right_time'}</b></td>\n";
63 if (&foreign_available("time")) {
64 $tm = "<a href=time/>$tm</a>";
66 print "<td>$tm</td> </tr>\n";
69 if ($info->{'kernel'}) {
70 print "<tr> <td><b>$text{'right_kernel'}</b></td>\n";
71 print "<td>",&text('right_kernelon',
72 $info->{'kernel'}->{'os'},
73 $info->{'kernel'}->{'version'},
74 $info->{'kernel'}->{'arch'}),"</td> </tr>\n";
78 if ($info->{'load'}) {
79 @c = @{$info->{'load'}};
81 print "<tr> <td><b>$text{'right_cpuinfo'}</b></td>\n";
82 print "<td>",&text('right_cputype', @c),"</td> </tr>\n";
87 &foreign_require("proc");
89 my ($d, $h, $m) = &proc::get_system_uptime();
91 $uptime = &text('right_updays', $d, $h, $m);
94 $uptime = &text('right_uphours', $h, $m);
97 $uptime = &text('right_upmins', $m);
100 print "<tr> <td><b>$text{'right_uptime'}</b></td>\n";
101 print "<td>$uptime</td> </tr>\n";
105 if (&foreign_check("proc")) {
106 @procs = &proc::list_processes();
107 $pr = scalar(@procs);
108 print "<tr> <td><b>$text{'right_procs'}</b></td>\n";
109 if (&foreign_available("proc")) {
110 $pr = "<a href=proc/>$pr</a>";
112 print "<td>$pr</td> </tr>\n";
116 if ($info->{'load'}) {
117 @c = @{$info->{'load'}};
119 print "<tr> <td><b>$text{'right_cpu'}</b></td>\n";
120 print "<td>",&text('right_load', @c),"</td> </tr>\n";
125 if ($info->{'cpu'}) {
126 @c = @{$info->{'cpu'}};
127 print "<tr> <td><b>$text{'right_cpuuse'}</b></td>\n";
128 print "<td>",&text('right_cpustats', @c),"</td> </tr>\n";
132 if ($info->{'mem'}) {
133 @m = @{$info->{'mem'}};
135 print "<tr> <td><b>$text{'right_real'}</b></td>\n";
136 print "<td>",&text('right_used',
137 &nice_size($m[0]*1024),
138 &nice_size(($m[0]-$m[1])*1024)),
140 print "<tr> <td></td>\n";
141 print "<td>",&bar_chart($m[0], $m[0]-$m[1], 1),
146 print "<tr> <td><b>$text{'right_virt'}</b></td>\n";
147 print "<td>",&text('right_used',
148 &nice_size($m[2]*1024),
149 &nice_size(($m[2]-$m[3])*1024)),
151 print "<tr> <td></td>\n";
152 print "<td>",&bar_chart($m[2], $m[2]-$m[3], 1),
157 # Disk space on local drives
158 if ($info->{'disk_total'}) {
159 ($total, $free) = ($info->{'disk_total'}, $info->{'disk_free'});
160 print "<tr> <td><b>$text{'right_disk'}</b></td>\n";
161 print "<td>",&text('right_used',
163 &nice_size($total-$free)),"</td> </tr>\n";
164 print "<tr> <td></td>\n";
165 print "<td>",&bar_chart($total, $total-$free, 1),
170 if ($info->{'poss'}) {
171 print "<tr> <td><b>$text{'right_updates'}</b></td>\n";
172 @poss = @{$info->{'poss'}};
173 @secs = grep { $_->{'security'} } @poss;
174 if (@poss && @secs) {
175 $msg = &text('right_upsec', scalar(@poss),
179 $msg = &text('right_upneed', scalar(@poss));
182 $msg = $text{'right_upok'};
184 if (&foreign_available("package-updates")) {
185 $msg = "<a href='package-updates/index.cgi?mode=updates'>$msg</a>";
187 print "<td>$msg</td> </tr>\n";
192 # Check for incorrect OS
193 if (&foreign_check("webmin")) {
194 &foreign_require("webmin", "webmin-lib.pl");
195 &webmin::show_webmin_notifications();
198 elsif ($level == 3) {
199 # Show Usermin user's information
200 print "<h3>$text{'right_header5'}</h3>\n";
201 print "<table width=70%>\n";
203 # Host and login info
204 print "<tr> <td><b>$text{'right_host'}</b></td>\n";
205 print "<td>",&get_system_hostname(),"</td> </tr>\n";
207 print "<tr> <td><b>$text{'right_os'}</b></td>\n";
208 if ($gconfig{'os_version'} eq '*') {
209 print "<td>$gconfig{'real_os_type'}</td> </tr>\n";
212 print "<td>$gconfig{'real_os_type'} $gconfig{'real_os_version'}</td> </tr>\n";
215 print "<tr> <td><b>$text{'right_usermin'}</b></td>\n";
216 print "<td>",&get_webmin_version(),"</td> </tr>\n";
219 $tm = localtime(time());
220 print "<tr> <td><b>$text{'right_time'}</b></td>\n";
221 print "<td>$tm</td> </tr>\n";
224 if (&foreign_installed("quota")) {
225 &foreign_require("quota", "quota-lib.pl");
226 $n = "a::user_filesystems($remote_user);
229 for($i=0; $i<$n; $i++) {
230 if ($quota::filesys{$i,'hblocks'}) {
231 $quota += $quota::filesys{$i,'hblocks'};
232 $usage += $quota::filesys{$i,'ublocks'};
234 elsif ($quota::filesys{$i,'sblocks'}) {
235 $quota += $quota::filesys{$i,'sblocks'};
236 $usage += $quota::filesys{$i,'ublocks'};
240 $bsize = $quota::config{'block_size'};
241 print "<tr> <td><b>$text{'right_uquota'}</b></td>\n";
242 print "<td>",&text('right_out',
243 &nice_size($usage*$bsize),
244 &nice_size($quota*$bsize)),"</td> </tr>\n";
245 print "<tr> <td></td>\n";
246 print "<td>",&bar_chart($quota, $usage, 1),
256 # bar_chart(total, used, blue-rest)
257 # Returns HTML for a bar chart of a single value
260 local ($total, $used, $blue) = @_;
262 $rv .= sprintf "<img src=images/red.gif width=%s height=10>",
263 int($bar_width*$used/$total)+1;
265 $rv .= sprintf "<img src=images/blue.gif width=%s height=10>",
266 $bar_width - int($bar_width*$used/$total)-1;
269 $rv .= sprintf "<img src=images/white.gif width=%s height=10>",
270 $bar_width - int($bar_width*$used/$total)-1;
275 # bar_chart_three(total, used1, used2, used3)
276 # Returns HTML for a bar chart of three values, stacked
279 local ($total, $used1, $used2, $used3) = @_;
281 local $w1 = int($bar_width*$used1/$total)+1;
282 local $w2 = int($bar_width*$used2/$total);
283 local $w3 = int($bar_width*$used3/$total);
284 $rv .= sprintf "<img src=images/red.gif width=%s height=10>", $w1;
285 $rv .= sprintf "<img src=images/purple.gif width=%s height=10>", $w2;
286 $rv .= sprintf "<img src=images/blue.gif width=%s height=10>", $w3;
287 $rv .= sprintf "<img src=images/grey.gif width=%s height=10>",
288 $bar_width - $w1 - $w2 - $w3;
292 # collapsed_header(text, name)
295 local ($text, $name) = @_;
296 print "<br><font style='font-size:16px'>";
297 local $others = join("&", map { "open=$_" } grep { $_ ne $name } @open);
298 $others = "&$others" if ($others);
300 print "<img src=images/open.gif border=0>\n";
301 print "<a href='right.cgi?$others'>$text</a>";
304 print "<img src=images/closed.gif border=0>\n";
305 print "<a href='right.cgi?open=$name$others'>$text</a>";
307 print "</font><br>\n";