From f46abf36e80a67d13d12dbe4ba8c899026e53961 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 31 Jul 2021 18:20:03 +0300 Subject: more on configurable colors --- cmd/dgrep/main.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'cmd/dgrep/main.go') diff --git a/cmd/dgrep/main.go b/cmd/dgrep/main.go index 4da1bb3..422bdd4 100644 --- a/cmd/dgrep/main.go +++ b/cmd/dgrep/main.go @@ -6,7 +6,6 @@ import ( "os" "github.com/mimecast/dtail/internal/clients" - "github.com/mimecast/dtail/internal/color" "github.com/mimecast/dtail/internal/config" "github.com/mimecast/dtail/internal/io/logger" "github.com/mimecast/dtail/internal/io/signal" @@ -46,7 +45,9 @@ func main() { flag.Parse() config.Read(cfgFile, sshPort) - color.Colored = !noColor + if noColor { + config.Client.TermColorsEnabled = false + } if displayVersion { version.PrintAndExit() -- cgit v1.2.3 From 3cc8887885f24a3f0d607af24197bc364ab16b8d Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Thu, 12 Aug 2021 10:56:36 +0300 Subject: add missing brush and also add color client configs plus jsonschema --- cmd/dgrep/main.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'cmd/dgrep/main.go') diff --git a/cmd/dgrep/main.go b/cmd/dgrep/main.go index 422bdd4..f32be34 100644 --- a/cmd/dgrep/main.go +++ b/cmd/dgrep/main.go @@ -46,12 +46,13 @@ func main() { config.Read(cfgFile, sshPort) if noColor { - config.Client.TermColorsEnabled = false + config.Client.TermColorsEnable = false } if displayVersion { version.PrintAndExit() } + version.Print() ctx := context.TODO() logger.Start(ctx, logger.Modes{ -- cgit v1.2.3 From 7fbea88cf55af9b3354b4a1334e49c38d0d920fc Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 18 Sep 2021 13:16:36 +0300 Subject: additional flags can be interpreted as file list --- cmd/dgrep/main.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'cmd/dgrep/main.go') diff --git a/cmd/dgrep/main.go b/cmd/dgrep/main.go index f32be34..35b2236 100644 --- a/cmd/dgrep/main.go +++ b/cmd/dgrep/main.go @@ -4,6 +4,7 @@ import ( "context" "flag" "os" + "strings" "github.com/mimecast/dtail/internal/clients" "github.com/mimecast/dtail/internal/config" @@ -44,6 +45,15 @@ func main() { flag.Parse() + if args.What == "" { + // Interpret additional args as file list. + var files []string + for _, file := range flag.Args() { + files = append(files, file) + } + args.What = strings.Join(files, ",") + } + config.Read(cfgFile, sshPort) if noColor { config.Client.TermColorsEnable = false -- cgit v1.2.3 From 6506e20f6c80f4acb7434eb9dd14f784a67189cd Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 18 Sep 2021 14:41:25 +0300 Subject: add spartan mode --- cmd/dgrep/main.go | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) (limited to 'cmd/dgrep/main.go') diff --git a/cmd/dgrep/main.go b/cmd/dgrep/main.go index 35b2236..7b96472 100644 --- a/cmd/dgrep/main.go +++ b/cmd/dgrep/main.go @@ -4,7 +4,6 @@ import ( "context" "flag" "os" - "strings" "github.com/mimecast/dtail/internal/clients" "github.com/mimecast/dtail/internal/config" @@ -21,17 +20,17 @@ func main() { var debugEnable bool var displayVersion bool var grep string - var noColor bool var sshPort int userName := user.Name() + flag.BoolVar(&args.Quiet, "quiet", false, "Quiet output mode") flag.BoolVar(&args.RegexInvert, "invert", false, "Invert regex") + flag.BoolVar(&args.Spartan, "spartan", false, "Spartan output mode") flag.BoolVar(&args.TrustAllHosts, "trustAllHosts", false, "Auto trust all unknown host keys") flag.BoolVar(&debugEnable, "debug", false, "Activate debug messages") flag.BoolVar(&displayVersion, "version", false, "Display version") - flag.BoolVar(&noColor, "noColor", false, "Disable ANSII terminal colors") - flag.BoolVar(&args.Quiet, "quiet", false, "Quiet output mode") + flag.BoolVar(&args.NoColor, "noColor", false, "Disable ANSII terminal colors") flag.IntVar(&args.ConnectionsPerCPU, "cpc", 10, "How many connections established per CPU core concurrently") flag.IntVar(&sshPort, "port", 2222, "SSH server port") flag.StringVar(&args.Discovery, "discovery", "", "Server discovery method") @@ -44,25 +43,16 @@ func main() { flag.StringVar(&grep, "grep", "", "Alias for -regex") flag.Parse() - - if args.What == "" { - // Interpret additional args as file list. - var files []string - for _, file := range flag.Args() { - files = append(files, file) - } - args.What = strings.Join(files, ",") - } - - config.Read(cfgFile, sshPort) - if noColor { - config.Client.TermColorsEnable = false - } + args.Transform(flag.Args()) + config.Read(cfgFile, sshPort, args.NoColor) + args.TransformAfterConfigFile() if displayVersion { version.PrintAndExit() } - version.Print() + if !args.Spartan { + version.Print() + } ctx := context.TODO() logger.Start(ctx, logger.Modes{ -- cgit v1.2.3 From fe3e68afd99d8ea246be52893730f987e138ec24 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 19 Sep 2021 13:22:59 +0300 Subject: move args to config package logger package rewrite as dlog --- cmd/dgrep/main.go | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) (limited to 'cmd/dgrep/main.go') diff --git a/cmd/dgrep/main.go b/cmd/dgrep/main.go index 7b96472..c6bece0 100644 --- a/cmd/dgrep/main.go +++ b/cmd/dgrep/main.go @@ -4,10 +4,11 @@ import ( "context" "flag" "os" + "sync" "github.com/mimecast/dtail/internal/clients" "github.com/mimecast/dtail/internal/config" - "github.com/mimecast/dtail/internal/io/logger" + "github.com/mimecast/dtail/internal/io/dlog" "github.com/mimecast/dtail/internal/io/signal" "github.com/mimecast/dtail/internal/user" "github.com/mimecast/dtail/internal/version" @@ -15,37 +16,32 @@ import ( // The evil begins here. func main() { - var args clients.Args - var cfgFile string - var debugEnable bool + var args config.Args var displayVersion bool var grep string - var sshPort int userName := user.Name() + flag.BoolVar(&args.NoColor, "noColor", false, "Disable ANSII terminal colors") flag.BoolVar(&args.Quiet, "quiet", false, "Quiet output mode") flag.BoolVar(&args.RegexInvert, "invert", false, "Invert regex") flag.BoolVar(&args.Spartan, "spartan", false, "Spartan output mode") - flag.BoolVar(&args.TrustAllHosts, "trustAllHosts", false, "Auto trust all unknown host keys") - flag.BoolVar(&debugEnable, "debug", false, "Activate debug messages") + flag.BoolVar(&args.TrustAllHosts, "trustAllHosts", false, "Trust all unknown host keys") flag.BoolVar(&displayVersion, "version", false, "Display version") - flag.BoolVar(&args.NoColor, "noColor", false, "Disable ANSII terminal colors") flag.IntVar(&args.ConnectionsPerCPU, "cpc", 10, "How many connections established per CPU core concurrently") - flag.IntVar(&sshPort, "port", 2222, "SSH server port") + flag.IntVar(&args.SSHPort, "port", 2222, "SSH server port") + flag.StringVar(&args.ConfigFile, "cfg", "", "Config file path") flag.StringVar(&args.Discovery, "discovery", "", "Server discovery method") + flag.StringVar(&args.LogLevel, "logLevel", "", "Log level") flag.StringVar(&args.PrivateKeyPathFile, "key", "", "Path to private key") flag.StringVar(&args.RegexStr, "regex", ".", "Regular expression") flag.StringVar(&args.ServersStr, "servers", "", "Remote servers to connect") flag.StringVar(&args.UserName, "user", userName, "Your system user name") flag.StringVar(&args.What, "files", "", "File(s) to read") - flag.StringVar(&cfgFile, "cfg", "", "Config file path") flag.StringVar(&grep, "grep", "", "Alias for -regex") flag.Parse() - args.Transform(flag.Args()) - config.Read(cfgFile, sshPort, args.NoColor) - args.TransformAfterConfigFile() + config.Setup(&args, flag.Args()) if displayVersion { version.PrintAndExit() @@ -54,11 +50,10 @@ func main() { version.Print() } - ctx := context.TODO() - logger.Start(ctx, logger.Modes{ - Debug: debugEnable || config.Common.DebugEnable, - Quiet: args.Quiet, - }) + ctx, cancel := context.WithCancel(context.Background()) + var wg sync.WaitGroup + wg.Add(1) + dlog.Start(ctx, &wg, dlog.CLIENT, args.LogLevel) if grep != "" { args.RegexStr = grep @@ -70,6 +65,8 @@ func main() { } status := client.Start(ctx, signal.InterruptCh(ctx)) - logger.Flush() + cancel() + + wg.Wait() os.Exit(status) } -- cgit v1.2.3 From fcaa94c7453efa0d74e330128c0f5c2cde8f11b3 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 26 Sep 2021 16:42:47 +0300 Subject: refactor config reader - also looks in additional search paths for config file unless NONE is specified --- cmd/dgrep/main.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'cmd/dgrep/main.go') diff --git a/cmd/dgrep/main.go b/cmd/dgrep/main.go index c6bece0..36efe4e 100644 --- a/cmd/dgrep/main.go +++ b/cmd/dgrep/main.go @@ -28,10 +28,11 @@ func main() { flag.BoolVar(&args.Spartan, "spartan", false, "Spartan output mode") flag.BoolVar(&args.TrustAllHosts, "trustAllHosts", false, "Trust all unknown host keys") flag.BoolVar(&displayVersion, "version", false, "Display version") - flag.IntVar(&args.ConnectionsPerCPU, "cpc", 10, "How many connections established per CPU core concurrently") - flag.IntVar(&args.SSHPort, "port", 2222, "SSH server port") + flag.IntVar(&args.ConnectionsPerCPU, "cpc", config.DefaultConnectionsPerCPU, "How many connections established per CPU core concurrently") + flag.IntVar(&args.SSHPort, "port", config.DefaultSSHPort, "SSH server port") flag.StringVar(&args.ConfigFile, "cfg", "", "Config file path") flag.StringVar(&args.Discovery, "discovery", "", "Server discovery method") + flag.StringVar(&args.LogDir, "logDir", "", "Log dir") flag.StringVar(&args.LogLevel, "logLevel", "", "Log level") flag.StringVar(&args.PrivateKeyPathFile, "key", "", "Path to private key") flag.StringVar(&args.RegexStr, "regex", ".", "Regular expression") -- cgit v1.2.3 From 6e1af993924bc7bebe898b403962db5a6b3505d1 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 2 Oct 2021 11:23:08 +0300 Subject: Client default log dir is ~/log --- cmd/dgrep/main.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'cmd/dgrep/main.go') diff --git a/cmd/dgrep/main.go b/cmd/dgrep/main.go index 36efe4e..4f21a9e 100644 --- a/cmd/dgrep/main.go +++ b/cmd/dgrep/main.go @@ -10,6 +10,7 @@ import ( "github.com/mimecast/dtail/internal/config" "github.com/mimecast/dtail/internal/io/dlog" "github.com/mimecast/dtail/internal/io/signal" + "github.com/mimecast/dtail/internal/source" "github.com/mimecast/dtail/internal/user" "github.com/mimecast/dtail/internal/version" ) @@ -32,7 +33,7 @@ func main() { flag.IntVar(&args.SSHPort, "port", config.DefaultSSHPort, "SSH server port") flag.StringVar(&args.ConfigFile, "cfg", "", "Config file path") flag.StringVar(&args.Discovery, "discovery", "", "Server discovery method") - flag.StringVar(&args.LogDir, "logDir", "", "Log dir") + flag.StringVar(&args.LogDir, "logDir", "~/log", "Log dir") flag.StringVar(&args.LogLevel, "logLevel", "", "Log level") flag.StringVar(&args.PrivateKeyPathFile, "key", "", "Path to private key") flag.StringVar(&args.RegexStr, "regex", ".", "Regular expression") @@ -54,7 +55,7 @@ func main() { ctx, cancel := context.WithCancel(context.Background()) var wg sync.WaitGroup wg.Add(1) - dlog.Start(ctx, &wg, dlog.CLIENT, args.LogLevel) + dlog.Start(ctx, &wg, source.Client, args.LogLevel) if grep != "" { args.RegexStr = grep -- cgit v1.2.3 From 07e1470892beacf0722276f94bacbd822b002540 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 3 Oct 2021 13:09:32 +0300 Subject: add dmap tests --- cmd/dgrep/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmd/dgrep/main.go') diff --git a/cmd/dgrep/main.go b/cmd/dgrep/main.go index 4f21a9e..95db6f0 100644 --- a/cmd/dgrep/main.go +++ b/cmd/dgrep/main.go @@ -43,7 +43,7 @@ func main() { flag.StringVar(&grep, "grep", "", "Alias for -regex") flag.Parse() - config.Setup(&args, flag.Args()) + config.Setup(source.Client, &args, flag.Args()) if displayVersion { version.PrintAndExit() -- cgit v1.2.3 From 2d7ddbeae8286373ac19787dc7dde598a7cb0598 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Fri, 8 Oct 2021 11:43:43 +0300 Subject: refactor --- cmd/dgrep/main.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'cmd/dgrep/main.go') diff --git a/cmd/dgrep/main.go b/cmd/dgrep/main.go index 95db6f0..529331d 100644 --- a/cmd/dgrep/main.go +++ b/cmd/dgrep/main.go @@ -34,6 +34,7 @@ func main() { flag.StringVar(&args.ConfigFile, "cfg", "", "Config file path") flag.StringVar(&args.Discovery, "discovery", "", "Server discovery method") flag.StringVar(&args.LogDir, "logDir", "~/log", "Log dir") + flag.StringVar(&args.Logger, "logger", config.DefaultClientLogger, "Logger name") flag.StringVar(&args.LogLevel, "logLevel", "", "Log level") flag.StringVar(&args.PrivateKeyPathFile, "key", "", "Path to private key") flag.StringVar(&args.RegexStr, "regex", ".", "Regular expression") @@ -55,7 +56,7 @@ func main() { ctx, cancel := context.WithCancel(context.Background()) var wg sync.WaitGroup wg.Add(1) - dlog.Start(ctx, &wg, source.Client, args.LogLevel) + dlog.Start(ctx, &wg, source.Client) if grep != "" { args.RegexStr = grep -- cgit v1.2.3 From 97747ea0f3178f7f5890512d483fdccaa82846b0 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 9 Oct 2021 21:10:29 +0300 Subject: vetting and linting and some code restyling --- cmd/dgrep/main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'cmd/dgrep/main.go') diff --git a/cmd/dgrep/main.go b/cmd/dgrep/main.go index 529331d..576e22b 100644 --- a/cmd/dgrep/main.go +++ b/cmd/dgrep/main.go @@ -20,7 +20,6 @@ func main() { var args config.Args var displayVersion bool var grep string - userName := user.Name() flag.BoolVar(&args.NoColor, "noColor", false, "Disable ANSII terminal colors") @@ -29,7 +28,8 @@ func main() { flag.BoolVar(&args.Spartan, "spartan", false, "Spartan output mode") flag.BoolVar(&args.TrustAllHosts, "trustAllHosts", false, "Trust all unknown host keys") flag.BoolVar(&displayVersion, "version", false, "Display version") - flag.IntVar(&args.ConnectionsPerCPU, "cpc", config.DefaultConnectionsPerCPU, "How many connections established per CPU core concurrently") + flag.IntVar(&args.ConnectionsPerCPU, "cpc", config.DefaultConnectionsPerCPU, + "How many connections established per CPU core concurrently") flag.IntVar(&args.SSHPort, "port", config.DefaultSSHPort, "SSH server port") flag.StringVar(&args.ConfigFile, "cfg", "", "Config file path") flag.StringVar(&args.Discovery, "discovery", "", "Server discovery method") -- cgit v1.2.3 From f44792c9102488774c9993b080f35c65287a64b1 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 10 Oct 2021 14:02:12 +0300 Subject: add another dmap test - reading 100 source files at once fix a data race when reading multiple files on one server from the same session at once --- cmd/dgrep/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmd/dgrep/main.go') diff --git a/cmd/dgrep/main.go b/cmd/dgrep/main.go index 576e22b..da3f7a4 100644 --- a/cmd/dgrep/main.go +++ b/cmd/dgrep/main.go @@ -35,7 +35,7 @@ func main() { flag.StringVar(&args.Discovery, "discovery", "", "Server discovery method") flag.StringVar(&args.LogDir, "logDir", "~/log", "Log dir") flag.StringVar(&args.Logger, "logger", config.DefaultClientLogger, "Logger name") - flag.StringVar(&args.LogLevel, "logLevel", "", "Log level") + flag.StringVar(&args.LogLevel, "logLevel", config.DefaultLogLevel, "Log level") flag.StringVar(&args.PrivateKeyPathFile, "key", "", "Path to private key") flag.StringVar(&args.RegexStr, "regex", ".", "Regular expression") flag.StringVar(&args.ServersStr, "servers", "", "Remote servers to connect") -- cgit v1.2.3 From 1dead22129a26e4f532e68c2c63fe4122b519506 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 13 Oct 2021 21:10:28 +0300 Subject: Merging grep context from master --- cmd/dgrep/main.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'cmd/dgrep/main.go') diff --git a/cmd/dgrep/main.go b/cmd/dgrep/main.go index da3f7a4..2d7e53b 100644 --- a/cmd/dgrep/main.go +++ b/cmd/dgrep/main.go @@ -30,6 +30,9 @@ func main() { flag.BoolVar(&displayVersion, "version", false, "Display version") flag.IntVar(&args.ConnectionsPerCPU, "cpc", config.DefaultConnectionsPerCPU, "How many connections established per CPU core concurrently") + flag.IntVar(&args.LContext.AfterContext, "after", 0, "Print lines of trailing context after matching lines") + flag.IntVar(&args.LContext.BeforeContext, "before", 0, "Print lines of leading context before matching lines") + flag.IntVar(&args.LContext.MaxCount, "max", 0, "Stop reading file after NUM matching lines") flag.IntVar(&args.SSHPort, "port", config.DefaultSSHPort, "SSH server port") flag.StringVar(&args.ConfigFile, "cfg", "", "Config file path") flag.StringVar(&args.Discovery, "discovery", "", "Server discovery method") -- cgit v1.2.3 From 06ece112c0dd20c0c211c538216fe64ebe4045c9 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Thu, 14 Oct 2021 20:10:55 +0300 Subject: add dgrep context integration tests --- cmd/dgrep/main.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'cmd/dgrep/main.go') diff --git a/cmd/dgrep/main.go b/cmd/dgrep/main.go index 2d7e53b..3cbb3cc 100644 --- a/cmd/dgrep/main.go +++ b/cmd/dgrep/main.go @@ -3,9 +3,14 @@ package main import ( "context" "flag" + "fmt" "os" "sync" + "net/http" + _ "net/http" + _ "net/http/pprof" + "github.com/mimecast/dtail/internal/clients" "github.com/mimecast/dtail/internal/config" "github.com/mimecast/dtail/internal/io/dlog" @@ -20,6 +25,7 @@ func main() { var args config.Args var displayVersion bool var grep string + var pprof int userName := user.Name() flag.BoolVar(&args.NoColor, "noColor", false, "Disable ANSII terminal colors") @@ -34,6 +40,7 @@ func main() { flag.IntVar(&args.LContext.BeforeContext, "before", 0, "Print lines of leading context before matching lines") flag.IntVar(&args.LContext.MaxCount, "max", 0, "Stop reading file after NUM matching lines") flag.IntVar(&args.SSHPort, "port", config.DefaultSSHPort, "SSH server port") + flag.IntVar(&pprof, "pprof", -1, "Start PProf server this port") flag.StringVar(&args.ConfigFile, "cfg", "", "Config file path") flag.StringVar(&args.Discovery, "discovery", "", "Server discovery method") flag.StringVar(&args.LogDir, "logDir", "~/log", "Log dir") @@ -65,6 +72,13 @@ func main() { args.RegexStr = grep } + if pprof > -1 { + // For debugging purposes only + pprofArgs := fmt.Sprintf("0.0.0.0:%d", pprof) + go http.ListenAndServe(pprofArgs, nil) + dlog.Client.Info("Started PProf", pprofArgs) + } + client, err := clients.NewGrepClient(args) if err != nil { panic(err) -- cgit v1.2.3 From c0332e8fa13f4939de17c856b2e71fd093847253 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Fri, 15 Oct 2021 09:04:40 +0300 Subject: add dcat color output test --- cmd/dgrep/main.go | 3 --- 1 file changed, 3 deletions(-) (limited to 'cmd/dgrep/main.go') diff --git a/cmd/dgrep/main.go b/cmd/dgrep/main.go index 3cbb3cc..602d318 100644 --- a/cmd/dgrep/main.go +++ b/cmd/dgrep/main.go @@ -59,9 +59,6 @@ func main() { if displayVersion { version.PrintAndExit() } - if !args.Spartan { - version.Print() - } ctx, cancel := context.WithCancel(context.Background()) var wg sync.WaitGroup -- cgit v1.2.3 From b679462fa687b375ccefd3c11fec3fd96b9b4d60 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 20 Oct 2021 06:41:08 +0300 Subject: make pprof bind address configurable --- cmd/dgrep/main.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'cmd/dgrep/main.go') diff --git a/cmd/dgrep/main.go b/cmd/dgrep/main.go index 602d318..02b2463 100644 --- a/cmd/dgrep/main.go +++ b/cmd/dgrep/main.go @@ -3,7 +3,6 @@ package main import ( "context" "flag" - "fmt" "os" "sync" @@ -25,7 +24,7 @@ func main() { var args config.Args var displayVersion bool var grep string - var pprof int + var pprof string userName := user.Name() flag.BoolVar(&args.NoColor, "noColor", false, "Disable ANSII terminal colors") @@ -40,7 +39,6 @@ func main() { flag.IntVar(&args.LContext.BeforeContext, "before", 0, "Print lines of leading context before matching lines") flag.IntVar(&args.LContext.MaxCount, "max", 0, "Stop reading file after NUM matching lines") flag.IntVar(&args.SSHPort, "port", config.DefaultSSHPort, "SSH server port") - flag.IntVar(&pprof, "pprof", -1, "Start PProf server this port") flag.StringVar(&args.ConfigFile, "cfg", "", "Config file path") flag.StringVar(&args.Discovery, "discovery", "", "Server discovery method") flag.StringVar(&args.LogDir, "logDir", "~/log", "Log dir") @@ -52,6 +50,7 @@ func main() { flag.StringVar(&args.UserName, "user", userName, "Your system user name") flag.StringVar(&args.What, "files", "", "File(s) to read") flag.StringVar(&grep, "grep", "", "Alias for -regex") + flag.StringVar(&pprof, "pprof", "", "Start PProf server this address") flag.Parse() config.Setup(source.Client, &args, flag.Args()) @@ -69,11 +68,9 @@ func main() { args.RegexStr = grep } - if pprof > -1 { - // For debugging purposes only - pprofArgs := fmt.Sprintf("0.0.0.0:%d", pprof) - go http.ListenAndServe(pprofArgs, nil) - dlog.Client.Info("Started PProf", pprofArgs) + if pprof != "" { + go http.ListenAndServe(pprof, nil) + dlog.Client.Info("Started PProf", pprof) } client, err := clients.NewGrepClient(args) -- cgit v1.2.3