-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathformatting.py
35 lines (26 loc) · 1 KB
/
formatting.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
35
# Functions which formats the metric value for
# the chart. The returned value is between 0 and 100.
def normalize_cpu(metrics, chart_metric):
return 100 - int(metrics[chart_metric])
def normalize_mem(metrics, chart_metric):
return int(metrics[chart_metric])
def normalize_disk(metrics, chart_metric):
return int(metrics[chart_metric])
# Functions which format the display values
# which are shown after the horizontal bar char
def format_cpu_metrics(*args):
cpu_user = float(args[0])
cpu_sys = float(args[1])
cpu_idle = float(args[2])
return (cpu_user, cpu_sys, cpu_idle)
def format_mem_metrics(*args):
mem_used = float(args[0]) / 1024 / 1024
mem_free = float(args[1]) / 1024 / 1024
return (mem_used, mem_free)
def format_disk_metrics(*args):
block_size = float(args[0])
blocks_free = float(args[1])
blocks_total = float(args[2])
free_gb = (blocks_free * block_size) / 1024 / 1024 / 1024
total_gb = (blocks_total * block_size) / 1024 / 1024 / 1024
return (free_gb, total_gb)