Last active
December 30, 2020 09:44
-
-
Save youssefeldakar/a552cfe0a4952e03111bd9a3adead9a6 to your computer and use it in GitHub Desktop.
Print Slurm bank account usage/quota minutes for a given resource
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# This gist has moved under github.com/hpcalex/slurmies/ as of 2020-12-30. | |
# Usage: sacctmins <acct> <resc> | |
# Reference for Slurm commands: | |
# | |
# https://slurm.schedmd.com/sshare.html | |
# A previous revision used sreport and sacctmgr, respectively. | |
share_info=$(sshare -lnpA "$1" | head -n 1) | |
# Usage (u) and capacity (c). | |
u=$(echo "$share_info" | cut -d \| -f 5) | |
c=$(echo "$share_info" | cut -d \| -f 10 | sed -n "s,.*\<$2\>=\([1-9][0-9]*\).*,\1,;Tx;p;:x") | |
u=$((u / 60)) # Quotient is floored. | |
if [ "$#" -ne 2 ] || [ -z "$c" ]; then | |
exit 1 | |
fi | |
printf "$1 $2 : %d of %d mins (%d of %d h) %d%%\n" "$u" "$c" "$((u / 60))" "$((c / 60))" "$((100 * u / c))" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment