@@ -28,18 +28,19 @@ import (
28
28
)
29
29
30
30
type NodesMetrics struct {
31
- alloc map [string ]float64
32
- comp map [string ]float64
33
- down map [string ]float64
34
- drain map [string ]float64
35
- err map [string ]float64
36
- fail map [string ]float64
37
- idle map [string ]float64
38
- maint map [string ]float64
39
- mix map [string ]float64
40
- resv map [string ]float64
41
- other map [string ]float64
42
- total map [string ]float64
31
+ alloc map [string ]float64
32
+ comp map [string ]float64
33
+ down map [string ]float64
34
+ drain map [string ]float64
35
+ err map [string ]float64
36
+ fail map [string ]float64
37
+ idle map [string ]float64
38
+ maint map [string ]float64
39
+ mix map [string ]float64
40
+ resv map [string ]float64
41
+ other map [string ]float64
42
+ planned map [string ]float64
43
+ total map [string ]float64
43
44
}
44
45
45
46
func NodesGetMetrics (part string ) * NodesMetrics {
@@ -76,6 +77,7 @@ func InitFeatureSet(nm *NodesMetrics, feature_set string) {
76
77
nm .mix [feature_set ] = nm .mix [feature_set ]
77
78
nm .resv [feature_set ] = nm .resv [feature_set ]
78
79
nm .other [feature_set ] = nm .other [feature_set ]
80
+ nm .planned [feature_set ] = nm .planned [feature_set ]
79
81
nm .total [feature_set ] = nm .total [feature_set ]
80
82
}
81
83
@@ -99,6 +101,7 @@ func ParseNodesMetrics(input []byte) *NodesMetrics {
99
101
nm .mix = make (map [string ]float64 )
100
102
nm .resv = make (map [string ]float64 )
101
103
nm .other = make (map [string ]float64 )
104
+ nm .planned = make (map [string ]float64 )
102
105
nm .total = make (map [string ]float64 )
103
106
104
107
for _ , line := range lines_uniq {
@@ -123,6 +126,7 @@ func ParseNodesMetrics(input []byte) *NodesMetrics {
123
126
maint := regexp .MustCompile (`^maint` )
124
127
mix := regexp .MustCompile (`^mix` )
125
128
resv := regexp .MustCompile (`^res` )
129
+ planned := regexp .MustCompile (`^planned` )
126
130
switch {
127
131
case alloc .MatchString (state ):
128
132
nm .alloc [feature_set ] += count
@@ -144,6 +148,8 @@ func ParseNodesMetrics(input []byte) *NodesMetrics {
144
148
nm .mix [feature_set ] += count
145
149
case resv .MatchString (state ):
146
150
nm .resv [feature_set ] += count
151
+ case planned .MatchString (state ):
152
+ nm .planned [feature_set ] += count
147
153
default :
148
154
nm .other [feature_set ] += count
149
155
}
@@ -220,34 +226,36 @@ func NewNodesCollector() *NodesCollector {
220
226
labelnames = append (labelnames , "partition" )
221
227
labelnames = append (labelnames , "active_feature_set" )
222
228
return & NodesCollector {
223
- alloc : prometheus .NewDesc ("slurm_nodes_alloc" , "Allocated nodes" , labelnames , nil ),
224
- comp : prometheus .NewDesc ("slurm_nodes_comp" , "Completing nodes" , labelnames , nil ),
225
- down : prometheus .NewDesc ("slurm_nodes_down" , "Down nodes" , labelnames , nil ),
226
- drain : prometheus .NewDesc ("slurm_nodes_drain" , "Drain nodes" , labelnames , nil ),
227
- err : prometheus .NewDesc ("slurm_nodes_err" , "Error nodes" , labelnames , nil ),
228
- fail : prometheus .NewDesc ("slurm_nodes_fail" , "Fail nodes" , labelnames , nil ),
229
- idle : prometheus .NewDesc ("slurm_nodes_idle" , "Idle nodes" , labelnames , nil ),
230
- maint : prometheus .NewDesc ("slurm_nodes_maint" , "Maint nodes" , labelnames , nil ),
231
- mix : prometheus .NewDesc ("slurm_nodes_mix" , "Mix nodes" , labelnames , nil ),
232
- resv : prometheus .NewDesc ("slurm_nodes_resv" , "Reserved nodes" , labelnames , nil ),
233
- other : prometheus .NewDesc ("slurm_nodes_other" , "Nodes reported with an unknown state" , labelnames , nil ),
234
- total : prometheus .NewDesc ("slurm_nodes_total" , "Total number of nodes" , nil , nil ),
229
+ alloc : prometheus .NewDesc ("slurm_nodes_alloc" , "Allocated nodes" , labelnames , nil ),
230
+ comp : prometheus .NewDesc ("slurm_nodes_comp" , "Completing nodes" , labelnames , nil ),
231
+ down : prometheus .NewDesc ("slurm_nodes_down" , "Down nodes" , labelnames , nil ),
232
+ drain : prometheus .NewDesc ("slurm_nodes_drain" , "Drain nodes" , labelnames , nil ),
233
+ err : prometheus .NewDesc ("slurm_nodes_err" , "Error nodes" , labelnames , nil ),
234
+ fail : prometheus .NewDesc ("slurm_nodes_fail" , "Fail nodes" , labelnames , nil ),
235
+ idle : prometheus .NewDesc ("slurm_nodes_idle" , "Idle nodes" , labelnames , nil ),
236
+ maint : prometheus .NewDesc ("slurm_nodes_maint" , "Maint nodes" , labelnames , nil ),
237
+ mix : prometheus .NewDesc ("slurm_nodes_mix" , "Mix nodes" , labelnames , nil ),
238
+ resv : prometheus .NewDesc ("slurm_nodes_resv" , "Reserved nodes" , labelnames , nil ),
239
+ other : prometheus .NewDesc ("slurm_nodes_other" , "Nodes reported with an unknown state" , labelnames , nil ),
240
+ planned : prometheus .NewDesc ("slurm_nodes_planned" , "Planned nodes" , labelnames , nil ),
241
+ total : prometheus .NewDesc ("slurm_nodes_total" , "Total number of nodes" , nil , nil ),
235
242
}
236
243
}
237
244
238
245
type NodesCollector struct {
239
- alloc * prometheus.Desc
240
- comp * prometheus.Desc
241
- down * prometheus.Desc
242
- drain * prometheus.Desc
243
- err * prometheus.Desc
244
- fail * prometheus.Desc
245
- idle * prometheus.Desc
246
- maint * prometheus.Desc
247
- mix * prometheus.Desc
248
- resv * prometheus.Desc
249
- other * prometheus.Desc
250
- total * prometheus.Desc
246
+ alloc * prometheus.Desc
247
+ comp * prometheus.Desc
248
+ down * prometheus.Desc
249
+ drain * prometheus.Desc
250
+ err * prometheus.Desc
251
+ fail * prometheus.Desc
252
+ idle * prometheus.Desc
253
+ maint * prometheus.Desc
254
+ mix * prometheus.Desc
255
+ resv * prometheus.Desc
256
+ other * prometheus.Desc
257
+ planned * prometheus.Desc
258
+ total * prometheus.Desc
251
259
}
252
260
253
261
// Send all metric descriptions
@@ -263,6 +271,7 @@ func (nc *NodesCollector) Describe(ch chan<- *prometheus.Desc) {
263
271
ch <- nc .mix
264
272
ch <- nc .resv
265
273
ch <- nc .other
274
+ ch <- nc .planned
266
275
ch <- nc .total
267
276
}
268
277
@@ -291,6 +300,7 @@ func (nc *NodesCollector) Collect(ch chan<- prometheus.Metric) {
291
300
SendFeatureSetMetric (ch , nc .mix , prometheus .GaugeValue , nm .mix , part )
292
301
SendFeatureSetMetric (ch , nc .resv , prometheus .GaugeValue , nm .resv , part )
293
302
SendFeatureSetMetric (ch , nc .other , prometheus .GaugeValue , nm .other , part )
303
+ SendFeatureSetMetric (ch , nc .planned , prometheus .GaugeValue , nm .planned , part )
294
304
}
295
305
total := SlurmGetTotal ()
296
306
ch <- prometheus .MustNewConstMetric (nc .total , prometheus .GaugeValue , total )
0 commit comments