#!/usr/local/bin/perl # Show server or domain information use strict; use warnings; require 'gray-theme/gray-theme-lib.pl'; &ReadParse(); &load_theme_library(); our ($current_theme); our %text = &load_language($current_theme); my $bar_width = 300; my $prehead = defined(&WebminCore::theme_prehead) ? &capture_function_output(\&WebminCore::theme_prehead) : ""; &popup_header(undef, $prehead); print "
\n"; # Webmin logo if (&get_product_name() eq 'webmin') { print "

\n"; } # Get system info to show my @info = &list_combined_system_info(); foreach my $info (@info) { print &ui_table_start($info->{'desc'}, "width=600", 2); if ($info->{'type'} eq 'table') { # A table of various labels and values foreach my $t (@{$info->{'table'}}) { my $chart = ""; if ($t->{'chart'}) { my $chart = &make_bar_chart($t->{'chart'}); $chart = "
".$chart; } print &ui_table_row($t->{'desc'}, $t->{'value'}.$chart); } } elsif ($info->{'type'} eq 'chart') { # A table of graphs my $ctable = &ui_columns_start($info->{'titles'}); foreach my $t (@{$info->{'chart'}}) { $ctable .= &ui_columns_row([ $t->{'desc'}, &make_bar_chart($t->{'chart'}), $t->{'value'}, ]); } $ctable .= &ui_columns_end(); print &ui_table_row(undef, $ctable, 2); } print &ui_table_end(); } print "

\n"; &popup_footer(); # bar_chart_three(total, used1, used2, used3) # Returns HTML for a bar chart of three values, stacked sub bar_chart_three { my ($total, $used1, $used2, $used3) = @_; my $rv; my $w1 = int($bar_width*$used1/$total)+1; my $w2 = int($bar_width*$used2/$total); my $w3 = int($bar_width*$used3/$total); $rv .= sprintf "", $w1; $rv .= sprintf "", $w2; $rv .= sprintf "", $w3; $rv .= sprintf "", $bar_width - $w1 - $w2 - $w3; return $rv; } sub make_bar_chart { my ($c) = @_; my @c = @$c; if (@c == 2) { return &bar_chart_three( $c[0], $c[1], 0, $c[0]-$c[1]); } else { return &bar_chart_three( $c[0], $c[1], $c[2], $c[0]-$c[1]-$c[2]); } }