add cli options to enable the textfile collector
This commit is contained in:
parent
351d3344f7
commit
d81d494f19
@ -16,6 +16,8 @@ type AppSettings struct {
|
||||
MetricsPort int
|
||||
Fail2BanDbPath string
|
||||
Fail2BanSocketPath string
|
||||
FileCollectorPath string
|
||||
FileCollectorEnabled bool
|
||||
}
|
||||
|
||||
func Parse() *AppSettings {
|
||||
@ -24,6 +26,8 @@ func Parse() *AppSettings {
|
||||
flag.IntVar(&appSettings.MetricsPort, "port", 9191, "port to use for the metrics server")
|
||||
flag.StringVar(&appSettings.Fail2BanDbPath, "db", "", "path to the fail2ban sqlite database (deprecated)")
|
||||
flag.StringVar(&appSettings.Fail2BanSocketPath, "socket", "", "path to the fail2ban server socket")
|
||||
flag.BoolVar(&appSettings.FileCollectorEnabled, "collector.textfile", false, "enable the textfile collector")
|
||||
flag.StringVar(&appSettings.FileCollectorPath, "collector.textfile.directory", "", "directory to read text files with metrics from")
|
||||
|
||||
flag.Parse()
|
||||
appSettings.validateFlags()
|
||||
@ -42,6 +46,10 @@ func (settings *AppSettings) validateFlags() {
|
||||
minServerPort, maxServerPort, settings.MetricsPort)
|
||||
flagsValid = false
|
||||
}
|
||||
if settings.FileCollectorEnabled && settings.FileCollectorPath == "" {
|
||||
fmt.Printf("file collector directory must not be empty if collector enabled\n")
|
||||
flagsValid = false
|
||||
}
|
||||
}
|
||||
if !flagsValid {
|
||||
flag.Usage()
|
||||
|
Loading…
x
Reference in New Issue
Block a user