/
opt
/
dedrads
/
/opt/dedrads
mkdir
upload
Name
Size
Mode
Actions
account_review/
-
0555
rm
check_software_mods/
-
0555
rm
cms_tools/
-
0555
rm
etc/
-
0555
rm
extras/
-
0555
rm
mailparse/
-
0555
rm
mysql/
-
0555
rm
nlp_scripts/
-
0555
rm
oldrads/
-
0555
rm
perl/
-
0555
rm
provision/
-
0555
rm
python/
-
0555
rm
suspended/
-
0555
rm
__pycache__/
-
0555
rm
account-review
799
0555
edit
dl
rm
allfw
6259
0555
edit
dl
rm
alp.py
16553
0555
edit
dl
rm
autossl_sync
6267
0555
edit
dl
rm
check_apache
9205
0555
edit
dl
rm
check_bandwidth
4546
0555
edit
dl
rm
check_boxtrapper
1684
0555
edit
dl
rm
check_cpu
12212
0555
edit
dl
rm
check_crons
1827
0555
edit
dl
rm
check_dcpumon
1973
0555
edit
dl
rm
check_dns
1827
0555
edit
dl
rm
check_domlogs
61
0555
edit
dl
rm
check_exim
3731
0555
edit
dl
rm
check_hacks
22604
0555
edit
dl
rm
check_imap
5249
0555
edit
dl
rm
check_io
6635
0555
edit
dl
rm
check_max_children
16341
0555
edit
dl
rm
check_mem
1660
0555
edit
dl
rm
check_misc
1510
0555
edit
dl
rm
check_pacct
5201
0555
edit
dl
rm
check_php
4344
0555
edit
dl
rm
check_pop3
2295
0555
edit
dl
rm
check_prov.py
4714
0555
edit
dl
rm
check_server
696
0555
edit
dl
rm
check_size
490
0555
edit
dl
rm
check_software
9849
0555
edit
dl
rm
check_spamd
2426
0555
edit
dl
rm
check_traffic
1933
0555
edit
dl
rm
check_user
1887
0555
edit
dl
rm
clean_exim.py
6390
0555
edit
dl
rm
clusterfix
5343
0555
edit
dl
rm
cmspass.py
3970
0555
edit
dl
rm
cms_check.py
9825
0555
edit
dl
rm
cms_counter.py
36734
0555
edit
dl
rm
cms_creds
713
0555
edit
dl
rm
cms_dumpdb
4485
0555
edit
dl
rm
cms_pw
1416
0555
edit
dl
rm
cpanel-api
7040
0555
edit
dl
rm
cpanel_postgres_manager.py
29004
0555
edit
dl
rm
cpmerge
4631
0555
edit
dl
rm
cpumon
2195
0555
edit
dl
rm
dcpumon.pl
1239
0555
edit
dl
rm
dedcheck
18127
0555
edit
dl
rm
dns-sync
14386
0555
edit
dl
rm
docroot.py
4425
0555
edit
dl
rm
du-tree
7450
0555
edit
dl
rm
envinfo.py
6633
0555
edit
dl
rm
exclude_rbl.py
5249
0555
edit
dl
rm
extract-vhost
2691
0555
edit
dl
rm
filescan
3566
0555
edit
dl
rm
find_warez
1460
0555
edit
dl
rm
first_setup.py
19120
0555
edit
dl
rm
fixwpcron.py
4822
0555
edit
dl
rm
fix_dns_cluster
353
0555
edit
dl
rm
goaccess
1217720
0555
edit
dl
rm
hostsfilemods
4467
0555
edit
dl
rm
imap_io
2323
0555
edit
dl
rm
innodb_converter.py
9343
0555
edit
dl
rm
killall911
530
0555
edit
dl
rm
killdns
941
0555
edit
dl
rm
lastcommcache.sh
1374
0555
edit
dl
rm
legal_lock_down.sh
7450
0555
edit
dl
rm
lil-cpanel
52002
0555
edit
dl
rm
listacct
4575
0555
edit
dl
rm
mailscan
4544
0555
edit
dl
rm
mail_sources.py
7407
0555
edit
dl
rm
megaclisas-status
38664
0555
edit
dl
rm
migrate2central.sh
14418
0555
edit
dl
rm
modify-account
40631
0555
edit
dl
rm
modsec_disable.py
11461
0555
edit
dl
rm
monarxctl
8912
0555
edit
dl
rm
msp.pl
27714
0555
edit
dl
rm
mysql_dstat
474
0555
edit
dl
rm
mysql_selector.py
73102
0555
edit
dl
rm
nlp
4582
0555
edit
dl
rm
procscrape
1863
0555
edit
dl
rm
quarantine
11083
0555
edit
dl
rm
radsfunctions.sh
863
0555
edit
dl
rm
recent-cp
16148
0555
edit
dl
rm
remote_dump
18347
0555
edit
dl
rm
reset_cpanel
3205
0555
edit
dl
rm
server-load
2192
0555
edit
dl
rm
show-conns
20105
0555
edit
dl
rm
show-conns-adv.py
54667
0555
edit
dl
rm
sparta.py
382498
0555
edit
dl
rm
sqltop
27129
0555
edit
dl
rm
telcheck
2411
0555
edit
dl
rm
temprootreset
186
0555
edit
dl
rm
unsuspend_user
1307
0555
edit
dl
rm
unsusprunner.sh
1840
0555
edit
dl
rm
updatednsadmin
526
0555
edit
dl
rm
update_spf
14972
0555
edit
dl
rm
upgrade-check
9216
0555
edit
dl
rm
vhost_data.py
6221
0555
edit
dl
rm
wp-xray.sh
85816
0555
edit
dl
rm
Edit:
/opt/dedrads/du-tree
(7450B)
#!/usr/lib/rads/venv/bin/python3 # By Alex Kostyn # Starting import section ## import sys import math import argparse import subprocess # GLOBALS VERSION = 0.2 # Classes # ALL THE COLORS! class Colors: """ANSI Colors""" clrscr = '\033[2J' clrline = '\033[K' home = '\033[0;0f' xclear = '\033[2J\033[K\033[K' def __init__(self): self.off = '\033[m' self.red = '\033[31m' self.yel = '\033[33m' self.blu = '\033[36m' self.wht = '\033[37m' def bleach(self): self.off = '' self.red = '' self.yel = '' self.blu = '' self.wht = '' # Functions # Used to take bytes and set them to the appropiate names. # Takes an Int that resembles bytes # Returns a string of its human readable size. def convertsize(size): if size == 0: return '0B' size_name = ("KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB") num = int(math.floor(math.log(size, 1024))) power = math.pow(1024, num) size = round(size / power, 2) return f'{size} {size_name[num]}' # Function is just printing the full path with colors. # Depending on the percent of total Disk Usage determins the color of the print def printpath(pppercent, ppsubfilename, ppsubfilesize): if pppercent == 100: print(ppsubfilename + "\t" + ppsubfilesize) if args.verbose: print("@ " + str(pppercent) + "%") elif pppercent > 60: print( termColor.red + ppsubfilename + "\t" + ppsubfilesize + termColor.off ) if args.verbose: print("@ " + str(pppercent) + "%") elif pppercent > 40: print( termColor.yel + ppsubfilename + "\t" + ppsubfilesize + termColor.off ) if args.verbose: print("@ " + str(pppercent) + "%") elif pppercent > 20: print( termColor.blu + ppsubfilename + "\t" + ppsubfilesize + termColor.off ) if args.verbose: print("@ " + str(pppercent) + "%") elif 20 > pppercent > 10: print(ppsubfilename + "\t" + ppsubfilesize) if args.verbose: print("@ " + str(pppercent) + "%") # Prints out just the file like old du-tree. # Depending on the percent of total Disk Usage determins the color of the print # Each tab is replaced with two spaces. def printfile(pfpercent, pfsubfilename, pfsubfilesize): splitsubfilename = pfsubfilename.split("/") spacenumber = pfsubfilename.count("/") * 2 if pfpercent == 100: print(pfsubfilename + "\t" + pfsubfilesize) if args.verbose: print("@ " + str(pfpercent) + "%") elif pfpercent > 60: print( termColor.red + " " * spacenumber + splitsubfilename[-1] + "\t" + pfsubfilesize + termColor.off ) if args.verbose: print("@ " + str(pfpercent) + "%") elif pfpercent > 40: print( termColor.yel + " " * spacenumber + splitsubfilename[-1] + "\t" + pfsubfilesize + termColor.off ) if args.verbose: print("@ " + str(pfpercent) + "%") elif pfpercent > 20: print( termColor.blu + " " * spacenumber + splitsubfilename[-1] + "\t" + pfsubfilesize + termColor.off ) if args.verbose: print("@ " + str(pfpercent) + "%") elif 20 > pfpercent > 10: print(" " * spacenumber + splitsubfilename[-1] + "\t" + pfsubfilesize) if args.verbose: print("@ " + str(pfpercent) + "%") # --- Entry --- # # Starting ArgParser: parser = argparse.ArgumentParser(description='DU formatter') # Run on any directory. parser.add_argument( 'directory', help="The directory you want to scan.", nargs="*" ) # Generic version speal. parser.add_argument( '-V', '--version', action='version', version='%(prog)s, Version: ' + str(VERSION), ) # Prints everything. # Is more useful for me dubugging the code. parser.add_argument( '-v', '--verbose', action='store_true', help="Prints everything the program is doing.", ) # Prints a legend showing what each color means. parser.add_argument( '-l', '--legend', action='store_true', help="Prints color legend before running.", ) # Clear colors from output. parser.add_argument( '-b', '--bleach', action='store_true', help="Removes color from output" ) # Prints full path. parser.add_argument( '-f', '--full', action='store_true', help="Prints full path" ) # Doing the needful. args = parser.parse_args() # Setting Variables. depth = 5 dirs = args.directory termColor = Colors() if args.bleach: termColor.bleach() # Printing legend if argument was passed. # Specifically showing what colors mean what. if args.legend: print("\n --- Color Legend --- ") print( termColor.red + " [*] Greater than 60% overall usage." + termColor.off ) print( termColor.yel + " [*] Greater than 40% overall usage." + termColor.off ) print( termColor.blu + " [*] Greater than 20% overall usage." + termColor.off ) print("\n") # Running the command and sending the output to a variable # Running without human readable for acuracy. # stderr = subprocess.PIPE to hide permission denied messages. # same with stdout = subprocess.PIPE if not args.bleach: print("Running Du", end=' ') sys.stdout.flush() command = ["/usr/bin/du", "--max-depth=" + str(depth)] # Adding dirs to the end of the command. for i in dirs: command.append(i) with subprocess.Popen( command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="utf-8", errors="ignore", ) as proc: output = proc.communicate() if not args.bleach: print("\rComplete: ") # More for dubugging purposes if args.verbose: print(output) # Trimming the output. # Command is stored in a Tuple. # Grabbing just the first element. # Splitting via '\n' Then storing in an array. FormattedOutPut = output[0] FormattedOutPut = FormattedOutPut.splitlines() # Going through each element of the output to find the base dir. # The base dir will always be the largest # Each item is seperated with a tab, therefore I split each line by '\t' # Casted baseDirSize in comparison for better calculations. count = 0 baseDir = "" baseDirSize = 0 for line in FormattedOutPut: count += 1 dirSize = int(line.split('\t')[0]) if dirSize > int(baseDirSize): if args.verbose: print(str(dirSize) + " > " + str(baseDirSize)) baseDirSize = dirSize baseDir = line.split('\t')[1] # Going through and outputing large folders / files # Converted baseDirSize to an float before doing anything. # Reversing the list so that it makes more sense. # To grab the percent you set both file size vars to floats, # then you deivide sub/base, then multiply it by 100. # Converted to int to remove the decimal. baseDirSize = float(baseDirSize) for line in reversed(FormattedOutPut): subFileSize = float(line.split('\t')[0]) subFileName = line.split('\t')[1] percent = int(subFileSize / baseDirSize * 100) subFileSize = convertsize(subFileSize) if args.full: printpath(percent, subFileName, subFileSize) else: printfile(percent, subFileName, subFileSize)
Save
cmd:
run