1
0
mirror of https://github.com/prometheus-community/postgres_exporter.git synced 2025-07-30 09:43:10 +03:00

Refactor PR #157 to fit the new repository format.

This didn't actually need all that much change, it fits perfectly.
This commit is contained in:
Will Rouesnel
2018-03-06 18:49:00 +11:00
parent 2ab8f10935
commit dfc644214b
2 changed files with 16 additions and 9 deletions

View File

@ -5,12 +5,14 @@ import (
"net/http"
"runtime"
"gopkg.in/alecthomas/kingpin.v2"
_ "github.com/lib/pq"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/prometheus/common/log"
"github.com/wrouesnel/postgres_exporter/collector"
"gopkg.in/alecthomas/kingpin.v2"
)
// Version is set during build to the git describe version
@ -18,10 +20,13 @@ import (
var Version = "0.0.1"
var (
listenAddress = kingpin.Flag("web.listen-address", "Address to listen on for web interface and telemetry.").Default(":9187").OverrideDefaultFromEnvar("PG_EXPORTER_WEB_LISTEN_ADDRESS").String()
metricPath = kingpin.Flag("web.telemetry-path", "Path under which to expose metrics.").Default("/metrics").OverrideDefaultFromEnvar("PG_EXPORTER_WEB_TELEMETRY_PATH").String()
queriesPath = kingpin.Flag("extend.query-path", "Path to custom queries to run.").Default("").OverrideDefaultFromEnvar("PG_EXPORTER_EXTEND_QUERY_PATH").String()
onlyDumpMaps = kingpin.Flag("dumpmaps", "Do not run, simply dump the maps.").Bool()
listenAddress = kingpin.Flag("web.listen-address", "Address to listen on for web interface and telemetry.").
Default(":9187").Envar("PG_EXPORTER_WEB_LISTEN_ADDRESS").String()
metricPath = kingpin.Flag("web.telemetry-path", "Path under which to expose metrics.").
Default("/metrics").Envar("PG_EXPORTER_WEB_TELEMETRY_PATH").String()
queriesPath = kingpin.Flag("extend.query-path", "Path to custom queries to run.").
Default("").Envar("PG_EXPORTER_EXTEND_QUERY_PATH").String()
onlyDumpMaps = kingpin.Flag("dumpmaps", "Do not run, simply dump the maps.").Bool()
)
func main() {

View File

@ -3,11 +3,13 @@
package collector
import (
. "gopkg.in/check.v1"
"testing"
"github.com/blang/semver"
. "gopkg.in/check.v1"
"os"
"github.com/blang/semver"
)
// Hook up gocheck into the "go test" runner.
@ -89,11 +91,11 @@ func (s *FunctionalSuite) TestSemanticVersionColumnDiscard(c *C) {
// test read username and password from file
func (s *FunctionalSuite) TestEnvironmentSettingWithSecretsFiles(c *C) {
err := os.Setenv("DATA_SOURCE_USER_FILE", "../tests/username_file")
err := os.Setenv("DATA_SOURCE_USER_FILE", "../cmd/postgres_exporter/tests/username_file")
c.Assert(err, IsNil)
defer UnsetEnvironment(c, "DATA_SOURCE_USER_FILE")
err = os.Setenv("DATA_SOURCE_PASS_FILE", "../tests/userpass_file")
err = os.Setenv("DATA_SOURCE_PASS_FILE", "../cmd/postgres_exporter/tests/userpass_file")
c.Assert(err, IsNil)
defer UnsetEnvironment(c, "DATA_SOURCE_PASS_FILE")