[slurm-users] slurm sinfo format memory

1,163 views
Skip to first unread message

Arsene Marian Alain

unread,
Jul 20, 2023, 12:24:51 PM7/20/23
to Slurm User Community List

 

Dear slurm users,

 

I would like to see the following information of my nodes "hostname, total mem, free mem and cpus". So, I used  ‘sinfo -o "%8n %8m %8e %C"’ but in the output it shows me the memory in MB like "190560" and I need it in GB (without decimals if possible) like "190GB". Any ideas or suggestions on how I can do that?

 

current output:

 

HOSTNAME MEMORY   FREE_MEM CPUS(A/I/O/T)

node01   190560   125249   60/4/0/64

node02   190560   171944   40/24/0/64

node05   93280     91584     0/40/0/40

node06   513120   509448   0/96/0/96

node07   513120   512086   0/96/0/96

node08   513120   512328   0/96/0/96

node09   513120   512304   0/96/0/96

 

desired output:

 

HOSTNAME MEMORY   FREE_MEM CPUS(A/I/O/T)

node01   190GB   125GB   60/4/0/64

node02   190GB   171GB   40/24/0/64

node05   93GB      91GB    0/40/0/40

node06   512GB   500GB   0/96/0/96

node07   512GB   512GB   0/96/0/96

node08   512GB   512GB   0/96/0/96

node09   512GB   512GB   0/96/0/96

 

 

 

I would appreciate any help.

 

Thank you.

 

Best Regards,

 

Alain

Feng Zhang

unread,
Jul 20, 2023, 3:37:51 PM7/20/23
to Slurm User Community List
Looks like Slurm itself only supports that format(in MB unit). Slurm commands output format is not very user friendly to me. If it can add some easy options, like for the output info of sinfo command in this email thread, how about adding support for lazy options, like sinfo -ABC, etc.

For the desired format in GB, one workaround may be to prepare a wrapper shell script, read in the  sinfo output, and convert the MB to GB and print out to the screen.

Kevin Buckley

unread,
Jul 21, 2023, 5:05:15 AM7/21/23
to slurm...@lists.schedmd.com
Specifying a field width and adding in your desired unit qualifier

sinfo -o "%n %.3mGB %.3eGB %C"

would give something like

HOSTNAME MEMGB FREGB CPUS(A/I/O/T)
node01 190GB 125GB 60/4/0/64
node02 190GB 171GB 40/24/0/64
node05 93GB 91GB 0/40/0/40
node06 513GB 509GB 0/96/0/96
node07 513GB 512GB 0/96/0/96
node08 513GB 512GB 0/96/0/96
node09 513GB 512GB 0/96/0/96

which isn't exact, but at least maintains some of the differences
between the RealMemory figure, which is statically defined in your
Slurm config anyway, and the reported FreeMemory figure.

Other than that, piping the output into a script/program that
does whatever scaling you want will give you eaxctly what you
want, as you'll have full control over things.





Ole Holm Nielsen

unread,
Jul 21, 2023, 5:32:43 AM7/21/23
to slurm...@lists.schedmd.com
Hi Arsene,

On 7/20/23 18:24, Arsene Marian Alain wrote:
> I would like to see the following information of my nodes "hostname, total
> mem, free mem and cpus". So, I used  ‘sinfo -o "%8n %8m %8e %C"’ but in
> the output it shows me the memory in MB like "190560" and I need it in GB
> (without decimals if possible) like "190GB". Any ideas or suggestions on
> how I can do that?

Just my 2 cents: The old "-o" options flag should be replaced by Slurm's
more modern "-O" option which uses readable parameters and allows more
output fields than -o, for example:

sinfo -O "NodeHost,CPUsState:20,Memory:20,FreeMem:20,StateComplete:30"

/Ole

Roberto Monti

unread,
Jul 21, 2023, 10:18:11 AM7/21/23
to Slurm User Community List
The proposed solution will break for values >=1000G.

As sinfo is apparently stuck with megabytes, you will have to do something like:

sinfo -o "%n %m %e %C" | awk '$3 ~ /[0-9]+/ {printf "%s %iG %iG %s\n", $1, $2 / 1024, $3 / 1024, $4}'

numfmt is another option, but it is only with newer versions of GNU coreutils that they added multi-field support.

--
Roberto P. Monti
DevOps Engineer I
robert...@jax.org

The Jackson Laboratory
United States | China | Japan
www.jax.org
---

The information in this email, including attachments, may be confidential and is intended solely for the addressee(s). If you believe you received this email by mistake, please notify the sender by return email as soon as possible.

Michael DiDomenico

unread,
Jul 21, 2023, 10:27:42 AM7/21/23
to Slurm User Community List
another option besides those mentioned would be to frontend sinfo with
jq/python and parse the data through json/yaml

On Thu, Jul 20, 2023 at 12:28 PM Arsene Marian Alain
<alain....@uah.es> wrote:
>
>
>
Reply all
Reply to author
Forward
0 new messages