mirror of
https://github.com/prometheus-community/windows_exporter
synced 2025-02-08 23:58:58 +00:00
Fix cs collector crashing when running on a domain joined machine
The wmi lib does some type checking for nil values. Use a pointer as a workaround for that.
This commit is contained in:
parent
74d7332b47
commit
d1a807840c
@ -67,7 +67,7 @@ type Win32_ComputerSystem struct {
|
||||
TotalPhysicalMemory uint64
|
||||
DNSHostname string
|
||||
Domain string
|
||||
Workgroup string
|
||||
Workgroup *string
|
||||
}
|
||||
|
||||
func (c *CSCollector) collect(ch chan<- prometheus.Metric) (*prometheus.Desc, error) {
|
||||
@ -93,7 +93,7 @@ func (c *CSCollector) collect(ch chan<- prometheus.Metric) (*prometheus.Desc, er
|
||||
)
|
||||
|
||||
var fqdn string
|
||||
if dst[0].Domain != dst[0].Workgroup {
|
||||
if dst[0].Workgroup == nil || dst[0].Domain != *dst[0].Workgroup {
|
||||
fqdn = dst[0].DNSHostname + "." + dst[0].Domain
|
||||
} else {
|
||||
fqdn = dst[0].DNSHostname
|
||||
|
Loading…
Reference in New Issue
Block a user