Skip to content

Commit

Permalink
Merge pull request #14 from camptocamp/10-please-add-an-option-to-set…
Browse files Browse the repository at this point in the history
…-the-listening-ip-address-to-localhost

10 please add an option to set the listening ip address to localhost
  • Loading branch information
lconsuegra authored Oct 31, 2023
2 parents ca3322e + 4697388 commit a994e97
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ jobs:
go-version: 1.18
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v3
uses: goreleaser/goreleaser-action@v4
with:
version: latest
args: release --rm-dist
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 4 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
builds:
- goos:
- linux
- darwin
archives:
- wrap_in_directory: true
name_template: "{{ .ProjectName }}-{{ .Version }}.{{ .Os }}-{{ .Arch }}"
20 changes: 11 additions & 9 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 @@ -54,13 +55,13 @@ var (
metricsDesc: ipahealthcheckReplicationCheckDesc,
},
"ReplicationChangelogCheck": {
scrape: true,
metricsDesc: ipahealthcheckReplicationCheckDesc,
},
scrape: true,
metricsDesc: ipahealthcheckReplicationCheckDesc,
},
"ReplicationCheck": {
scrape: true,
metricsDesc: ipahealthcheckReplicationCheckDesc,
},
scrape: true,
metricsDesc: ipahealthcheckReplicationCheckDesc,
},
"DogtagCertsConnectivityCheck": {
scrape: true,
metricsDesc: ipahealthcheckDogtagCheckDesc,
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 All @@ -113,7 +115,7 @@ func (ic ipahealthcheckCollector) Collect(ch chan<- prometheus.Metric) {
if sudo {
healthCheckCmd = append([]string{"sudo"}, healthCheckCmd...)
log.Info("using sudo to execute health check")
}
}
cmd := exec.Command(healthCheckCmd[0], healthCheckCmd[1:]...)
cmd.Stderr = os.Stderr
err = cmd.Run()
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 a994e97

Please sign in to comment.