diff --git a/cmd/client/main.go b/cmd/client/main.go index 8fac5e3..1773b1e 100644 --- a/cmd/client/main.go +++ b/cmd/client/main.go @@ -42,7 +42,7 @@ import ( ) var ( - myFqdn = kingpin.Flag("fqdn", "FQDN to register with").Default(fqdn.Get()).String() + myFqdn = kingpin.Flag("fqdn", "FQDN to register with").Default(default_fqdn()).String() proxyURL = kingpin.Flag("proxy-url", "Push proxy to talk to.").Required().String() caCertFile = kingpin.Flag("tls.cacert", " CA certificate to verify peer against").String() tlsCert = kingpin.Flag("tls.cert", " Client certificate file").String() @@ -74,6 +74,14 @@ var ( ) ) +func default_fqdn() string { + hostname, err := fqdn.FqdnHostname() + if err != nil { + return "" + } + return hostname +} + func init() { prometheus.MustRegister(pushErrorCounter, pollErrorCounter, scrapeErrorCounter) } @@ -235,6 +243,10 @@ func main() { logger := promlog.New(&promlogConfig) coordinator := Coordinator{logger: logger} + if *myFqdn == "" { + level.Error(coordinator.logger).Log("msg", "Missing FQDN hostname, use --fqdn.") + os.Exit(1) + } if *proxyURL == "" { level.Error(coordinator.logger).Log("msg", "--proxy-url flag must be specified.") os.Exit(1)