Skip to content

extend debug page to show assigned domain quota#2989

Merged
andryyy merged 5 commits intomailcow:masterfrom
heavygale:patch-5
Oct 2, 2019
Merged

extend debug page to show assigned domain quota#2989
andryyy merged 5 commits intomailcow:masterfrom
heavygale:patch-5

Conversation

@heavygale
Copy link
Copy Markdown
Contributor

This PR extends the disk usage display on the admin's debug page, adding a second progress bar for the total amount of assigned domain quota. This way, the admin can see how much of the available disk space has already been assined to domains, since this disk space must be considered as potentially used. The code can handle disk space overcommitmend, as the progressbar is capped to 100%.

before:
old
after:
new

I changed the dockerapi container to not return human readable values for df, so that the values can be used for calculations. Looks like "df" from dockerapi isn't used elsewhere in mailcow.

adding the amount of assigned domain quota to the disk usage display as potentially used disk space
now only summing up the assigned domain quota for active domains, and not subtracting disc base occupied by mailboxes of inactive domains (inactive_bytes)
- changed dockerapi to not return human readable values for df
- all caluclations now in KiB
- moved code from domain_admin to mailbox functions
- using actual occupied bytes as used quota
- all outputs now in *iB using formatBytes()
@MAGICCC
Copy link
Copy Markdown
Member

MAGICCC commented Oct 2, 2019

Neat, possible to change the color of the bar(s) if you hit a certain threshold of like 75%/90% disk usage?

@andryyy
Copy link
Copy Markdown
Contributor

andryyy commented Oct 2, 2019

What if you assigned more than 100%?

Comment thread data/web/debug.php
$quota_stats = mailbox('get','quota_stats');
$quotaPercent1 = round(($quota_stats['total_quota']/$vmail_df[3])*100);
$quotaPercent2 = round((($quota_stats['total_quota']-$quota_stats['used_bytes'])/$vmail_df[3])*100);
$quotaPercent2 = ($quotaPercent2+$used_percent>100) ? 100-$used_percent : $quotaPercent2;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handling overcommitment -> progressbar is capped to 100%

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mörciii

@andryyy andryyy merged commit b727d24 into mailcow:master Oct 2, 2019
@andryyy
Copy link
Copy Markdown
Contributor

andryyy commented Oct 2, 2019

image

Not really working. Can you fix it?

if 'dir' in request.json:
for container in docker_client.containers.list(filters={"id": container_id}):
df_return = container.exec_run(["/bin/bash", "-c", "/bin/df -H '" + request.json['dir'].replace("'", "'\\''") + "' | /usr/bin/tail -n1 | /usr/bin/tr -s [:blank:] | /usr/bin/tr ' ' ','"], user='nobody')
df_return = container.exec_run(["/bin/bash", "-c", "/bin/df '" + request.json['dir'].replace("'", "'\\''") + "' | /usr/bin/tail -n1 | /usr/bin/tr -s [:blank:] | /usr/bin/tr ' ' ','"], user='nobody')
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andryyy We need a new build of dockerapi, as I removed the -H.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did locally, but the view is broken anyway.

My VM has 100G, the other stuff is wrong, too.

@andryyy
Copy link
Copy Markdown
Contributor

andryyy commented Oct 2, 2019

Plus:

image

@MAGICCC
Copy link
Copy Markdown
Member

MAGICCC commented Oct 2, 2019

@andryyy Possible to revert? We discuss some stuff in IRC

andryyy added a commit that referenced this pull request Oct 2, 2019
fix for "available ≠ total" error in #2989
andryyy added a commit that referenced this pull request Oct 2, 2019
Revert "fix for "available ≠ total" error in #2989"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants