Skip to content

Commit

Permalink
[bugfix] output responding_code also when not responding
Browse files Browse the repository at this point in the history
  • Loading branch information
Tesifonte Belda committed May 20, 2022
1 parent af45f9d commit de6bd0c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 4 additions & 0 deletions pkg/vccollector/vccollector_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,3 +251,7 @@ func (c *hostState) isHostConnectedAndResponding(skipDuration time.Duration) boo

return connectedResponding
}

func (c *hostState) isHostConnected() bool {
return !c.notConnected
}
11 changes: 6 additions & 5 deletions pkg/vccollector/vccollector_host.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,9 +378,6 @@ func (c *VcCollector) ReportHostEsxcliResponse(
acc.AddError(fmt.Errorf("Could not find host state for %s", host.Name()))
continue
}
if !hostSt.isHostConnectedAndResponding(c.skipNotRespondigFor) {
continue
}

hstags := getHostTags(
c.client.Client.URL().Host,
Expand All @@ -390,8 +387,12 @@ func (c *VcCollector) ReportHostEsxcliResponse(
host.Reference().Value,
)
responding_code = 0
if time.Since(hostSt.lastNoResponse) < c.dataDuration {
responding_code = 2
if !hostSt.isHostConnected() {
responding_code = 1
} else {
if !hostSt.isHostConnectedAndResponding(c.skipNotRespondigFor) {
responding_code = 2
}
}
hsfields := getEsxcliFields(
responding_code,
Expand Down

0 comments on commit de6bd0c

Please sign in to comment.