@@ -166,15 +166,28 @@ func (c *SolidfireCollector) Describe(ch chan<- *prometheus.Desc) {
166166 ch <- MetricDescriptions .DriveCapacityBytes
167167
168168 ch <- MetricDescriptions .NodeISCSISessions
169+
170+ ch <- MetricDescriptions .VolumeCount
171+ ch <- MetricDescriptions .AccountCount
172+ ch <- MetricDescriptions .ClusterAdminCount
173+ ch <- MetricDescriptions .InitiatorCount
174+ ch <- MetricDescriptions .VolumeAccessGroupCount
169175}
170176
171- func (c * SolidfireCollector ) collectVolumeMeta (ctx context.Context ) error {
177+ func (c * SolidfireCollector ) collectVolumeMeta (ctx context.Context , ch chan <- prometheus. Metric ) error {
172178 volumes , err := c .client .ListVolumes (ctx )
173179 if err != nil {
174180 return err
175181 }
176182 mu .Lock ()
177183 defer mu .Unlock ()
184+
185+ ch <- prometheus .MustNewConstMetric (
186+ MetricDescriptions .VolumeCount ,
187+ prometheus .CounterValue ,
188+ float64 (len (volumes .Result .Volumes )),
189+ )
190+
178191 for _ , vol := range volumes .Result .Volumes {
179192 c .volumeNamesByID [vol .VolumeID ] = vol .Name
180193 }
@@ -218,6 +231,7 @@ func (c *SolidfireCollector) collectNodeMeta(ctx context.Context, ch chan<- prom
218231 }
219232 return nil
220233}
234+
221235func (c * SolidfireCollector ) collectVolumeStats (ctx context.Context , ch chan <- prometheus.Metric ) error {
222236 volumeStats , err := c .client .ListVolumeStats (ctx )
223237 if err != nil {
@@ -1251,6 +1265,65 @@ func (c *SolidfireCollector) collectISCSISessions(ctx context.Context, ch chan<-
12511265 return nil
12521266}
12531267
1268+ func (c * SolidfireCollector ) collectAccounts (ctx context.Context , ch chan <- prometheus.Metric ) error {
1269+ accounts , err := c .client .ListAccounts (ctx )
1270+ if err != nil {
1271+ return err
1272+ }
1273+ mu .Lock ()
1274+ defer mu .Unlock ()
1275+ ch <- prometheus .MustNewConstMetric (
1276+ MetricDescriptions .AccountCount ,
1277+ prometheus .CounterValue ,
1278+ float64 (len (accounts .Result .Accounts )),
1279+ )
1280+ return nil
1281+ }
1282+
1283+ func (c * SolidfireCollector ) collectClusterAdmins (ctx context.Context , ch chan <- prometheus.Metric ) error {
1284+ clusterAdmins , err := c .client .ListClusterAdmins (ctx )
1285+ if err != nil {
1286+ return err
1287+ }
1288+ mu .Lock ()
1289+ defer mu .Unlock ()
1290+ ch <- prometheus .MustNewConstMetric (
1291+ MetricDescriptions .ClusterAdminCount ,
1292+ prometheus .CounterValue ,
1293+ float64 (len (clusterAdmins .Result .ClusterAdmins )),
1294+ )
1295+ return nil
1296+ }
1297+
1298+ func (c * SolidfireCollector ) collectInitiators (ctx context.Context , ch chan <- prometheus.Metric ) error {
1299+ initiators , err := c .client .ListInitiators (ctx )
1300+ if err != nil {
1301+ return err
1302+ }
1303+ mu .Lock ()
1304+ defer mu .Unlock ()
1305+ ch <- prometheus .MustNewConstMetric (
1306+ MetricDescriptions .InitiatorCount ,
1307+ prometheus .CounterValue ,
1308+ float64 (len (initiators .Result .Initiators )),
1309+ )
1310+ return nil
1311+ }
1312+ func (c * SolidfireCollector ) collectVolumeAccessGroups (ctx context.Context , ch chan <- prometheus.Metric ) error {
1313+ volumeAccessGroups , err := c .client .ListVolumeAccessGroups (ctx )
1314+ if err != nil {
1315+ return err
1316+ }
1317+ mu .Lock ()
1318+ defer mu .Unlock ()
1319+ ch <- prometheus .MustNewConstMetric (
1320+ MetricDescriptions .VolumeAccessGroupCount ,
1321+ prometheus .CounterValue ,
1322+ float64 (len (volumeAccessGroups .Result .VolumeAccessGroups )),
1323+ )
1324+ return nil
1325+ }
1326+
12541327func (c * SolidfireCollector ) Collect (ch chan <- prometheus.Metric ) {
12551328 var up float64 = 0
12561329 defer func () { ch <- prometheus .MustNewConstMetric (MetricDescriptions .upDesc , prometheus .GaugeValue , up ) }()
@@ -1259,7 +1332,7 @@ func (c *SolidfireCollector) Collect(ch chan<- prometheus.Metric) {
12591332
12601333 metadataGroup , ctx := errgroup .WithContext (parentCtx )
12611334 metadataGroup .Go (func () error {
1262- return c .collectVolumeMeta (ctx )
1335+ return c .collectVolumeMeta (ctx , ch )
12631336 })
12641337 metadataGroup .Go (func () error {
12651338 return c .collectNodeMeta (ctx , ch )
@@ -1296,6 +1369,18 @@ func (c *SolidfireCollector) Collect(ch chan<- prometheus.Metric) {
12961369 metricsGroup .Go (func () error {
12971370 return c .collectISCSISessions (ctx , ch )
12981371 })
1372+ metricsGroup .Go (func () error {
1373+ return c .collectAccounts (ctx , ch )
1374+ })
1375+ metricsGroup .Go (func () error {
1376+ return c .collectClusterAdmins (ctx , ch )
1377+ })
1378+ metricsGroup .Go (func () error {
1379+ return c .collectInitiators (ctx , ch )
1380+ })
1381+ metricsGroup .Go (func () error {
1382+ return c .collectVolumeAccessGroups (ctx , ch )
1383+ })
12991384 if err := metricsGroup .Wait (); err != nil {
13001385 log .Errorln (err )
13011386 return
0 commit comments