forked from Checkmk/checkmk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdf_magic_number.py
executable file
·31 lines (24 loc) · 1.09 KB
/
df_magic_number.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
#!/usr/bin/env python3
# Copyright (C) 2019 Checkmk GmbH - License: GNU General Public License v2
# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and
# conditions defined in the file COPYING, which is part of this source code package.
import sys
normsize = 20.0
if len(sys.argv) > 1:
normsize = float(sys.argv[1])
def print_levels(level, exp):
sys.stdout.write("f=%3.1f: " % exp)
for size in [5, 10, 20, 50, 100, 300, 800]:
hgb_size = size / normsize # fixed: true-division
felt_size = hgb_size**exp
scale = felt_size / hgb_size # fixed: true-division
new_level = 1 - ((1 - level) * scale)
freegb = size * (1.0 - new_level)
sys.stdout.write(f"{size:4.0f}GB:{new_level * 100:4.0f}%({freegb:3.0f}G) ")
sys.stdout.write("\n")
for level_ in [0.80, 0.85, 0.90, 0.95]:
sys.stdout.write("Level for %.0f GB Normpartition: %d%%\n" % (normsize, int(level_ * 100)))
for exp_ in [1.0, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2]:
print_levels(level_, exp_)
sys.stdout.write("-" * 80)
sys.stdout.write("\n")