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