# Using sacctmgr to get max cores and max mem for an account

**URL:** https://discourse.openondemand.org/t/using-sacctmgr-to-get-max-cores-and-max-mem-for-an-account/3011
**Category:** Get Help
**Tags:** ondemand2, question
**Created:** [October 11, 2023, 2:53pm UTC](https://discourse.openondemand.org/t/using-sacctmgr-to-get-max-cores-and-max-mem-for-an-account/3011 "2023-10-11T14:53:23Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![jeff.ohrstrom](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/jeff.ohrstrom/32/136_2.png) [@jeff.ohrstrom](https://discourse.openondemand.org/u/jeff.ohrstrom)
#### Post date: [October 11, 2023, 3:26pm UTC](https://discourse.openondemand.org/t/using-sacctmgr-to-get-max-cores-and-max-mem-for-an-account/3011/2 "2023-10-11T15:26:28Z")

</div>

`auto_accounts` could work for you, up to a point. It’s dynamic WRT to clusters and qos (I think we’re lacking queues?), but won’t set min and max cpus.

If it were me - I would use `auto_accounts` to populate accounts then use `data-min` and `data-max` attributes to set mins and maxes.

[https://osc.github.io/ood-documentation/latest/how-tos/app-development/interactive/dynamic-form-widgets.html?#dynamic-min-and-maxes](https://osc.github.io/ood-documentation/latest/how-tos/app-development/interactive/dynamic-form-widgets.html?#dynamic-min-and-maxes)

Lastly - if you have to write Ruby to do query Slurm you should write it in an initializer because those `form.yml.erb` files are rendered a lot (I mean they’re read & rendered even without hitting that specific page) so embedding too much ruby (or ruby that queries other systems) is going to cause issues for your site.

> [@Suggestions on generating dynamic form data](https://discourse.openondemand.org/t/suggestions-on-generating-dynamic-form-data/1670/6):
>
> Really helpful thread! I managed to do the same for the slurm accounts; class SlurmData def self.accounts username = Etc.getlogin accounts = [] IO.popen 'sacctmgr -np show accounts withassoc format=account,user' do |io| io.each do |line| acc = line.split('|') if acc[1] == username accounts.append(acc[0]) end end end return accounts end end combined with bc\_account: widget: "select" label: "Project" options: [\<%…

---

_[View the full topic](https://discourse.openondemand.org/t/using-sacctmgr-to-get-max-cores-and-max-mem-for-an-account/3011)._
