#!/usr/local/bin/perl # Show server or domain information BEGIN { push(@INC, ".."); }; use WebminCore; &init_config(); &ReadParse(); &load_theme_library(); if (&get_product_name() eq "usermin") { $level = 3; } else { $level = 0; } %text = &load_language($current_theme); $bar_width = 300; foreach $o (split(/\0/, $in{'open'})) { push(@open, $o); $open{$o} = 1; } &popup_header(undef, &capture_function_output(\&WebminCore::theme_prehead)); print "
\n"; # Webmin logo if (&get_product_name() eq 'webmin') { print "

\n"; } if ($level == 0) { # Show general system information print "\n"; # Host and login info print "\n"; print "\n"; print "\n"; if ($gconfig{'os_version'} eq '*') { print "\n"; } else { print "\n"; } print "\n"; print "\n"; # System time $tm = localtime(time()); print "\n"; print "\n"; # Kernel and CPU $out = &backquote_command( "uname -r 2>/dev/null ; uname -m 2>/dev/null ; uname -s 2>/dev/null"); local ($r, $m, $o) = split(/\r?\n/, $out); print "\n"; print "\n"; # System uptime $out = &backquote_command("uptime"); $uptime = undef; if ($out =~ /up\s+(\d+)\s+days,\s+(\d+):(\d+)/) { # up 198 days, 2:06 $uptime = &text('right_updays', int($1), int($2), int($3)); } elsif ($out =~ /up\s+(\d+)\s+days,\s+(\d+)\s+min/) { # up 198 days, 10 mins $uptime = &text('right_updays', int($1), 0, int($2)); } elsif ($out =~ /up\s+(\d+):(\d+)/) { # up 3:10 $uptime = &text('right_uphours', int($1), int($2)); } elsif ($out =~ /up\s+(\d+)\s+mins/) { # up 45 mins $uptime = &text('right_upmins', int($1)); } if ($uptime) { print "\n"; print "\n"; } # Load and memory info if (&foreign_check("proc")) { &foreign_require("proc", "proc-lib.pl"); if (defined(&proc::get_cpu_info)) { @c = &proc::get_cpu_info(); if (@c) { print "\n"; print "\n"; } } if (defined(&proc::get_memory_info)) { @m = &proc::get_memory_info(); if (@m && $m[0]) { print "\n"; print "\n"; print "\n"; print "\n"; } if (@m && $m[2]) { print "\n"; print "\n"; print "\n"; print "\n"; } } #@procs = &proc::list_processes(); #print "\n"; #print "\n"; } # Disk space on local drives if (&foreign_check("mount")) { &foreign_require("mount", "mount-lib.pl"); ($total, $free) = &mount::local_disk_space(); if ($total) { print "\n"; print "\n"; print "\n"; print "\n"; } } print "
$text{'right_host'}",&get_system_hostname(),"
$text{'right_os'}$gconfig{'real_os_type'}
$gconfig{'real_os_type'} $gconfig{'real_os_version'}
$text{'right_webmin'}",&get_webmin_version(),"
$text{'right_time'}$tm
$text{'right_kernel'}",&text('right_kernelon', $o, $r, $m),"
$text{'right_uptime'}$uptime
$text{'right_cpu'}",&text('right_load', @c),"
$text{'right_real'}",&text('right_used', &nice_size($m[0]*1024), &nice_size(($m[0]-$m[1])*1024)), "
",&bar_chart($m[0], $m[0]-$m[1], 1), "
$text{'right_virt'}",&text('right_used', &nice_size($m[2]*1024), &nice_size(($m[2]-$m[3])*1024)), "
",&bar_chart($m[2], $m[2]-$m[3], 1), "
$text{'right_procs'}",scalar(@procs),"
$text{'right_disk'}",&text('right_used', &nice_size($total), &nice_size($total-$free)),"
",&bar_chart($total, $total-$free, 1), "
\n"; # Check for incorrect OS if (&foreign_check("webmin")) { &foreign_require("webmin", "webmin-lib.pl"); &webmin::show_webmin_notifications(); } } elsif ($level == 3) { # Show Usermin user's information print "

$text{'right_header5'}

\n"; print "\n"; # Host and login info print "\n"; print "\n"; print "\n"; if ($gconfig{'os_version'} eq '*') { print "\n"; } else { print "\n"; } print "\n"; print "\n"; # System time $tm = localtime(time()); print "\n"; print "\n"; # Disk quotas if (&foreign_installed("quota")) { &foreign_require("quota", "quota-lib.pl"); $n = "a::user_filesystems($remote_user); $usage = 0; $quota = 0; for($i=0; $i<$n; $i++) { if ($quota::filesys{$i,'hblocks'}) { $quota += $quota::filesys{$i,'hblocks'}; $usage += $quota::filesys{$i,'ublocks'}; } elsif ($quota::filesys{$i,'sblocks'}) { $quota += $quota::filesys{$i,'sblocks'}; $usage += $quota::filesys{$i,'ublocks'}; } } if ($quota) { $bsize = $quota::config{'block_size'}; print "\n"; print "\n"; print "\n"; print "\n"; } } print "
$text{'right_host'}",&get_system_hostname(),"
$text{'right_os'}$gconfig{'real_os_type'}
$gconfig{'real_os_type'} $gconfig{'real_os_version'}
$text{'right_usermin'}",&get_webmin_version(),"
$text{'right_time'}$tm
$text{'right_uquota'}",&text('right_out', &nice_size($usage*$bsize), &nice_size($quota*$bsize)),"
",&bar_chart($quota, $usage, 1), "
\n"; } print "
\n"; &popup_footer(); # bar_chart(total, used, blue-rest) # Returns HTML for a bar chart of a single value sub bar_chart { local ($total, $used, $blue) = @_; local $rv; $rv .= sprintf "", int($bar_width*$used/$total)+1; if ($blue) { $rv .= sprintf "", $bar_width - int($bar_width*$used/$total)-1; } else { $rv .= sprintf "", $bar_width - int($bar_width*$used/$total)-1; } return $rv; } # bar_chart_three(total, used1, used2, used3) # Returns HTML for a bar chart of three values, stacked sub bar_chart_three { local ($total, $used1, $used2, $used3) = @_; local $rv; local $w1 = int($bar_width*$used1/$total)+1; local $w2 = int($bar_width*$used2/$total); local $w3 = int($bar_width*$used3/$total); $rv .= sprintf "", $w1; $rv .= sprintf "", $w2; $rv .= sprintf "", $w3; $rv .= sprintf "", $bar_width - $w1 - $w2 - $w3; return $rv; } # collapsed_header(text, name) sub collapsed_header { local ($text, $name) = @_; print "
"; local $others = join("&", map { "open=$_" } grep { $_ ne $name } @open); $others = "&$others" if ($others); if ($open{$name}) { print "\n"; print "$text"; } else { print "\n"; print "$text"; } print "
\n"; return $open{$name}; }