Skip to content

Commit

Permalink
Check whether we got a nil interface pointer back (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
rbarry82 authored Mar 4, 2023
1 parent f2a598a commit ce7faed
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.4
0.2.6
13 changes: 8 additions & 5 deletions nrpe_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,20 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) {
return
}
conn, err = openssl.Dial("tcp", c.target, ctx, openssl.InsecureSkipHostVerification)
if conn == (*openssl.Conn)(nil) || err != nil {
level.Error(c.logger).Log("msg", "Error dialing NRPE server", "err", err)
return
}
} else {
d := net.Dialer{}
conn, err = d.Dial("tcp", c.target)
if err != nil {
level.Error(c.logger).Log("msg", "Error dialing NRPE server", "err", err)
return
}
}
defer conn.Close()

if err != nil {
level.Error(c.logger).Log("msg", "Error dialing NRPE server", "err", err)
return
}

cmdResult, err := collectCommandMetrics(c.command, conn, c.logger)
if err != nil {
level.Error(c.logger).Log("msg", "Error running command", "command", c.command, "err", err)
Expand Down
2 changes: 2 additions & 0 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ github.com/canonical/nrped/common
# github.com/cespare/xxhash/v2 v2.1.1
## explicit; go 1.11
github.com/cespare/xxhash/v2
# github.com/davecgh/go-spew v1.1.1
## explicit
# github.com/go-kit/kit v0.9.0
## explicit
github.com/go-kit/kit/log
Expand Down

0 comments on commit ce7faed

Please sign in to comment.