Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

Commit 44ce18c

Browse files
authored
Fix 0.4.0 compilation problem (#277)
* Fix parsing kingpin flags according to exporter-toolkit v0.8.2 Fixes #275 Signed-off-by: Nikolay Pelov <npelov@gmail.com> * Update README file to reflect the changed options from exporter-toolkit. * Update release version to 0.4.1 --------- Signed-off-by: Nikolay Pelov <npelov@gmail.com>
1 parent 3bd4633 commit 44ce18c

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ OS_TYPE ?= $(shell uname -s | tr '[:upper:]' '[:lower:]')
33
ARCH_TYPE ?= $(subst x86_64,amd64,$(patsubst i%86,386,$(ARCH)))
44
GOOS ?= $(shell go env GOOS)
55
GOARCH ?= $(shell go env GOARCH)
6-
VERSION ?= 0.4.0
6+
VERSION ?= 0.4.1
77
MAJOR_VERSION ?= 21
88
MINOR_VERSION ?= 8
99
ORACLE_VERSION ?= $(MAJOR_VERSION).$(MINOR_VERSION)

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ Usage of oracledb_exporter:
179179
File that may contain various custom metrics in a TOML file.
180180
--default.metrics string
181181
Default TOML file metrics.
182+
--web.systemd-socket
183+
Use systemd socket activation listeners instead of port listeners (Linux only).
182184
--web.listen-address string
183185
Address to listen on for web interface and telemetry. (default ":9161")
184186
--web.telemetry-path string
@@ -187,8 +189,8 @@ Usage of oracledb_exporter:
187189
Number of maximum idle connections in the connection pool. (default "0")
188190
--database.maxOpenConns string
189191
Number of maximum open connections in the connection pool. (default "10")
190-
--web.config
191-
Specify which web configuration file to load
192+
--web.config.file
193+
Path to configuration file that can enable TLS or authentication.
192194
```
193195

194196
# Default metrics
@@ -497,7 +499,7 @@ If you experience an error `Error scraping for wait_time: sql: Scan error on col
497499

498500
export NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P1
499501
export DATA_SOURCE_NAME=system/oracle@myhost
500-
/path/to/binary --log.level error --web.listen-address 9161
502+
/path/to/binary --log.level error --web.listen-address :9161
501503
```
502504

503505
If using Docker, set the same variable using the -e flag.

main.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"github.com/prometheus/common/promlog"
2929
"github.com/prometheus/common/promlog/flag"
3030
"github.com/prometheus/exporter-toolkit/web"
31+
webflag "github.com/prometheus/exporter-toolkit/web/kingpinflag"
3132
"gopkg.in/alecthomas/kingpin.v2"
3233
//Required for debugging
3334
//_ "net/http/pprof"
@@ -36,14 +37,12 @@ import (
3637
var (
3738
// Version will be set at build time.
3839
Version = "0.0.0.dev"
39-
listenAddress = kingpin.Flag("web.listen-address", "Address to listen on for web interface and telemetry. (env: LISTEN_ADDRESS)").Default(getEnv("LISTEN_ADDRESS", ":9161")).String()
4040
metricPath = kingpin.Flag("web.telemetry-path", "Path under which to expose metrics. (env: TELEMETRY_PATH)").Default(getEnv("TELEMETRY_PATH", "/metrics")).String()
4141
defaultFileMetrics = kingpin.Flag("default.metrics", "File with default metrics in a TOML file. (env: DEFAULT_METRICS)").Default(getEnv("DEFAULT_METRICS", "default-metrics.toml")).String()
4242
customMetrics = kingpin.Flag("custom.metrics", "File that may contain various custom metrics in a TOML file. (env: CUSTOM_METRICS)").Default(getEnv("CUSTOM_METRICS", "")).String()
4343
queryTimeout = kingpin.Flag("query.timeout", "Query timeout (in seconds). (env: QUERY_TIMEOUT)").Default(getEnv("QUERY_TIMEOUT", "5")).String()
4444
maxIdleConns = kingpin.Flag("database.maxIdleConns", "Number of maximum idle connections in the connection pool. (env: DATABASE_MAXIDLECONNS)").Default(getEnv("DATABASE_MAXIDLECONNS", "0")).Int()
4545
maxOpenConns = kingpin.Flag("database.maxOpenConns", "Number of maximum open connections in the connection pool. (env: DATABASE_MAXOPENCONNS)").Default(getEnv("DATABASE_MAXOPENCONNS", "10")).Int()
46-
tlsconfigFile = kingpin.Flag("web.config", "Path to config yaml file that can enable TLS or authentication.").Default("").String()
4746
scrapeInterval = kingpin.Flag("scrape.interval", "Interval between each scrape. Default is to scrape on collect requests").Default("0s").Duration()
4847
)
4948

@@ -587,6 +586,7 @@ func main() {
587586

588587
promlogConfig := &promlog.Config{}
589588
flag.AddFlags(kingpin.CommandLine, promlogConfig)
589+
var toolkitFlags = webflag.AddFlags(kingpin.CommandLine, ":9161")
590590

591591
kingpin.Version("oracledb_exporter " + Version)
592592
kingpin.HelpFlag.Short('h')
@@ -615,10 +615,9 @@ func main() {
615615
w.Write([]byte("<html><head><title>Oracle DB Exporter " + Version + "</title></head><body><h1>Oracle DB Exporter " + Version + "</h1><p><a href='" + *metricPath + "'>Metrics</a></p></body></html>"))
616616
})
617617

618-
level.Info(logger).Log("Listening on", *listenAddress)
619-
server := &http.Server{Addr: *listenAddress}
620-
if err := web.ListenAndServe(server, *tlsconfigFile, logger); err != nil {
621-
level.Error(logger).Log("err", err)
618+
server := &http.Server{}
619+
if err := web.ListenAndServe(server, toolkitFlags, logger); err != nil {
620+
level.Error(logger).Log("msg", err)
622621
os.Exit(1)
623622
}
624623
}

0 commit comments

Comments
 (0)