Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added new node 'planned' node state (21.08) #62

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type NodesMetrics struct {
maint float64
mix float64
resv float64
plnd float64
}

func NodesGetMetrics() *NodesMetrics {
Expand Down Expand Up @@ -83,6 +84,7 @@ func ParseNodesMetrics(input []byte) *NodesMetrics {
maint := regexp.MustCompile(`^maint`)
mix := regexp.MustCompile(`^mix`)
resv := regexp.MustCompile(`^res`)
plnd := regexp.MustCompile(`^plan`)
switch {
case alloc.MatchString(state) == true:
nm.alloc += count
Expand All @@ -104,6 +106,8 @@ func ParseNodesMetrics(input []byte) *NodesMetrics {
nm.mix += count
case resv.MatchString(state) == true:
nm.resv += count
case plnd.MatchString(state) == true:
nm.plnd += count
}
}
}
Expand Down Expand Up @@ -145,6 +149,7 @@ func NewNodesCollector() *NodesCollector {
maint: prometheus.NewDesc("slurm_nodes_maint", "Maint nodes", nil, nil),
mix: prometheus.NewDesc("slurm_nodes_mix", "Mix nodes", nil, nil),
resv: prometheus.NewDesc("slurm_nodes_resv", "Reserved nodes", nil, nil),
plnd: prometheus.NewDesc("slurm_nodes_plnd", "Planned nodes", nil, nil),
}
}

Expand All @@ -159,6 +164,7 @@ type NodesCollector struct {
maint *prometheus.Desc
mix *prometheus.Desc
resv *prometheus.Desc
plnd *prometheus.Desc
}

// Send all metric descriptions
Expand All @@ -173,6 +179,7 @@ func (nc *NodesCollector) Describe(ch chan<- *prometheus.Desc) {
ch <- nc.maint
ch <- nc.mix
ch <- nc.resv
ch <- nc.plnd
}
func (nc *NodesCollector) Collect(ch chan<- prometheus.Metric) {
nm := NodesGetMetrics()
Expand All @@ -186,4 +193,5 @@ func (nc *NodesCollector) Collect(ch chan<- prometheus.Metric) {
ch <- prometheus.MustNewConstMetric(nc.maint, prometheus.GaugeValue, nm.maint)
ch <- prometheus.MustNewConstMetric(nc.mix, prometheus.GaugeValue, nm.mix)
ch <- prometheus.MustNewConstMetric(nc.resv, prometheus.GaugeValue, nm.resv)
ch <- prometheus.MustNewConstMetric(nc.plnd, prometheus.GaugeValue, nm.plnd)
}
6 changes: 3 additions & 3 deletions test_data/sinfo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ lxfoo0373,idle
lxfoo0374,idle
lxfoo0375,idle
lxfoo0376,idle
lxfoo0377,idle
lxfoo0377,planned
lxfoo0378,idle
lxfoo0379,idle
lxfoo0380,idle
Expand All @@ -390,7 +390,7 @@ lxfoo0389,idle
lxfoo0390,idle
lxfoo0391,idle
lxfoo0392,idle
lxfoo0393,idle
lxfoo0393,planned
lxfoo0394,idle
lxfoo0395,idle
lxfoo0396,idle
Expand Down Expand Up @@ -457,7 +457,7 @@ lxfoo0456,idle
lxfoo0457,idle
lxfoo0458,idle
lxfoo0459,idle
lxfoo0460,idle
lxfoo0460,planned
lxfoo0461,idle
lxfoo0462,idle
lxfoo0463,idle
Expand Down