Skip to content

Commit

Permalink
Merge pull request #476 from sll552/fix_domain_hostname
Browse files Browse the repository at this point in the history
Fix cs collector crashing when running on a domain joined machine
  • Loading branch information
carlpett authored Mar 4, 2020
2 parents 74d7332 + d1a8078 commit 890fdc2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions collector/cs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
Expand Down

0 comments on commit 890fdc2

Please sign in to comment.