| Linux hosting5.siteguarding.com 3.10.0-962.3.2.lve1.5.88.el7.x86_64 #1 SMP Fri Sep 26 14:06:42 UTC 2025 x86_64 Path : /usr/local/bin/ |
| Current File : //usr/local/bin/bsc_tarstats.py |
#!/usr/bin/python3
# Anatoly Roschenya 2019-01-20
import sys
sizes = {}
try:
for line in sys.stdin:
entry = line.strip().split(maxsplit=5)
#print('entry', entry) #debug
travpath = ''
for dir in entry[5].split('/'):
travpath = travpath + '/' + dir if travpath else dir
#print('travpath', travpath) #debug
if travpath not in sizes: sizes[travpath] = 0
try:
if int(entry[2]): sizes[travpath] += int(entry[2])
except Exception as e:
print("Exception caught", e)
pass
for path,size in sizes.items(): print('{:0.2f}G {}'.format(size/(1024**3),path))
except Exception as e: print("Exception caught", e)