Skip to content

Commit

Permalink
feat: add verbose argument
Browse files Browse the repository at this point in the history
  • Loading branch information
lconsuegra committed Oct 31, 2023
1 parent a994e97 commit e8a5126
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,20 @@ The following arguments are supported :

```sh
# ./ipa-healthcheck_exporter -h
Usage of ./ipa-healthcheck_exporter:
Usage of ./ipahealthcheck_exporter:
-address string
Address on which to expose metrics. (default "0.0.0.0")
-ipahealthcheck-log-path string
Path to the ipa-healthcheck log file. (default "/var/log/ipa/healthcheck/healthcheck.log")
-ipahealthcheck-path string
Path to the ipa-healthcheck tool. (default "/usr/bin/ipa-healthcheck")
Path to the ipa-healthcheck binary. (default "/usr/bin/ipa-healthcheck")
-metrics-path string
Path under which to expose metrics. (default "/metrics")
Path under which to expose the metrics. (default "/metrics")
-port int
Port on which to expose metrics. (default 9888)
-sudo
Use privilege escalation to run the health checks
Use privilege escalation to run the health checks
-v Verbose mode (print more logs)
```

## Exported Metrics
Expand Down
9 changes: 9 additions & 0 deletions ipahealthcheck_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var (
address string
port int
sudo bool
verbose bool

ipahealthcheckServiceStateDesc = prometheus.NewDesc(
"ipa_service_state",
Expand Down Expand Up @@ -93,6 +94,7 @@ func init() {
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")
flag.BoolVar(&verbose, "v", false, "Verbose mode (print more logs)")
}

func (ic ipahealthcheckCollector) Describe(ch chan<- *prometheus.Desc) {
Expand Down Expand Up @@ -137,6 +139,10 @@ func (ic ipahealthcheckCollector) Collect(ch chan<- prometheus.Metric) {

for _, check := range checks {

if verbose {
log.Debugf("Found check from cmd : %v = %v\n", check.Check, check.Result)
}

if check.Result == "SUCCESS" {
ch <- prometheus.MustNewConstMetric(ipahealthcheckServiceStateDesc, prometheus.GaugeValue, 1.0, check.Check)
} else {
Expand All @@ -158,6 +164,9 @@ func (ic ipahealthcheckCollector) Collect(ch chan<- prometheus.Metric) {

for _, check := range checks {

if verbose {
log.Debugf("Found check from logfile : %v = %v\n", check.Check, check.Result)
}
if scrapedChecks[check.Check].scrape {

if check.Result == "SUCCESS" {
Expand Down

0 comments on commit e8a5126

Please sign in to comment.