forked from boynux/squid-exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
43 lines (33 loc) · 1.11 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"flag"
)
const (
defaultListenAddress = "127.0.0.1:9301"
defaultListenPort = 9301
defaultMetricsPath = "/metrics"
defaultSquidHostname = "localhost"
defaultSquidPort = 3128
)
/*Config configurations for exporter */
type Config struct {
ListenAddress string
ListenPort int
MetricPath string
SquidHostname string
SquidPort int
Login string
Password string
}
/*NewConfig creates a new config object from command line args */
func NewConfig() *Config {
c := &Config{}
flag.StringVar(&c.ListenAddress, "listen", defaultListenAddress, "Address and Port to bind exporter, in host:port format")
flag.StringVar(&c.MetricPath, "metrics-path", defaultMetricsPath, "Metrics path to expose prometheus metrics")
flag.StringVar(&c.SquidHostname, "squid-hostname", defaultSquidHostname, "Squid hostname")
flag.IntVar(&c.SquidPort, "squid-port", defaultSquidPort, "Squid port to read metrics")
flag.StringVar(&c.Login, "squid-login", "", "Login to squid service")
flag.StringVar(&c.Password, "squid-password", "", "Password to squid service")
flag.Parse()
return c
}