forked from siliu-tacc/sanitytool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
diskquota_vast.py
executable file
·34 lines (30 loc) · 1.24 KB
/
diskquota_vast.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from util import capture
import sys
import requests
def diskquota_vast():
# primitive argument input for userid - no error checking
if len(sys.argv)==2:
username=sys.argv[1]
else:
username=capture("whoami").rstrip()
GiB = 1024 * 1024 * 1024
res = requests.get(f"https://portal.chpc.utah.edu/monitoring/storage/vast/~{username}")
if not res:
#print("There was an error communicating with the quota server.")
return
BOLD = '\033[1m'
CLEAR = '\033[0m'
print("[General environment]")
for quota in res.json()["quotas"]:
path = quota["path"]
if path == "/scratch":
path = "/scratch/general/vast"
elif path == "/home/chpc-data" and quota["user_usage_bytes"] < GiB:
continue
usage = f"{BOLD}{quota['user_usage_bytes']/GiB:.2f} GiB{CLEAR}"
if quota["user_quota_bytes"] is not None:
limit = f"{BOLD}{quota['user_quota_bytes']/GiB:.2f} GiB{CLEAR}"
else:
limit = ""
shared_usage_percent = f"{BOLD}{100*quota['shared_usage_bytes']/quota['shared_quota_bytes']:.2f}%{CLEAR}"
print(f"In {path} you have used {usage}{' out of '+limit if limit else ''}. Overall capacity is {shared_usage_percent} full.")