long node name causes index out of range error
Opened this issue · 1 comments
hokiegeek2 commented
First of all, great project! This works great.
Found one easily fixable issue. If the node names are too long, the memoryAlloc field value merges into the node name value:
INFO[0000] Starting Server: 0.0.0.0:9090 source="main.go:59"
INFO[0000] GPUs Accounting: false source="main.go:60"
INFO[0049] sinfo fields: [production-slurm-compute-10 8192 0/4/0/4 idle] source="node.go:55"
panic: runtime error: index out of range [4] with length 4
goroutine 39 [running]:
main.ParseNodeMetrics({0xc0001b9000, 0x594, 0xc0000adde0?})
/home/jyost/development/git/prometheus-slurm-exporter/node.go:58 +0x5a5
main.NodeGetMetrics()
/home/jyost/development/git/prometheus-slurm-exporter/node.go:41 +0x1e
main.(*NodeCollector).Collect(0xc00007f740, 0xc0000adf60?)
/home/jyost/development/git/prometheus-slurm-exporter/node.go:131 +0x3e
github.com/prometheus/client_golang/prometheus.(*Registry).Gather.func1()
/home/jyost/development/git/prometheus-slurm-exporter/go/modules/pkg/mod/github.com/prometheus/client_golang@v1.2.1/prometheus/registry.go:443 +0xfb
created by github.com/prometheus/client_golang/prometheus.(*Registry).Gather
/home/jyost/development/git/prometheus-slurm-exporter/go/modules/pkg/mod/github.com/prometheus/client_golang@v1.2.1/prometheus/registry.go:535 +0xb0b
The node name is production-slurm-compute-1 and the 0 got appended to the end of the node name. I fixed in my fork and will submit a PR soon
hokiegeek2 commented
whoops, this issue is a dupe