Skip to content

Commit

Permalink
[bugfix] better handling no client and no responding when creating es…
Browse files Browse the repository at this point in the history
…xcli metrics
  • Loading branch information
Tesifonte Belda committed Jun 21, 2023
1 parent 8b2bf40 commit 4309319
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion internal/vccollector/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,9 +459,14 @@ func (c *VcCollector) ReportHostEsxcliResponse(
hsfields = make(map[string]interface{})
hostSt *hostState
t time.Time
z time.Duration
respondingCode int
)

if c.client == nil {
return fmt.Errorf("could not get host esxcli response: %w", govplus.ErrorNoClient)
}

t = time.Now()
for i, dc := range c.dcs {
for j, host := range c.hosts[i] {
Expand All @@ -482,7 +487,7 @@ func (c *VcCollector) ReportHostEsxcliResponse(
respondingCode = 0
if !hostSt.isHostConnected() {
respondingCode = 1
} else if !hostSt.isHostConnectedAndResponding(c.skipNotRespondigFor) {
} else if !hostSt.isHostConnectedAndResponding(z) {
respondingCode = 2
}
hsfields["respondingCode"] = respondingCode
Expand Down

0 comments on commit 4309319

Please sign in to comment.