smartctl_exporter: Non standard device accessors such as `-d cciss,N` do not work

When using HPSA controllers, smartctl needs to access devices via the -d cciss,<idx> parameter. However using the following:

smartctl_exporter:
  bind_to: 0.0.0.0:9243
  url_path: /metrics
  fake_json: no
  smartctl_location: /usr/sbin/smartctl
  collect_not_more_than_period: 120s
  devices:
  - "/dev/sda -d cciss,0"
  - "/dev/sda -d cciss,1"
  - "/dev/sda -d cciss,2"
  - "/dev/sda -d cciss,3"
  - "/dev/sda -d cciss,4"

results in

[Debug] Parsed options: {{0.0.0.0:9243 /metrics %!s(bool=false) /usr/sbin/smartctl 120s 2m0s [/dev/sda -d cciss,0 /dev/sda -d cciss,1 /dev/sda -d cciss,2 /dev/sda -d cciss,3 /dev/sda -d cciss,4]}}
[Error] Device /dev/sda -d cciss,0 unavialable
[Error] Device /dev/sda -d cciss,1 unavialable
[Error] Device /dev/sda -d cciss,2 unavialable
[Error] Device /dev/sda -d cciss,3 unavialable
[Error] Device /dev/sda -d cciss,4 unavialable
panic: runtime error: index out of range [0] with length 0

goroutine 38 [running]:
main.(*SMARTctlInfo).mineVersion(0xc000080eb8)
	/mnt/Sheridan/sheridan/sheridan/smartctl_exporter/smartctlinfo.go:46 +0x942
main.(*SMARTctlInfo).Collect(...)
	/mnt/Sheridan/sheridan/sheridan/smartctl_exporter/smartctlinfo.go:35
main.SMARTctlManagerCollector.Collect(0xc000264060)
	/mnt/Sheridan/sheridan/sheridan/smartctl_exporter/main.go:37 +0x1c1
github.com/prometheus/client_golang/prometheus.DescribeByCollect.func1(0xa20840, 0xdc8010, 0xc000264060)
	/mnt/Sheridan/sheridan/sheridan/smartctl_exporter/vendor/src/github.com/prometheus/client_golang/prometheus/collector.go:90 +0x3b
created by github.com/prometheus/client_golang/prometheus.DescribeByCollect
	/mnt/Sheridan/sheridan/sheridan/smartctl_exporter/vendor/src/github.com/prometheus/client_golang/prometheus/collector.go:89 +0x75

My Go-fu isn’t great (Rust FTW! :-p), and there’s a fair amount of indirection through which i need to dig to resolve that locally. If its not too much trouble, would it be possible for the functionality to be implemented upstream?

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 1
  • Comments: 27 (8 by maintainers)

Commits related to this issue

Most upvoted comments

Part of my refactoring for the flag controls was to allow for easier adjustment of flags to the various smartctl commands.

Hello! @sempervictus did you find a way to manage this issue? I am facing the same problem. Thanks!