-
Notifications
You must be signed in to change notification settings - Fork 6
/
lab_usage_qos.awk
81 lines (72 loc) · 2.36 KB
/
lab_usage_qos.awk
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/awk -f
@include "mycolors.awk"
BEGIN {
FS="[ :|=,]";
printf("| %14s |","Username");
printf(" %3s | %3s | %3s |", "N-R", "O-R", "R");
printf("\n");
printf("| %14s |","--------------");
printf(" %3s + %3s + %3s |", "---", "---", "---");
printf("\n");
}
{
if ($1 == "G>") {
# for overcap jobs, assign lab arbitrarily
if ($14 == "overcap"){
lab=user_to_lab[$2]
}
else{
lab=$13
}
gpu_counts[lab][$2][$3]+=$12;
gpu_counts[lab][$2][$3,$4]+=$12;
gpu_counts[lab][$2]["R"]+=0;
gpu_counts[lab][$2]["R","normal"]+=0;
gpu_counts[lab][$2]["R","overcap"]+=0;
labs_to_gpus_used[lab][$3]+=$12;
lab_totals[lab][$3]+=$12;
lab_totals[lab][$3,$4]+=$12;
} else {
if ($5 == "gres/gpu") {
labs_to_gpus[$1] += $12;
labs_to_cpus[$1] += $4;
} else {
if ($1 != "overcap") {
user_to_lab[$2]=$1;
}
}
}
}
END {
for (lab in labs_to_gpus) {
if (lab == "guest-lab") {
continue;
}
print_str = sprintf("[ %d/%d/%d ]", labs_to_gpus_used[lab]["R"], labs_to_gpus_used[lab]["PD"], labs_to_gpus[lab])
printf("| %14s | %-15s |\n", lab, print_str);
if (lab in gpu_counts) {
for (name in gpu_counts[lab]){
printf("| %14s |",name);
# printf(" %3d |",gpu_counts[name]["R","normal"]);
# printf(" %3d |",gpu_counts[name]["R","overcap"]);
# printf(" %3d |",gpu_counts[name]["R"]);
# Colorized
printf(" %s |",colour_int(gpu_counts[lab][name]["R","normal"]));
printf(" %s |",colour_int(gpu_counts[lab][name]["R","overcap"]));
printf(" %s |",colour_int(gpu_counts[lab][name]["R"]));
printf("\n");
}
}
printf("| %14s |","");
printf(" %3s + %3s + %3s |", "---", "---", "---");
printf("\n");
printf("| %14s :","totals");
printf(" %3d |",lab_totals[lab]["R","normal"]);
printf(" %3d |",lab_totals[lab]["R","overcap"]);
printf(" %3d |",lab_totals[lab]["R"]);
printf("\n");
printf("| %14s |","--------------");
printf(" %3s + %3s + %3s |", "---", "---", "---");
printf("\n");
}
}