mirror of
https://github.com/prometheus-community/postgres_exporter
synced 2025-04-08 10:11:26 +00:00
Add CLI flag to return version info
Fixes wrouesnel/postgres_exporter#67.
This commit is contained in:
parent
1bf7f2435f
commit
5c587cb725
@ -11,6 +11,7 @@ import (
|
||||
"net/url"
|
||||
"os"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
@ -23,6 +24,7 @@ import (
|
||||
"github.com/prometheus/common/log"
|
||||
)
|
||||
|
||||
// executable version (set at build time by make)
|
||||
var Version string = "0.0.1"
|
||||
|
||||
var db *sql.DB = nil
|
||||
@ -44,6 +46,7 @@ var (
|
||||
"dumpmaps", false,
|
||||
"Do not run, simply dump the maps.",
|
||||
)
|
||||
showVersion = flag.Bool("version", false, "print version")
|
||||
)
|
||||
|
||||
// Metric name parts.
|
||||
@ -967,6 +970,14 @@ func (e *Exporter) scrape(ch chan<- prometheus.Metric) {
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
if *showVersion {
|
||||
fmt.Printf(
|
||||
"postgres_exporter %s (built with %s)\n",
|
||||
Version, runtime.Version(),
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
if *onlyDumpMaps {
|
||||
dumpMaps()
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user