Truenas scale cli hooks to values in GUI

Problem/Justification
Truenas scale is a great application, but many users have specific needs and wishes to customize it. Unfortunately, there does not appear any good way of using Truenas scales gui features in conjunction with custom scripts, which often forces people to altogether abandon the gui methods and instead implement solutions themselves or alternatively people use the gui methods and then use hacky hooks through either the log files or even email alerts, as seen in the following: Monitoring status of replication tasks | TrueNAS Community Correct way to script ZFS replication in TrueNAS Scale? - #7 by winnielinnie

What I would like is either some kind of api where the gui variables are clearly exposed, or a folder which have files with all the variable values. I believe that Truenas might already have something somewhat along those lines in a middleware API, but I have been unable to find much information on this or whether it covers the case I’m mentioning.

Thus through such an API I can easily create a shell script that acts when a certain condition is met. Like for instance, if a replication task has sucessfully finished in the last 5 minutes, run this script.

Impact
The benefit of this feature is that it will be easier for people who wishes to customize truenas scale. There will be one source of truth for all the things shown in the GUI, and people can reliably query this API or whatever form this might take and get the same values as are currently exposed in the GUI.

Thus for people who do not want to customize there should be no impact, and for the people who wish to customize things there is a simple source of truth for all things happening in the GUI

Did you take a look at the api documentation?
https://www.truenas.com/docs/api/scale_rest_api.html

1 Like

I believe this is the api that is being deprecated from the next major version of Truenas scale API Reference | TrueNAS Documentation Hub

I previously tried to look at it, and found it to be confusing and I wasn’t really sure what I would be able to do through it. But looking at it now, I can see that it is probably exactly what I am requesting. Judging on the amount of posts about this api though, I’m guessing that most people have no idea what it is or how to use it, but hopefully that will come.

See also:

…which uses the new websocket API.

1 Like