mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-02-23 21:26:36 +00:00
Merge pull request #476 from sll552/fix_domain_hostname
Fix cs collector crashing when running on a domain joined machine
This commit is contained in:
@@ -67,7 +67,7 @@ type Win32_ComputerSystem struct {
|
|||||||
TotalPhysicalMemory uint64
|
TotalPhysicalMemory uint64
|
||||||
DNSHostname string
|
DNSHostname string
|
||||||
Domain string
|
Domain string
|
||||||
Workgroup string
|
Workgroup *string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CSCollector) collect(ch chan<- prometheus.Metric) (*prometheus.Desc, error) {
|
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
|
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
|
fqdn = dst[0].DNSHostname + "." + dst[0].Domain
|
||||||
} else {
|
} else {
|
||||||
fqdn = dst[0].DNSHostname
|
fqdn = dst[0].DNSHostname
|
||||||
|
|||||||
Reference in New Issue
Block a user