[%- USE CPScalar; USE Master; SET is_mail_only_theme = CPANEL.CPVAR.mailonlytheme; SET usages = execute_or_die('ResourceUsage', 'get_usages').data; FOR stat = usages; SET is_bytes = (stat.formatter == 'format_bytes') || (stat.formatter == 'format_bytes_per_second') stat.formatted_usage = is_bytes ? locale.format_bytes(stat.usage) : locale.numf(stat.usage); IF (stat.formatter == 'format_bytes_per_second'); stat.formatted_usage = stat.formatted_usage _ '/s'; END; IF stat.maximum.length; IF stat.maximum; stat.show_progress = 1; stat.percent = 100 * stat.usage / stat.maximum; stat.formatted_percent = locale.numf( 0 + stat.percent.sprintf('%.2f') ); END; stat.formatted_max = is_bytes ? locale.format_bytes(stat.maximum) : locale.numf(stat.maximum); #hackery to get a reverse sort on percent but preserve #the API’s normal sort order (which reflects 3rd-party orderings) stat.percent_reverse_sorter = 0 - (stat.percent || 0); IF stat.formatter == 'format_bytes_per_second'; stat.formatted_max = stat.formatted_max _ '/s'; END; ELSE; stat.percent_reverse_sorter = 0; IF stat.formatter == 'format_bytes_per_second'; stat.formatted_max = stat.maximum; ELSE; stat.formatted_max = '∞'; END; END; END; #XXX Should this be done in the API? IF is_mail_only_theme; mail_only_inclusions = { email_accounts => 1, mailing_lists => 1, autoresponders => 1, forwarders => 1, }; END; -%] [% MACRO set_bar_class(test_percent) BLOCK; IF test_percent >= 80; 'progress-bar progress-bar-danger'; ELSIF test_percent >= 60; 'progress-bar progress-bar-warning'; ELSIF test_percent >= 40; 'progress-bar progress-bar-info'; ELSE; 'progress-bar progress-bar-success'; END; END %] [% FOREACH stat IN usages.nsort('percent_reverse_sorter') %] [% NEXT IF is_mail_only_theme && !mail_only_inclusions.${stat.id} -%] [% END %] [% IF CPANEL.feature("serverstatus") %] [% END %]
[% stat.description.html() %] [% IF stat.id == "mysqldatabases" %] [% stat.formatted_usage %] [% ELSE %]
[% stat.formatted_usage %] [% IF stat.formatted_max.length %] / [% stat.formatted_max %] [% END %] [% IF stat.percent >= 80 && varcache.upgrade_app_info %] [%- varcache.upgrade_app_info.itemdesc -%] [% END %]
[% IF stat.show_progress -%]
[% END -%] [% END %]
[% locale.maketext("Server Information") %]