Skip to content

Commit

Permalink
Log fetching problems.
Browse files Browse the repository at this point in the history
  • Loading branch information
bjoernalbers committed Jun 6, 2024
1 parent 9a45290 commit 26f1b64
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ func (c collector) Collect(ch chan<- prometheus.Metric) {
start := time.Now()
output, err := c.jmx.Fetch()
if err != nil {
log.Printf("Fetching metrics failed: %v\n", err)
ch <- prometheus.MustNewConstMetric(dcm4chee2Up, prometheus.GaugeValue, float64(0))
return
}
Expand Down Expand Up @@ -130,6 +131,7 @@ func main() {
flag.StringVar(&jmx.Password, "p", "admin", "Password of JBoss admin")
address := flag.String("a", ":9404", "Address to listen on")
flag.Parse()
log.Printf("Starting dcm4chee2-exporter, version %s\n", version)
prometheus.MustRegister(&collector{jmx})
http.Handle(metricsPath, promhttp.Handler())
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
Expand All @@ -144,6 +146,5 @@ func main() {
</html>
`))
})
log.Printf("Starting dcm4chee2-exporter, version %s\n", version)
log.Fatal(http.ListenAndServe(*address, nil))
}

0 comments on commit 26f1b64

Please sign in to comment.