commit
7f83f897c8
1 changed files with 82 additions and 0 deletions
@ -0,0 +1,82 @@ |
|||||||
|
#!/bin/bash |
||||||
|
# 20151028 |
||||||
|
|
||||||
|
|
||||||
|
function node_slot_stats_per_machine_type() |
||||||
|
# Original extraction command on turing: |
||||||
|
# |
||||||
|
# qstat -f | grep -ve '^[-# ]' -e '^queuename' | less |
||||||
|
# |
||||||
|
# FIXME: If a machine is covered by more than one queue, this will cause the counts |
||||||
|
# to be overestimated. |
||||||
|
{ |
||||||
|
qstat -f \ |
||||||
|
| gawk ' |
||||||
|
BEGIN { |
||||||
|
STDERR = "/dev/stderr" |
||||||
|
} |
||||||
|
FNR == 1 && $1 == "queuename" { next; } |
||||||
|
|
||||||
|
# Valid host status field |
||||||
|
($0 ~ /^[A-Za-z]/) && (NF == 5 || NF == 6) { |
||||||
|
#print($0) |
||||||
|
queue_node = $1 |
||||||
|
core_usage_combo = $3 |
||||||
|
states = $6 # if any |
||||||
|
|
||||||
|
# skip disabled hosts |
||||||
|
if (states ~ /d/) next; |
||||||
|
|
||||||
|
# gawk extension of match: |
||||||
|
if (! match(queue_node, /^([^@]+)@([^-]+)-(.*)$/, Strs)) |
||||||
|
{ |
||||||
|
print("Invalid queue/host combo: " queue_node) > STDERR |
||||||
|
next |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
queue = Strs[1] |
||||||
|
hostkind = Strs[2] |
||||||
|
hostnum = Strs[3] |
||||||
|
} |
||||||
|
split(core_usage_combo, Strs, "/") |
||||||
|
slots_resv = Strs[1] |
||||||
|
slots_used = Strs[2] |
||||||
|
slots_tot = Strs[3] |
||||||
|
|
||||||
|
mach_node_count[hostkind] = mach_node_count[hostkind] + 1 |
||||||
|
mach_node_slot_count[hostkind] = slots_tot # assume homogenous! This DOES NOT work with c8-type nodes! |
||||||
|
mach_slots_tot[hostkind] = mach_slots_tot[hostkind] + slots_tot |
||||||
|
mach_slots_used[hostkind] = mach_slots_used[hostkind] + slots_used |
||||||
|
mach_slots_resv[hostkind] = mach_slots_resv[hostkind] + slots_resv |
||||||
|
} |
||||||
|
|
||||||
|
function report_node_stats() |
||||||
|
{ |
||||||
|
j = 0 |
||||||
|
for (i in mach_node_count) |
||||||
|
{ |
||||||
|
j += 1 |
||||||
|
machs[j] = i |
||||||
|
} |
||||||
|
machs_count = asort(machs) |
||||||
|
printf("%-16s %4s %5s %5s %5s %5s\n", "MACHTYPE", "NODE", "CORES", "used", "free", "resv") |
||||||
|
|
||||||
|
for (i = 1; i <= machs_count; ++i) |
||||||
|
{ |
||||||
|
mach = machs[i] |
||||||
|
printf("%-16s %4d %5d %5d %5d %5d\n", |
||||||
|
mach, mach_node_count[mach], mach_slots_tot[mach], |
||||||
|
mach_slots_used[mach], |
||||||
|
mach_slots_tot[mach] - mach_slots_used[mach] - mach_slots_resv[mach], |
||||||
|
mach_slots_resv[mach]) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
END { |
||||||
|
report_node_stats() |
||||||
|
} |
||||||
|
' |
||||||
|
} |
||||||
|
|
||||||
|
node_slot_stats_per_machine_type |
Loading…
Reference in new issue