Skip to content

Commit 5c587cb

Browse files
Tyler Yahnwrouesnel
Tyler Yahn
authored andcommitted
Add CLI flag to return version info
Fixes prometheus-community#67.
1 parent 1bf7f24 commit 5c587cb

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

postgres_exporter.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"net/url"
1212
"os"
1313
"regexp"
14+
"runtime"
1415
"strconv"
1516
"sync"
1617
"time"
@@ -23,6 +24,7 @@ import (
2324
"github.com/prometheus/common/log"
2425
)
2526

27+
// executable version (set at build time by make)
2628
var Version string = "0.0.1"
2729

2830
var db *sql.DB = nil
@@ -44,6 +46,7 @@ var (
4446
"dumpmaps", false,
4547
"Do not run, simply dump the maps.",
4648
)
49+
showVersion = flag.Bool("version", false, "print version")
4750
)
4851

4952
// Metric name parts.
@@ -967,6 +970,14 @@ func (e *Exporter) scrape(ch chan<- prometheus.Metric) {
967970
func main() {
968971
flag.Parse()
969972

973+
if *showVersion {
974+
fmt.Printf(
975+
"postgres_exporter %s (built with %s)\n",
976+
Version, runtime.Version(),
977+
)
978+
return
979+
}
980+
970981
if *onlyDumpMaps {
971982
dumpMaps()
972983
return

0 commit comments

Comments
 (0)