Skip to content

Commit

Permalink
Merge pull request #47 from wbollock/fix/version_update_warn
Browse files Browse the repository at this point in the history
fix: only warn if version getter fails
  • Loading branch information
wbollock authored Jan 10, 2024
2 parents 1577218 + 11708e3 commit ea9f0ab
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
6 changes: 1 addition & 5 deletions get_nagios_version/get_nagios_version.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package get_nagios_version

import (
"fmt"
"net/http"
"strings"

log "github.com/sirupsen/logrus"
"golang.org/x/net/html"
)

Expand All @@ -14,15 +12,13 @@ func GetLatestNagiosXIVersion(NagiosXIURL string) (version string, err error) {
// Fetch the HTML source data from the URL
resp, err := http.Get(NagiosXIURL)
if err != nil {
fmt.Println("Error fetching HTML:", err)
return
return "", err
}
defer resp.Body.Close()

// Parse the HTML data into a tree structure
doc, err := html.Parse(resp.Body)
if err != nil {
log.Info(err)
return "", err
}

Expand Down
3 changes: 2 additions & 1 deletion nagios_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,8 @@ func (e *Exporter) QueryAPIsAndUpdateMetrics(ch chan<- prometheus.Metric, sslVer
if checkUpdates {
nagiosVersion, err := get_nagios_version.GetLatestNagiosXIVersion(NagiosXIURL)
if err != nil {
log.Fatal(err)
// don't abandon exporter just for version updater issues
log.Warn(err)
}

updateMetric := CompareNagiosVersions(nagiosVersion, systemInfoObject.Version)
Expand Down

0 comments on commit ea9f0ab

Please sign in to comment.