webmin / authentic-theme

Official theme for the best server management panel of the 21st Century
https://authentic-theme.com
MIT License
947 stars 163 forks source link

Quotas Bar Charts Incorrect #110

Closed clawrie closed 9 years ago

clawrie commented 9 years ago

Bars for disk quotas in System Information are not accurate. Please refer to attached image. quotas

7starsone commented 9 years ago

Yes, it works ;-)

iliajie commented 9 years ago

Alright, please update to version 10.1.0. Does it fully fix your problem?

drkskwlkr commented 9 years ago

Attached VAR output as requested (four quota entries in my list):

$VAR1 = { 'desc' => 'Domain1', 'chart' => [ '1157619712', 818016256, 339603456 ], 'value' => '1.08 GB' };

$VAR1 = { 'desc' => 'Domain2', 'value' => '1.02 GB', 'chart' => [ '1157619712', 1088880640, 6811648 ] };

$VAR1 = { 'desc' => 'Domain3', 'value' => '61.32 MB', 'chart' => [ '1157619712', 61534208, 2760704 ] };

$VAR1 = { 'desc' => 'Domain4', 'value' => '208 kB', 'chart' => [ '1157619712', 212992, 0 ] };

iliajie commented 9 years ago

From what I can see you have old buged type output. You ether didn't update Virtualmin or still have old, cache version of the lib files in memory... Try to double check please. When I get to PC I will post more things to check. If it persists will create a bug to Virtualmin team.

drkskwlkr commented 9 years ago

I restarted webmin (service webmin restart) and rebooted the server but nothing changed. I am positive that I am running the latest version of Virtualmin (4.15gpl-2)

iliajie commented 9 years ago

What is the content of:

  1. authentic-theme/sysinfo.cgi line 40-50
  2. virtual-server/system_info.pl line 285-363

Besides, what is your version of Webmin?

drkskwlkr commented 9 years ago

Contents of /usr/share/webmin/authentic-theme/sysinfo.cgi, line 40-50

    : ''
) . '</h3>' . "\n";

print '</div>';
print '<div class="panel-body">' . "\n";

# Get system info to show
my @info = &list_combined_system_info( { 'qshow', 1 } );

if ( $level == 0 ) {

Contents of /usr/share/webmin/virtual-server/system_info.pl, line 285-363

# Top quota users
my @quota = $info->{'quota'} ?
                grep { &can_edit_domain($_->[0]) } @{$info->{'quota'}} : ( );
if (!$data->{'noquotas'} && @quota && (&master_admin() || &reseller_admin())) {
        my @usage;
        my $max = $data->{'max'} || 10;
        my $maxquota = $info->{'maxquota'};

        # Work out if showing by percent makes sense
        my $qshow = $data->{'qshow'};
        if ($qshow) {
                my @quotawithlimit = grep { $_->[2] } @quota;
                $qshow = 0 if (!@quotawithlimit);
                }

        # Limit to those with a quota limit, if showing a percent
        if ($qshow) {
                @quota = grep { $_->[2] } @quota;
                }

        if ($qshow) {
                # Sort by percent used
                @quota = grep { $_->[2] } @quota;
                @quota = sort { ($b->[1]+$b->[3])/$b->[2] <=>
                                ($a->[1]+$a->[3])/$a->[2] } @quota;
                }
        else {
                # Sort by usage
                @quota = sort { $b->[1]+$b->[3] <=> $a->[1]+$a->[3] } @quota;
                }

        # Message above list
        my $qmsg;
        if (@quota > $max) {
                @quota = @quota[0..($max-1)];
                $qmsg = &text('right_quotamax', $max);
                }
        elsif (&master_admin()) {
                $qmsg = $text{'right_quotaall'};
                }
        else {
                $qmsg = $text{'right_quotayours'};
                }

        my $open = 0;
        foreach my $q (@quota) {
                my $cmd = &can_edit_domain($q->[0]) ? "edit_domain.cgi"
                                                    : "view_domain.cgi";
                my $chart = { 'desc' => &ui_link(
                        '/'.$module_name.'/'.$cmd.'?dom='.$q->[0]->{'id'},
                         &show_domain_name($q->[0])) };
                if ($qshow) {
                        # By percent used
                        my $qpc = int($q->[1]*100 / $q->[2]);
                        my $dpc = int($q->[3]*100 / $q->[2]);
                        $chart->{'chart'} = [ 100, $qpc, $dpc ];
                        }
                else {
                        # By actual usage
                        $chart->{'chart'} = [ $maxquota, $q->[1], $q->[3] ];
                        }
                if ($q->[2]) {
                        # Show used and limit
                        my $pc = int(($q->[1]+$q->[3])*100 / $q->[2]);
                        $pc = "&nbsp;$pc" if ($pc < 10);
                        $chart->{'value'} = &text('right_out',
                                                  &nice_size($q->[1]+$q->[3]),
                                                  &nice_size($q->[2]));
                        }
                else {
                        # Just show used
                        $chart->{'value'} = &nice_size($q->[1]+$q->[3]);
                        }
                if ($q->[2] && $q->[1]+$q->[3] >= $q->[2]) {
                        # Domain is over quota
                        $open = 1;
                        }
                push(@usage, $chart);
                }

Webmin version is 1.730

drkskwlkr commented 9 years ago

Sure, let's wait and see if the Webmin devs can say something more. I will patch the sysinfo.pl file as suggested && remain at your disposal to troubleshoot this thing. Thank you for your time!

iliajie commented 9 years ago

Do you have anything changed in Virtualmin->Configuration, like external/custom commands or something? Or other quotas settings?

drkskwlkr commented 9 years ago

No, I don't think so. I am not very experienced in Linux server administration and avoid touching anything whose purpose is not clear to me. I have no custom commands regarding quotas in Virtualmin->Configuration; I have defined the quotas for the different virtual servers via Edit Virtual Server->Quotas and Limits.

drkskwlkr commented 9 years ago

Heh. The problem got solved by itself.

I decided to reset the quotas (by writing 2048 MB instead of 2GB) just to see what would happen and as soon as I did this for all four virtual servers, the chart started showing the proper units (I have not yet patched the authentic-theme/sysinfo.pl file).

iliajie commented 9 years ago

Alright, it's cache problem. Jamie is aware! Thanks for reporting!