6

I am looking for a simple way to get information about memory usage, like free memory form the salt minions.

So far I know that the total memory can be listed using salt '*' grains.items but I don't even know how to list only just the total memory instead of the all grains data.

Second problem is that I don't know how to get the free memory returned.

sorin
  • 161,544
  • 178
  • 535
  • 806

5 Answers5

14

To get the total memory, use grains.item, rather than grains.items:

salt '*' grains.item mem_total
Jeff Bauer
  • 13,890
  • 9
  • 51
  • 73
10

salt targetminion status.meminfo

If you are parsing this, change the output formatting:

salt targetminion status.meminfo --out=json

Dan Garthwaite
  • 3,436
  • 4
  • 22
  • 32
  • Then you can get the total and free memory with the 'jq' command line json parser: `salt targetminion status.meminfo --out=json | jq '.targetminion.MemAvailable.value,.targetminion.MemTotal.value'` will output for exmaple: "27123356" "32802164" – mrossi Sep 07 '18 at 07:09
  • This is not supported on MacOS unfortunately :( – Maxime Jan 20 '20 at 20:00
0

Better you use Grains for the same:
salt '*' grains.item mem_total
Please refer:
Grains

Ganesh
  • 505
  • 2
  • 9
  • 26
-2

salt '*' disk.usage should give you details about every partition in the minion. Details as in the available space, capacity usage and so on.

Paritosh
  • 1,111
  • 1
  • 12
  • 29
-3

So far, I was able to obtain this information using: salt '*' cmd.run 'free -m -o | grep "Mem"' -- maybe somebody else knows a better/easier way.

sorin
  • 161,544
  • 178
  • 535
  • 806