@@ -112,6 +112,27 @@ export class TrueNasIntegration extends Integration implements ISystemHealthMoni
112112 } ) ;
113113 }
114114
115+ private async getPoolsAsync ( ) {
116+ localLogger . debug ( "Retrieving pools" , {
117+ url : this . wsUrl ( ) ,
118+ } ) ;
119+
120+ const response = await this . requestAsync ( "pool.query" , [
121+ [ ] ,
122+ {
123+ extra : {
124+ is_upgraded : true ,
125+ } ,
126+ } ,
127+ ] ) ;
128+ const result = await poolSchema . parseAsync ( response ) ;
129+ localLogger . debug ( "Retrieved pools" , {
130+ url : this . wsUrl ( ) ,
131+ count : result . length ,
132+ } ) ;
133+ return result ;
134+ }
135+
115136 /**
116137 * Retrieves data using the reporting method
117138 * @see https://www.truenas.com/docs/api/scale_websocket_api.html#reporting
@@ -225,6 +246,7 @@ export class TrueNasIntegration extends Integration implements ISystemHealthMoni
225246 const cpuData = this . extractLatestReportingData ( reporting , "cpu" ) ;
226247 const cpuTempData = this . extractLatestReportingData ( reporting , "cputemp" ) ;
227248 const memoryData = this . extractLatestReportingData ( reporting , "memory" ) ;
249+ const datasets = await this . getPoolsAsync ( ) ;
228250
229251 const netdata = await this . getReportingNetdataAsync ( ) ;
230252
@@ -236,14 +258,23 @@ export class TrueNasIntegration extends Integration implements ISystemHealthMoni
236258 cpuTemp : Math . max ( ...cpuTempData . filter ( ( _item , i ) => i > 0 ) ) ,
237259 memAvailableInBytes : systemInformation . physmem ,
238260 memUsedInBytes : memoryData [ 1 ] ?? 0 , // Index 0 is UNIX timestamp, Index 1 is free space in bytes
239- fileSystem : [ ] ,
261+ fileSystem : datasets . map ( ( dataset ) => ( {
262+ deviceName : dataset . name ,
263+ available : `${ dataset . size } ` , // TODO: can we use number instead of string here?
264+ used : `${ dataset . allocated } ` ,
265+ percentage : ( dataset . allocated / dataset . size ) * 100 ,
266+ } ) ) ,
240267 availablePkgUpdates : 0 ,
241268 network : {
242269 up : upload * NETWORK_MULTIPLIER ,
243270 down : download * NETWORK_MULTIPLIER ,
244271 } ,
245272 loadAverage : null ,
246- smart : [ ] ,
273+ smart : datasets . map ( ( dataset ) => ( {
274+ deviceName : dataset . name ,
275+ healthy : dataset . healthy ,
276+ temperature : null ,
277+ } ) ) ,
247278 uptime : systemInformation . uptime_seconds ,
248279 version : systemInformation . version ,
249280 cpuModelName : systemInformation . model ,
@@ -351,6 +382,14 @@ const reportingItemSchema = z.object({
351382
352383type ReportingItem = z . infer < typeof reportingItemSchema > ;
353384
385+ const poolSchema = z . array ( z . object ( {
386+ name : z . string ( ) ,
387+ healthy : z . boolean ( ) ,
388+ free : z . number ( ) . min ( 0 ) ,
389+ size : z . number ( ) ,
390+ allocated : z . number ( )
391+ } ) )
392+
354393const reportingNetDataSchema = z . array (
355394 z . object ( {
356395 name : z . string ( ) ,
0 commit comments