Skip to content

Commit

Permalink
feat: add listening address option
Browse files Browse the repository at this point in the history
  • Loading branch information
lconsuegra committed May 26, 2023
1 parent f7d63a8 commit 27ed34a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ipahealthcheck_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ var (
metricsPath string
ipahealthcheckPath string
ipahealthcheckLogPath string
address string
port int
sudo bool

Expand Down Expand Up @@ -89,6 +90,7 @@ func init() {
flag.StringVar(&metricsPath, "metrics-path", "/metrics", "Path under which to expose the metrics.")
flag.StringVar(&ipahealthcheckPath, "ipahealthcheck-path", "/usr/bin/ipa-healthcheck", "Path to the ipa-healthcheck binary.")
flag.StringVar(&ipahealthcheckLogPath, "ipahealthcheck-log-path", "/var/log/ipa/healthcheck/healthcheck.log", "Path to the ipa-healthcheck log file.")
flag.StringVar(&address, "address", "0.0.0.0", "Address on which to expose metrics.")
flag.IntVar(&port, "port", 9888, "Port on which to expose metrics.")
flag.BoolVar(&sudo, "sudo", false, "Use privilege escalation to run the health checks")
}
Expand Down Expand Up @@ -233,9 +235,9 @@ func main() {
}
})

log.Infof("ipa-healthcheck exporter listening on http://0.0.0.0:%d\n", port)
log.Infof("ipa-healthcheck exporter listening on http://%v:%d\n", address, port)

if err := http.ListenAndServe(fmt.Sprintf(":%d", port), nil); err != nil {
if err := http.ListenAndServe(fmt.Sprintf("%v:%d", address, port), nil); err != nil {
log.Fatal(err)
}
}

0 comments on commit 27ed34a

Please sign in to comment.