-
Notifications
You must be signed in to change notification settings - Fork 6
/
node_usage.awk
186 lines (175 loc) · 6.26 KB
/
node_usage.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#!/bin/awk -f
@include "mycolors.awk"
BEGIN {
FS="[ :|=*]";
# printf("| %14s |","Username");
# printf(" %3s | %3s | %3s |", "R", "PD", "CG");
# printf("\n");
#
# printf("| %14s |","--------------");
# printf(" %3s + %3s + %3s |", "---", "---", "---");
# printf("\n");
# # hack to use attributes for just "None"
# noc = colour("None");
# red = colour("Red");
# cln = noc;
i = 0;
# Fixed parameters
CPU_PER_JOB_LIMIT = 14;
CPU_PER_GPU_USE_LIMIT = 20;
CPU_THREADS_PER_NODE = 56;
}
{
if ($1 == "G>") {
# counts[$2][$3]+=$NF;
# counts[$2][$3,$4]+=$NF;
#
# counts[$2]["R"]+=0;
# counts[$2]["PD"]+=0;
# counts[$2]["CG"]+=0;
#
# labs_to_gpus_used[user_to_lab[$2]][$3]+=$NF;
if ($5 == "(null)" || $6 == 0) {
cpu_jobs[$2] += 1
} else {
gpus_used[$2] += $6
gpus_used[$2,$7] += $6
gpu_jobs[$2] += 1
}
total_jobs[$2] += 1
} else {
# if ($3 == "gres/gpu") {
# labs_to_gpus[$1] += $4;
# } else {
# user_to_lab[$2] = $1;
# }
if ($1 != "HOSTNAMES"){
# print(i, $1)
node_names[i++] = $1
total_i = i
total_gpus[$1] = $3
cpu_load[$1] = $4
free_mem[$1] = $5
state[$1] = $8
}
}
}
END {
printf("| %11s |","-----------");
printf(" %s + %s + %s + %s + %s + %s |",
"---", "------------", "---", "---", "---", "----------");
printf("\n");
printf("| %11s |","Node");
printf(" %3s | %8s | %3s | %3s | %3s | %10s |",
"G/T", "GJ + CJ = T", "CPU", "/TJ", "/GU", "state");
printf("\n");
printf("| %11s |","-----------");
printf(" %s + %s + %s + %s + %s + %s |",
"---", "------------", "---", "---", "---", "----------");
printf("\n");
for (i=0; i<total_i; i++) {
node = node_names[i];
# print(i, node)
if (state[node] == "down" || state[node] == "drained") {
# printf("| %s is down!\n",node)
continue
} else {
cpu_per_job_str = "N/A"
cpu_per_gpu_use_str = "N/A"
clr = noc; cl1 = noc; cl2 = noc; cl3 = noc;
if (state[node] == "drained" || state[node] == "draining" ) {
cls = colour("Yellow");
clr = cls;
} else if (state[node] == "idle") {
cls = colour("Green");
clr = cls;
} else {
cls = cln;
}
if (total_jobs[node] > 0){
cpu_per_job = cpu_load[node] / total_jobs[node]
cpu_per_job_str = sprintf("%d", cpu_per_job)
if (cpu_per_job > CPU_PER_JOB_LIMIT && cpu_load[node] > CPU_THREADS_PER_NODE) {
clr = red;
cl2 = red;
# printf("> %s <\n", cpu_per_job_str)
}
}
if (gpus_used[node] > 0){
cpu_per_gpu_use = cpu_load[node] / gpus_used[node]
cpu_per_gpu_use_str = sprintf("%d", cpu_per_gpu_use)
if (cpu_per_gpu_use > CPU_PER_GPU_USE_LIMIT && cpu_load[node] > CPU_THREADS_PER_NODE) {
clr = red;
cl3 = red;
# printf("> %s <\n", cpu_per_job_str)
}
}
if (cpu_load[node] > 100) {
clr = red;
cl1 = red;
}
printf("| %s%11s%s |",clr, node, cln)
printf(\
" %s/%d |",
# gpus_used[node],
colour_int_custom(gpus_used[node],colour("Magenta"),0),
total_gpus[node]\
)
# _str = sprintf(\
# "%s+%d=%d",
# # gpu_jobs[node],
# colour_int_custom(gpu_jobs[node],colour("Magenta")),
# cpu_jobs[node],
# total_jobs[node])
# # printf(" %8s |", _str)
# printf(" %16s |", _str)
printf(" %s + %s = %2d |",
colour_int_custom(gpu_jobs[node],colour("Magenta"),2),
colour_int_custom(cpu_jobs[node],colour("Blue"),2),
total_jobs[node])
printf(" %s%3d%s |", cl1, cpu_load[node], cln);
printf(" %s%3s%s |", cl2, cpu_per_job_str, cln);
printf(" %s%3s%s |", cl3, cpu_per_gpu_use_str, cln);
# print ;
printf(" %s%10s%s |", cls, state[node], cln);
printf("\n")
}
# 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);
# for (name in counts){
# if (user_to_lab[name] == lab) {
# printf("| %14s |",name);
# printf(" %3d |",counts[name]["R"]);
# printf(" %3d |",counts[name]["PD"]);
# printf(" %3d |",counts[name]["CG"]);
# printf("\n");
# }
# }
# printf("| %14s |","--------------");
# printf(" %3s + %3s + %3s |", "---", "---", "---");
# printf("\n");
}
printf("| %11s |","-----------");
printf(" %s + %s + %s + %s + %s + %s |",
"---", "------------", "---", "---", "---", "----------");
printf("\n");
printf("| %11s%-52s |\n", "legend", "")
printf("| %11s%-52s |\n", "G/T:", " GPUs in use / total GPUs")
printf("| %11s%-52s |\n", "GJ+CJ=T:", " GPU Jobs + CPU Jobs running = total jobs")
printf("| %11s%-52s |\n", "CPU:", " CPU Load")
printf("| %11s%-52s |\n", "/TJ:", " CPU Load / Total jobs running")
printf("| %11s%-52s |\n", "/GU:", " CPU Load / GPU in use")
# printf("| %59s |\n", "")
printf("| %11s |","-----------");
printf(" %s + %s + %s + %s + %s + %s |",
"---", "------------", "---", "---", "---", "----------");
printf("\n");
printf("| %11s | %s |\n","-----------", "---------");
for (node in state) {
if (state[node] == "down" || state[node] == "drained") {
printf("| %11s | %s %s%8s%s |\n",
node, "", colour("Yellow"), state[node], cln)
}
}
printf("| %11s | %s |\n","-----------", "---------");
}