Api v2 troubles

badblocks

Cadet
Joined
Mar 21, 2016
Messages
2
Hi,

I used api v1 under freenas before for reading the zpool status (healty/degraded) and it's used space (in percentage) with a Python script.
The v2 api is now very much different. What are the commands for this in v2? Or is this not implemented (yet)?
 

badblocks

Cadet
Joined
Mar 21, 2016
Messages
2
After searching and trial and error this is the solution (examples with Curl):

Command:
curl -X GET -H "Authorization: Bearer <your_api_key>" http://<your_ip_address>/api/v2.0/pool

Response:
a dict in a list with key "status"
If "status" has value "online" it's healty otherwise "degraded" or someting else bad.

Command:
curl -X GET -H "Authorization: Bearer <your_api_key>" http://<your_ip_address>/api/v2.0/pool/dataset/id/<name_of_your_root_dataset>

Response:
a dict with 2 keys; "used" and "available". Each has a dict with a "value" key wich holds the size
UsedPercentage = 100 * (Used/ (Used + Available))
 
Top