Script to Mimic Storage dashboards

I really like the little dashboards that the menu option ‘Storage’ …

… but I would like a script to tell me some of those items for each pool. Things like:

  • count of vdev (the ‘1 x’ part)
  • type of redundance (the ‘raidz2’ part)
  • count of disks per vdev (the ‘8 wide’ part)
  • storage per disk (the ‘10.91 TiB’ part)

I know I can get all of these from zpool status and then manually count various things …
but how do I get them from a script?

Anything in the web interface comes from the API. I expect the pool. methods would do it:
https://www.truenas.com/docs/api/scale_websocket_api.html#pool

You can use the midclt command, or use the client in Python:

1 Like

I’m using pool.query in my experiment to show data into an LCD, It shows a lot of usefull info like status - health - topology - space… I think you can achieve your goal just with that

@ruffhi just take a look… midclt call pool.query | jq and you will see a mountain of data. And of course there is more.

Thx all. I run this …

PoolSize=$(midclt call pool.query '[[ "name", "in", ["DuffleBag"] ]]' | jq -r '.[].size')

… and it gives me the number of bites(?) in DuffleBag. Divide by 1024^4 and I get TiB … exactly the same as ‘zpool list’ but different from the usage dashboard.

ZFS math :smiley: i suppose that just converting into TiB give you the max capacity of the pool not considering ZFS overhead and parity.

I am getting there … The rainmeter skin will cycle over the following:

  • Size: 87.2 TiB
  • Disks: 8
  • Parity: 2
  • PerDisk: 10.91 TiB
  • Available: 87.2 TiB
  • Used: 6.14 TiB
  • Free: 8.4 TiB
  • Capacity: 42%
  • State: Online

and display them for 1 second for each pool. If the pool is not Online the info and pool name will be red. Otherwise, white.

I still need to write the bash script to create the file that the skin reads.

Rainmeter skin is finished. Still need to knock off the bash script.

Don’t worry - BankVault is not really off line … I just changed Online to On-line to test my code.

This is weird (to me). I have a bash script that writes to …

\ScaleProd\TrueNASInfo\Scripts\PoolStatusData

I have a rainmeter skin that reads from …

X:\Scripts\PoolStatusData

X is mapped to \ScaleProd\TrueNASInfo\

But the files do not contain the same information. The date time stamps are the same. The file on the X drive is smaller.

What is the exact full path on TrueNAS? /mnt/pool/???

You likely have something wrong there.

The other possibility is caching. It just sounds very odd that the files have the same date/time stamp.

How about this possibility, are you running the script in two instances?

What is the script so we can examine it?

If you desire, you can send to me in a message unsanitized. I’m good about privacy.

full truenas path is … /mnt/SnappitySnap/TrueNASInfo/Scripts and then Pool status windows folder. I compared the two files with beyond compare and then copied the missing information from one to the other and saved.

Both files are now in sync. I run my script from the terminal (putty). First step is to delete the old file, then echo a bunch of stuff to the file with > and >>.

I just ran it with two explorer windows open in the back ground … file disappears (the delete) and then reappears (writing) on both explorers at the same time. And they are the same.

Weird.