summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorPaul Buetow <pbuetow@mimecast.com>2021-10-21 21:28:49 +0300
committerPaul Buetow <pbuetow@mimecast.com>2021-10-21 21:28:49 +0300
commitf4207a55f71bfbcfdc532d5cdd3befaa3474a157 (patch)
treeea5e4a2d2a67035f645bdee496ae55a52034178a /cmd
parentd80d6070557e3a800e3a54967af9eced518f116b (diff)
parent739205206d63bf42f4e843b39d04d4c8cd8207c3 (diff)
merge develop
Diffstat (limited to 'cmd')
-rw-r--r--cmd/dcat/main.go57
-rw-r--r--cmd/dcat/testdata.txt500
-rw-r--r--cmd/dgrep/main.go74
-rw-r--r--cmd/dmap/main.go65
-rw-r--r--cmd/dserver/main.go56
-rw-r--r--cmd/dtail/main.go101
-rw-r--r--cmd/dtailhealth/main.go53
7 files changed, 749 insertions, 157 deletions
diff --git a/cmd/dcat/main.go b/cmd/dcat/main.go
index 238f97a..5fd22ea 100644
--- a/cmd/dcat/main.go
+++ b/cmd/dcat/main.go
@@ -4,55 +4,64 @@ import (
"context"
"flag"
"os"
+ "sync"
+
+ "net/http"
+ _ "net/http"
+ _ "net/http/pprof"
"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/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"
)
// The evil begins here.
func main() {
- var args clients.Args
- var cfgFile string
- var debugEnable bool
+ var args config.Args
var displayVersion bool
- var noColor bool
- var sshPort int
+ var pprof string
userName := user.Name()
- 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.NoColor, "noColor", false, "Disable ANSII terminal colors")
flag.BoolVar(&args.Quiet, "quiet", false, "Quiet output mode")
- flag.IntVar(&args.ConnectionsPerCPU, "cpc", 10, "How many connections established per CPU core concurrently")
- flag.IntVar(&sshPort, "port", 2222, "SSH server port")
+ 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.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", "Log dir")
+ flag.StringVar(&args.Logger, "logger", config.DefaultClientLogger, "Logger name")
+ flag.StringVar(&args.LogLevel, "logLevel", config.DefaultLogLevel, "Log level")
flag.StringVar(&args.PrivateKeyPathFile, "key", "", "Path to private key")
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(&pprof, "pprof", "", "Start PProf server this address")
flag.Parse()
-
- config.Read(cfgFile, sshPort)
- color.Colored = !noColor
+ config.Setup(source.Client, &args, flag.Args())
if displayVersion {
version.PrintAndExit()
}
- 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, source.Client)
+
+ if pprof != "" {
+ go http.ListenAndServe(pprof, nil)
+ dlog.Client.Info("Started PProf", pprof)
+ }
client, err := clients.NewCatClient(args)
if err != nil {
@@ -60,6 +69,8 @@ func main() {
}
status := client.Start(ctx, signal.InterruptCh(ctx))
- logger.Flush()
+ cancel()
+
+ wg.Wait()
os.Exit(status)
}
diff --git a/cmd/dcat/testdata.txt b/cmd/dcat/testdata.txt
new file mode 100644
index 0000000..9e80424
--- /dev/null
+++ b/cmd/dcat/testdata.txt
@@ -0,0 +1,500 @@
+1 Sat 2 Oct 13:46:45 EEST 2021
+2 Sat 2 Oct 13:46:45 EEST 2021
+3 Sat 2 Oct 13:46:45 EEST 2021
+4 Sat 2 Oct 13:46:45 EEST 2021
+5 Sat 2 Oct 13:46:45 EEST 2021
+6 Sat 2 Oct 13:46:45 EEST 2021
+7 Sat 2 Oct 13:46:45 EEST 2021
+8 Sat 2 Oct 13:46:45 EEST 2021
+9 Sat 2 Oct 13:46:45 EEST 2021
+10 Sat 2 Oct 13:46:45 EEST 2021
+11 Sat 2 Oct 13:46:45 EEST 2021
+12 Sat 2 Oct 13:46:45 EEST 2021
+13 Sat 2 Oct 13:46:45 EEST 2021
+14 Sat 2 Oct 13:46:45 EEST 2021
+15 Sat 2 Oct 13:46:45 EEST 2021
+16 Sat 2 Oct 13:46:45 EEST 2021
+17 Sat 2 Oct 13:46:45 EEST 2021
+18 Sat 2 Oct 13:46:45 EEST 2021
+19 Sat 2 Oct 13:46:45 EEST 2021
+20 Sat 2 Oct 13:46:45 EEST 2021
+21 Sat 2 Oct 13:46:45 EEST 2021
+22 Sat 2 Oct 13:46:45 EEST 2021
+23 Sat 2 Oct 13:46:45 EEST 2021
+24 Sat 2 Oct 13:46:45 EEST 2021
+25 Sat 2 Oct 13:46:45 EEST 2021
+26 Sat 2 Oct 13:46:45 EEST 2021
+27 Sat 2 Oct 13:46:45 EEST 2021
+28 Sat 2 Oct 13:46:45 EEST 2021
+29 Sat 2 Oct 13:46:45 EEST 2021
+30 Sat 2 Oct 13:46:45 EEST 2021
+31 Sat 2 Oct 13:46:45 EEST 2021
+32 Sat 2 Oct 13:46:45 EEST 2021
+33 Sat 2 Oct 13:46:45 EEST 2021
+34 Sat 2 Oct 13:46:45 EEST 2021
+35 Sat 2 Oct 13:46:45 EEST 2021
+36 Sat 2 Oct 13:46:45 EEST 2021
+37 Sat 2 Oct 13:46:45 EEST 2021
+38 Sat 2 Oct 13:46:45 EEST 2021
+39 Sat 2 Oct 13:46:45 EEST 2021
+40 Sat 2 Oct 13:46:45 EEST 2021
+41 Sat 2 Oct 13:46:45 EEST 2021
+42 Sat 2 Oct 13:46:45 EEST 2021
+43 Sat 2 Oct 13:46:45 EEST 2021
+44 Sat 2 Oct 13:46:45 EEST 2021
+45 Sat 2 Oct 13:46:45 EEST 2021
+46 Sat 2 Oct 13:46:45 EEST 2021
+47 Sat 2 Oct 13:46:45 EEST 2021
+48 Sat 2 Oct 13:46:45 EEST 2021
+49 Sat 2 Oct 13:46:45 EEST 2021
+50 Sat 2 Oct 13:46:45 EEST 2021
+51 Sat 2 Oct 13:46:45 EEST 2021
+52 Sat 2 Oct 13:46:45 EEST 2021
+53 Sat 2 Oct 13:46:45 EEST 2021
+54 Sat 2 Oct 13:46:45 EEST 2021
+55 Sat 2 Oct 13:46:45 EEST 2021
+56 Sat 2 Oct 13:46:45 EEST 2021
+57 Sat 2 Oct 13:46:45 EEST 2021
+58 Sat 2 Oct 13:46:45 EEST 2021
+59 Sat 2 Oct 13:46:45 EEST 2021
+60 Sat 2 Oct 13:46:45 EEST 2021
+61 Sat 2 Oct 13:46:45 EEST 2021
+62 Sat 2 Oct 13:46:45 EEST 2021
+63 Sat 2 Oct 13:46:45 EEST 2021
+64 Sat 2 Oct 13:46:45 EEST 2021
+65 Sat 2 Oct 13:46:45 EEST 2021
+66 Sat 2 Oct 13:46:45 EEST 2021
+67 Sat 2 Oct 13:46:45 EEST 2021
+68 Sat 2 Oct 13:46:45 EEST 2021
+69 Sat 2 Oct 13:46:45 EEST 2021
+70 Sat 2 Oct 13:46:45 EEST 2021
+71 Sat 2 Oct 13:46:45 EEST 2021
+72 Sat 2 Oct 13:46:45 EEST 2021
+73 Sat 2 Oct 13:46:45 EEST 2021
+74 Sat 2 Oct 13:46:45 EEST 2021
+75 Sat 2 Oct 13:46:45 EEST 2021
+76 Sat 2 Oct 13:46:45 EEST 2021
+77 Sat 2 Oct 13:46:45 EEST 2021
+78 Sat 2 Oct 13:46:45 EEST 2021
+79 Sat 2 Oct 13:46:45 EEST 2021
+80 Sat 2 Oct 13:46:45 EEST 2021
+81 Sat 2 Oct 13:46:45 EEST 2021
+82 Sat 2 Oct 13:46:45 EEST 2021
+83 Sat 2 Oct 13:46:45 EEST 2021
+84 Sat 2 Oct 13:46:45 EEST 2021
+85 Sat 2 Oct 13:46:45 EEST 2021
+86 Sat 2 Oct 13:46:45 EEST 2021
+87 Sat 2 Oct 13:46:45 EEST 2021
+88 Sat 2 Oct 13:46:45 EEST 2021
+89 Sat 2 Oct 13:46:45 EEST 2021
+90 Sat 2 Oct 13:46:45 EEST 2021
+91 Sat 2 Oct 13:46:45 EEST 2021
+92 Sat 2 Oct 13:46:45 EEST 2021
+93 Sat 2 Oct 13:46:45 EEST 2021
+94 Sat 2 Oct 13:46:45 EEST 2021
+95 Sat 2 Oct 13:46:45 EEST 2021
+96 Sat 2 Oct 13:46:45 EEST 2021
+97 Sat 2 Oct 13:46:45 EEST 2021
+98 Sat 2 Oct 13:46:45 EEST 2021
+99 Sat 2 Oct 13:46:45 EEST 2021
+100 Sat 2 Oct 13:46:45 EEST 2021
+101 Sat 2 Oct 13:46:45 EEST 2021
+102 Sat 2 Oct 13:46:45 EEST 2021
+103 Sat 2 Oct 13:46:45 EEST 2021
+104 Sat 2 Oct 13:46:45 EEST 2021
+105 Sat 2 Oct 13:46:45 EEST 2021
+106 Sat 2 Oct 13:46:45 EEST 2021
+107 Sat 2 Oct 13:46:45 EEST 2021
+108 Sat 2 Oct 13:46:45 EEST 2021
+109 Sat 2 Oct 13:46:45 EEST 2021
+110 Sat 2 Oct 13:46:45 EEST 2021
+111 Sat 2 Oct 13:46:45 EEST 2021
+112 Sat 2 Oct 13:46:45 EEST 2021
+113 Sat 2 Oct 13:46:45 EEST 2021
+114 Sat 2 Oct 13:46:45 EEST 2021
+115 Sat 2 Oct 13:46:45 EEST 2021
+116 Sat 2 Oct 13:46:45 EEST 2021
+117 Sat 2 Oct 13:46:45 EEST 2021
+118 Sat 2 Oct 13:46:45 EEST 2021
+119 Sat 2 Oct 13:46:45 EEST 2021
+120 Sat 2 Oct 13:46:45 EEST 2021
+121 Sat 2 Oct 13:46:45 EEST 2021
+122 Sat 2 Oct 13:46:45 EEST 2021
+123 Sat 2 Oct 13:46:45 EEST 2021
+124 Sat 2 Oct 13:46:45 EEST 2021
+125 Sat 2 Oct 13:46:45 EEST 2021
+126 Sat 2 Oct 13:46:45 EEST 2021
+127 Sat 2 Oct 13:46:45 EEST 2021
+128 Sat 2 Oct 13:46:45 EEST 2021
+129 Sat 2 Oct 13:46:45 EEST 2021
+130 Sat 2 Oct 13:46:45 EEST 2021
+131 Sat 2 Oct 13:46:45 EEST 2021
+132 Sat 2 Oct 13:46:45 EEST 2021
+133 Sat 2 Oct 13:46:45 EEST 2021
+134 Sat 2 Oct 13:46:45 EEST 2021
+135 Sat 2 Oct 13:46:45 EEST 2021
+136 Sat 2 Oct 13:46:45 EEST 2021
+137 Sat 2 Oct 13:46:45 EEST 2021
+138 Sat 2 Oct 13:46:45 EEST 2021
+139 Sat 2 Oct 13:46:45 EEST 2021
+140 Sat 2 Oct 13:46:45 EEST 2021
+141 Sat 2 Oct 13:46:45 EEST 2021
+142 Sat 2 Oct 13:46:45 EEST 2021
+143 Sat 2 Oct 13:46:45 EEST 2021
+144 Sat 2 Oct 13:46:45 EEST 2021
+145 Sat 2 Oct 13:46:45 EEST 2021
+146 Sat 2 Oct 13:46:45 EEST 2021
+147 Sat 2 Oct 13:46:45 EEST 2021
+148 Sat 2 Oct 13:46:45 EEST 2021
+149 Sat 2 Oct 13:46:45 EEST 2021
+150 Sat 2 Oct 13:46:45 EEST 2021
+151 Sat 2 Oct 13:46:45 EEST 2021
+152 Sat 2 Oct 13:46:45 EEST 2021
+153 Sat 2 Oct 13:46:45 EEST 2021
+154 Sat 2 Oct 13:46:45 EEST 2021
+155 Sat 2 Oct 13:46:45 EEST 2021
+156 Sat 2 Oct 13:46:45 EEST 2021
+157 Sat 2 Oct 13:46:45 EEST 2021
+158 Sat 2 Oct 13:46:45 EEST 2021
+159 Sat 2 Oct 13:46:45 EEST 2021
+160 Sat 2 Oct 13:46:45 EEST 2021
+161 Sat 2 Oct 13:46:45 EEST 2021
+162 Sat 2 Oct 13:46:45 EEST 2021
+163 Sat 2 Oct 13:46:45 EEST 2021
+164 Sat 2 Oct 13:46:45 EEST 2021
+165 Sat 2 Oct 13:46:45 EEST 2021
+166 Sat 2 Oct 13:46:45 EEST 2021
+167 Sat 2 Oct 13:46:45 EEST 2021
+168 Sat 2 Oct 13:46:45 EEST 2021
+169 Sat 2 Oct 13:46:45 EEST 2021
+170 Sat 2 Oct 13:46:45 EEST 2021
+171 Sat 2 Oct 13:46:45 EEST 2021
+172 Sat 2 Oct 13:46:45 EEST 2021
+173 Sat 2 Oct 13:46:45 EEST 2021
+174 Sat 2 Oct 13:46:45 EEST 2021
+175 Sat 2 Oct 13:46:45 EEST 2021
+176 Sat 2 Oct 13:46:45 EEST 2021
+177 Sat 2 Oct 13:46:45 EEST 2021
+178 Sat 2 Oct 13:46:45 EEST 2021
+179 Sat 2 Oct 13:46:45 EEST 2021
+180 Sat 2 Oct 13:46:45 EEST 2021
+181 Sat 2 Oct 13:46:45 EEST 2021
+182 Sat 2 Oct 13:46:45 EEST 2021
+183 Sat 2 Oct 13:46:45 EEST 2021
+184 Sat 2 Oct 13:46:45 EEST 2021
+185 Sat 2 Oct 13:46:45 EEST 2021
+186 Sat 2 Oct 13:46:45 EEST 2021
+187 Sat 2 Oct 13:46:45 EEST 2021
+188 Sat 2 Oct 13:46:45 EEST 2021
+189 Sat 2 Oct 13:46:45 EEST 2021
+190 Sat 2 Oct 13:46:45 EEST 2021
+191 Sat 2 Oct 13:46:45 EEST 2021
+192 Sat 2 Oct 13:46:45 EEST 2021
+193 Sat 2 Oct 13:46:45 EEST 2021
+194 Sat 2 Oct 13:46:45 EEST 2021
+195 Sat 2 Oct 13:46:45 EEST 2021
+196 Sat 2 Oct 13:46:45 EEST 2021
+197 Sat 2 Oct 13:46:45 EEST 2021
+198 Sat 2 Oct 13:46:45 EEST 2021
+199 Sat 2 Oct 13:46:45 EEST 2021
+200 Sat 2 Oct 13:46:45 EEST 2021
+201 Sat 2 Oct 13:46:45 EEST 2021
+202 Sat 2 Oct 13:46:45 EEST 2021
+203 Sat 2 Oct 13:46:45 EEST 2021
+204 Sat 2 Oct 13:46:45 EEST 2021
+205 Sat 2 Oct 13:46:45 EEST 2021
+206 Sat 2 Oct 13:46:45 EEST 2021
+207 Sat 2 Oct 13:46:45 EEST 2021
+208 Sat 2 Oct 13:46:45 EEST 2021
+209 Sat 2 Oct 13:46:45 EEST 2021
+210 Sat 2 Oct 13:46:45 EEST 2021
+211 Sat 2 Oct 13:46:45 EEST 2021
+212 Sat 2 Oct 13:46:45 EEST 2021
+213 Sat 2 Oct 13:46:45 EEST 2021
+214 Sat 2 Oct 13:46:45 EEST 2021
+215 Sat 2 Oct 13:46:45 EEST 2021
+216 Sat 2 Oct 13:46:45 EEST 2021
+217 Sat 2 Oct 13:46:45 EEST 2021
+218 Sat 2 Oct 13:46:45 EEST 2021
+219 Sat 2 Oct 13:46:45 EEST 2021
+220 Sat 2 Oct 13:46:45 EEST 2021
+221 Sat 2 Oct 13:46:45 EEST 2021
+222 Sat 2 Oct 13:46:45 EEST 2021
+223 Sat 2 Oct 13:46:45 EEST 2021
+224 Sat 2 Oct 13:46:45 EEST 2021
+225 Sat 2 Oct 13:46:45 EEST 2021
+226 Sat 2 Oct 13:46:45 EEST 2021
+227 Sat 2 Oct 13:46:45 EEST 2021
+228 Sat 2 Oct 13:46:45 EEST 2021
+229 Sat 2 Oct 13:46:45 EEST 2021
+230 Sat 2 Oct 13:46:45 EEST 2021
+231 Sat 2 Oct 13:46:45 EEST 2021
+232 Sat 2 Oct 13:46:45 EEST 2021
+233 Sat 2 Oct 13:46:45 EEST 2021
+234 Sat 2 Oct 13:46:45 EEST 2021
+235 Sat 2 Oct 13:46:45 EEST 2021
+236 Sat 2 Oct 13:46:45 EEST 2021
+237 Sat 2 Oct 13:46:45 EEST 2021
+238 Sat 2 Oct 13:46:45 EEST 2021
+239 Sat 2 Oct 13:46:45 EEST 2021
+240 Sat 2 Oct 13:46:45 EEST 2021
+241 Sat 2 Oct 13:46:45 EEST 2021
+242 Sat 2 Oct 13:46:45 EEST 2021
+243 Sat 2 Oct 13:46:45 EEST 2021
+244 Sat 2 Oct 13:46:45 EEST 2021
+245 Sat 2 Oct 13:46:45 EEST 2021
+246 Sat 2 Oct 13:46:45 EEST 2021
+247 Sat 2 Oct 13:46:45 EEST 2021
+248 Sat 2 Oct 13:46:45 EEST 2021
+249 Sat 2 Oct 13:46:45 EEST 2021
+250 Sat 2 Oct 13:46:45 EEST 2021
+251 Sat 2 Oct 13:46:45 EEST 2021
+252 Sat 2 Oct 13:46:45 EEST 2021
+253 Sat 2 Oct 13:46:45 EEST 2021
+254 Sat 2 Oct 13:46:45 EEST 2021
+255 Sat 2 Oct 13:46:45 EEST 2021
+256 Sat 2 Oct 13:46:45 EEST 2021
+257 Sat 2 Oct 13:46:45 EEST 2021
+258 Sat 2 Oct 13:46:45 EEST 2021
+259 Sat 2 Oct 13:46:45 EEST 2021
+260 Sat 2 Oct 13:46:45 EEST 2021
+261 Sat 2 Oct 13:46:45 EEST 2021
+262 Sat 2 Oct 13:46:45 EEST 2021
+263 Sat 2 Oct 13:46:45 EEST 2021
+264 Sat 2 Oct 13:46:45 EEST 2021
+265 Sat 2 Oct 13:46:45 EEST 2021
+266 Sat 2 Oct 13:46:45 EEST 2021
+267 Sat 2 Oct 13:46:45 EEST 2021
+268 Sat 2 Oct 13:46:45 EEST 2021
+269 Sat 2 Oct 13:46:45 EEST 2021
+270 Sat 2 Oct 13:46:45 EEST 2021
+271 Sat 2 Oct 13:46:45 EEST 2021
+272 Sat 2 Oct 13:46:45 EEST 2021
+273 Sat 2 Oct 13:46:45 EEST 2021
+274 Sat 2 Oct 13:46:45 EEST 2021
+275 Sat 2 Oct 13:46:45 EEST 2021
+276 Sat 2 Oct 13:46:45 EEST 2021
+277 Sat 2 Oct 13:46:45 EEST 2021
+278 Sat 2 Oct 13:46:45 EEST 2021
+279 Sat 2 Oct 13:46:45 EEST 2021
+280 Sat 2 Oct 13:46:45 EEST 2021
+281 Sat 2 Oct 13:46:45 EEST 2021
+282 Sat 2 Oct 13:46:45 EEST 2021
+283 Sat 2 Oct 13:46:45 EEST 2021
+284 Sat 2 Oct 13:46:45 EEST 2021
+285 Sat 2 Oct 13:46:45 EEST 2021
+286 Sat 2 Oct 13:46:45 EEST 2021
+287 Sat 2 Oct 13:46:45 EEST 2021
+288 Sat 2 Oct 13:46:45 EEST 2021
+289 Sat 2 Oct 13:46:45 EEST 2021
+290 Sat 2 Oct 13:46:45 EEST 2021
+291 Sat 2 Oct 13:46:45 EEST 2021
+292 Sat 2 Oct 13:46:45 EEST 2021
+293 Sat 2 Oct 13:46:45 EEST 2021
+294 Sat 2 Oct 13:46:45 EEST 2021
+295 Sat 2 Oct 13:46:45 EEST 2021
+296 Sat 2 Oct 13:46:45 EEST 2021
+297 Sat 2 Oct 13:46:45 EEST 2021
+298 Sat 2 Oct 13:46:45 EEST 2021
+299 Sat 2 Oct 13:46:45 EEST 2021
+300 Sat 2 Oct 13:46:45 EEST 2021
+301 Sat 2 Oct 13:46:45 EEST 2021
+302 Sat 2 Oct 13:46:45 EEST 2021
+303 Sat 2 Oct 13:46:45 EEST 2021
+304 Sat 2 Oct 13:46:45 EEST 2021
+305 Sat 2 Oct 13:46:45 EEST 2021
+306 Sat 2 Oct 13:46:45 EEST 2021
+307 Sat 2 Oct 13:46:45 EEST 2021
+308 Sat 2 Oct 13:46:45 EEST 2021
+309 Sat 2 Oct 13:46:45 EEST 2021
+310 Sat 2 Oct 13:46:45 EEST 2021
+311 Sat 2 Oct 13:46:45 EEST 2021
+312 Sat 2 Oct 13:46:45 EEST 2021
+313 Sat 2 Oct 13:46:45 EEST 2021
+314 Sat 2 Oct 13:46:45 EEST 2021
+315 Sat 2 Oct 13:46:45 EEST 2021
+316 Sat 2 Oct 13:46:45 EEST 2021
+317 Sat 2 Oct 13:46:45 EEST 2021
+318 Sat 2 Oct 13:46:45 EEST 2021
+319 Sat 2 Oct 13:46:45 EEST 2021
+320 Sat 2 Oct 13:46:45 EEST 2021
+321 Sat 2 Oct 13:46:45 EEST 2021
+322 Sat 2 Oct 13:46:45 EEST 2021
+323 Sat 2 Oct 13:46:45 EEST 2021
+324 Sat 2 Oct 13:46:45 EEST 2021
+325 Sat 2 Oct 13:46:45 EEST 2021
+326 Sat 2 Oct 13:46:45 EEST 2021
+327 Sat 2 Oct 13:46:45 EEST 2021
+328 Sat 2 Oct 13:46:45 EEST 2021
+329 Sat 2 Oct 13:46:45 EEST 2021
+330 Sat 2 Oct 13:46:46 EEST 2021
+331 Sat 2 Oct 13:46:46 EEST 2021
+332 Sat 2 Oct 13:46:46 EEST 2021
+333 Sat 2 Oct 13:46:46 EEST 2021
+334 Sat 2 Oct 13:46:46 EEST 2021
+335 Sat 2 Oct 13:46:46 EEST 2021
+336 Sat 2 Oct 13:46:46 EEST 2021
+337 Sat 2 Oct 13:46:46 EEST 2021
+338 Sat 2 Oct 13:46:46 EEST 2021
+339 Sat 2 Oct 13:46:46 EEST 2021
+340 Sat 2 Oct 13:46:46 EEST 2021
+341 Sat 2 Oct 13:46:46 EEST 2021
+342 Sat 2 Oct 13:46:46 EEST 2021
+343 Sat 2 Oct 13:46:46 EEST 2021
+344 Sat 2 Oct 13:46:46 EEST 2021
+345 Sat 2 Oct 13:46:46 EEST 2021
+346 Sat 2 Oct 13:46:46 EEST 2021
+347 Sat 2 Oct 13:46:46 EEST 2021
+348 Sat 2 Oct 13:46:46 EEST 2021
+349 Sat 2 Oct 13:46:46 EEST 2021
+350 Sat 2 Oct 13:46:46 EEST 2021
+351 Sat 2 Oct 13:46:46 EEST 2021
+352 Sat 2 Oct 13:46:46 EEST 2021
+353 Sat 2 Oct 13:46:46 EEST 2021
+354 Sat 2 Oct 13:46:46 EEST 2021
+355 Sat 2 Oct 13:46:46 EEST 2021
+356 Sat 2 Oct 13:46:46 EEST 2021
+357 Sat 2 Oct 13:46:46 EEST 2021
+358 Sat 2 Oct 13:46:46 EEST 2021
+359 Sat 2 Oct 13:46:46 EEST 2021
+360 Sat 2 Oct 13:46:46 EEST 2021
+361 Sat 2 Oct 13:46:46 EEST 2021
+362 Sat 2 Oct 13:46:46 EEST 2021
+363 Sat 2 Oct 13:46:46 EEST 2021
+364 Sat 2 Oct 13:46:46 EEST 2021
+365 Sat 2 Oct 13:46:46 EEST 2021
+366 Sat 2 Oct 13:46:46 EEST 2021
+367 Sat 2 Oct 13:46:46 EEST 2021
+368 Sat 2 Oct 13:46:46 EEST 2021
+369 Sat 2 Oct 13:46:46 EEST 2021
+370 Sat 2 Oct 13:46:46 EEST 2021
+371 Sat 2 Oct 13:46:46 EEST 2021
+372 Sat 2 Oct 13:46:46 EEST 2021
+373 Sat 2 Oct 13:46:46 EEST 2021
+374 Sat 2 Oct 13:46:46 EEST 2021
+375 Sat 2 Oct 13:46:46 EEST 2021
+376 Sat 2 Oct 13:46:46 EEST 2021
+377 Sat 2 Oct 13:46:46 EEST 2021
+378 Sat 2 Oct 13:46:46 EEST 2021
+379 Sat 2 Oct 13:46:46 EEST 2021
+380 Sat 2 Oct 13:46:46 EEST 2021
+381 Sat 2 Oct 13:46:46 EEST 2021
+382 Sat 2 Oct 13:46:46 EEST 2021
+383 Sat 2 Oct 13:46:46 EEST 2021
+384 Sat 2 Oct 13:46:46 EEST 2021
+385 Sat 2 Oct 13:46:46 EEST 2021
+386 Sat 2 Oct 13:46:46 EEST 2021
+387 Sat 2 Oct 13:46:46 EEST 2021
+388 Sat 2 Oct 13:46:46 EEST 2021
+389 Sat 2 Oct 13:46:46 EEST 2021
+390 Sat 2 Oct 13:46:46 EEST 2021
+391 Sat 2 Oct 13:46:46 EEST 2021
+392 Sat 2 Oct 13:46:46 EEST 2021
+393 Sat 2 Oct 13:46:46 EEST 2021
+394 Sat 2 Oct 13:46:46 EEST 2021
+395 Sat 2 Oct 13:46:46 EEST 2021
+396 Sat 2 Oct 13:46:46 EEST 2021
+397 Sat 2 Oct 13:46:46 EEST 2021
+398 Sat 2 Oct 13:46:46 EEST 2021
+399 Sat 2 Oct 13:46:46 EEST 2021
+400 Sat 2 Oct 13:46:46 EEST 2021
+401 Sat 2 Oct 13:46:46 EEST 2021
+402 Sat 2 Oct 13:46:46 EEST 2021
+403 Sat 2 Oct 13:46:46 EEST 2021
+404 Sat 2 Oct 13:46:46 EEST 2021
+405 Sat 2 Oct 13:46:46 EEST 2021
+406 Sat 2 Oct 13:46:46 EEST 2021
+407 Sat 2 Oct 13:46:46 EEST 2021
+408 Sat 2 Oct 13:46:46 EEST 2021
+409 Sat 2 Oct 13:46:46 EEST 2021
+410 Sat 2 Oct 13:46:46 EEST 2021
+411 Sat 2 Oct 13:46:46 EEST 2021
+412 Sat 2 Oct 13:46:46 EEST 2021
+413 Sat 2 Oct 13:46:46 EEST 2021
+414 Sat 2 Oct 13:46:46 EEST 2021
+415 Sat 2 Oct 13:46:46 EEST 2021
+416 Sat 2 Oct 13:46:46 EEST 2021
+417 Sat 2 Oct 13:46:46 EEST 2021
+418 Sat 2 Oct 13:46:46 EEST 2021
+419 Sat 2 Oct 13:46:46 EEST 2021
+420 Sat 2 Oct 13:46:46 EEST 2021
+421 Sat 2 Oct 13:46:46 EEST 2021
+422 Sat 2 Oct 13:46:46 EEST 2021
+423 Sat 2 Oct 13:46:46 EEST 2021
+424 Sat 2 Oct 13:46:46 EEST 2021
+425 Sat 2 Oct 13:46:46 EEST 2021
+426 Sat 2 Oct 13:46:46 EEST 2021
+427 Sat 2 Oct 13:46:46 EEST 2021
+428 Sat 2 Oct 13:46:46 EEST 2021
+429 Sat 2 Oct 13:46:46 EEST 2021
+430 Sat 2 Oct 13:46:46 EEST 2021
+431 Sat 2 Oct 13:46:46 EEST 2021
+432 Sat 2 Oct 13:46:46 EEST 2021
+433 Sat 2 Oct 13:46:46 EEST 2021
+434 Sat 2 Oct 13:46:46 EEST 2021
+435 Sat 2 Oct 13:46:46 EEST 2021
+436 Sat 2 Oct 13:46:46 EEST 2021
+437 Sat 2 Oct 13:46:46 EEST 2021
+438 Sat 2 Oct 13:46:46 EEST 2021
+439 Sat 2 Oct 13:46:46 EEST 2021
+440 Sat 2 Oct 13:46:46 EEST 2021
+441 Sat 2 Oct 13:46:46 EEST 2021
+442 Sat 2 Oct 13:46:46 EEST 2021
+443 Sat 2 Oct 13:46:46 EEST 2021
+444 Sat 2 Oct 13:46:46 EEST 2021
+445 Sat 2 Oct 13:46:46 EEST 2021
+446 Sat 2 Oct 13:46:46 EEST 2021
+447 Sat 2 Oct 13:46:46 EEST 2021
+448 Sat 2 Oct 13:46:46 EEST 2021
+449 Sat 2 Oct 13:46:46 EEST 2021
+450 Sat 2 Oct 13:46:46 EEST 2021
+451 Sat 2 Oct 13:46:46 EEST 2021
+452 Sat 2 Oct 13:46:46 EEST 2021
+453 Sat 2 Oct 13:46:46 EEST 2021
+454 Sat 2 Oct 13:46:46 EEST 2021
+455 Sat 2 Oct 13:46:46 EEST 2021
+456 Sat 2 Oct 13:46:46 EEST 2021
+457 Sat 2 Oct 13:46:46 EEST 2021
+458 Sat 2 Oct 13:46:46 EEST 2021
+459 Sat 2 Oct 13:46:46 EEST 2021
+460 Sat 2 Oct 13:46:46 EEST 2021
+461 Sat 2 Oct 13:46:46 EEST 2021
+462 Sat 2 Oct 13:46:46 EEST 2021
+463 Sat 2 Oct 13:46:46 EEST 2021
+464 Sat 2 Oct 13:46:46 EEST 2021
+465 Sat 2 Oct 13:46:46 EEST 2021
+466 Sat 2 Oct 13:46:46 EEST 2021
+467 Sat 2 Oct 13:46:46 EEST 2021
+468 Sat 2 Oct 13:46:46 EEST 2021
+469 Sat 2 Oct 13:46:46 EEST 2021
+470 Sat 2 Oct 13:46:46 EEST 2021
+471 Sat 2 Oct 13:46:46 EEST 2021
+472 Sat 2 Oct 13:46:46 EEST 2021
+473 Sat 2 Oct 13:46:46 EEST 2021
+474 Sat 2 Oct 13:46:46 EEST 2021
+475 Sat 2 Oct 13:46:46 EEST 2021
+476 Sat 2 Oct 13:46:46 EEST 2021
+477 Sat 2 Oct 13:46:46 EEST 2021
+478 Sat 2 Oct 13:46:46 EEST 2021
+479 Sat 2 Oct 13:46:46 EEST 2021
+480 Sat 2 Oct 13:46:46 EEST 2021
+481 Sat 2 Oct 13:46:46 EEST 2021
+482 Sat 2 Oct 13:46:46 EEST 2021
+483 Sat 2 Oct 13:46:46 EEST 2021
+484 Sat 2 Oct 13:46:46 EEST 2021
+485 Sat 2 Oct 13:46:46 EEST 2021
+486 Sat 2 Oct 13:46:46 EEST 2021
+487 Sat 2 Oct 13:46:46 EEST 2021
+488 Sat 2 Oct 13:46:46 EEST 2021
+489 Sat 2 Oct 13:46:46 EEST 2021
+490 Sat 2 Oct 13:46:46 EEST 2021
+491 Sat 2 Oct 13:46:46 EEST 2021
+492 Sat 2 Oct 13:46:46 EEST 2021
+493 Sat 2 Oct 13:46:46 EEST 2021
+494 Sat 2 Oct 13:46:46 EEST 2021
+495 Sat 2 Oct 13:46:46 EEST 2021
+496 Sat 2 Oct 13:46:46 EEST 2021
+497 Sat 2 Oct 13:46:46 EEST 2021
+498 Sat 2 Oct 13:46:46 EEST 2021
+499 Sat 2 Oct 13:46:46 EEST 2021
+500 Sat 2 Oct 13:46:46 EEST 2021
diff --git a/cmd/dgrep/main.go b/cmd/dgrep/main.go
index 123d061..02b2463 100644
--- a/cmd/dgrep/main.go
+++ b/cmd/dgrep/main.go
@@ -4,68 +4,74 @@ import (
"context"
"flag"
"os"
+ "sync"
+
+ "net/http"
+ _ "net/http"
+ _ "net/http/pprof"
"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/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"
)
// 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 noColor bool
- var sshPort int
-
+ var pprof string
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.TrustAllHosts, "trustAllHosts", false, "Auto trust all unknown host keys")
- flag.BoolVar(&debugEnable, "debug", false, "Activate debug messages")
+ 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.BoolVar(&noColor, "noColor", false, "Disable ANSII terminal colors")
- flag.BoolVar(&args.Quiet, "quiet", false, "Quiet output mode")
- 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.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")
+ flag.StringVar(&args.LogDir, "logDir", "~/log", "Log dir")
+ flag.StringVar(&args.Logger, "logger", config.DefaultClientLogger, "Logger name")
+ 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")
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")
-
- // Line context awareness.
- flag.StringVar(&args.RegexStr, "regex", ".", "Regular expression")
flag.StringVar(&grep, "grep", "", "Alias for -regex")
- flag.IntVar(&args.LContext.BeforeContext, "before", 0, "Print lines of leading context before matching lines")
- flag.IntVar(&args.LContext.AfterContext, "after", 0, "Print lines of trailing context after matching lines")
- flag.IntVar(&args.LContext.MaxCount, "max", 0, "Stop reading file after NUM matching lines")
+ flag.StringVar(&pprof, "pprof", "", "Start PProf server this address")
flag.Parse()
+ config.Setup(source.Client, &args, flag.Args())
- if grep != "" {
- args.RegexStr = grep
+ if displayVersion {
+ version.PrintAndExit()
}
- config.Read(cfgFile, sshPort)
- color.Colored = !noColor
+ ctx, cancel := context.WithCancel(context.Background())
+ var wg sync.WaitGroup
+ wg.Add(1)
+ dlog.Start(ctx, &wg, source.Client)
- if displayVersion {
- version.PrintAndExit()
+ if grep != "" {
+ args.RegexStr = grep
}
- ctx := context.TODO()
- logger.Start(ctx, logger.Modes{
- Debug: debugEnable || config.Common.DebugEnable,
- Quiet: args.Quiet,
- })
+ if pprof != "" {
+ go http.ListenAndServe(pprof, nil)
+ dlog.Client.Info("Started PProf", pprof)
+ }
client, err := clients.NewGrepClient(args)
if err != nil {
@@ -73,6 +79,8 @@ func main() {
}
status := client.Start(ctx, signal.InterruptCh(ctx))
- logger.Flush()
+ cancel()
+
+ wg.Wait()
os.Exit(status)
}
diff --git a/cmd/dmap/main.go b/cmd/dmap/main.go
index 1a05549..2c941f3 100644
--- a/cmd/dmap/main.go
+++ b/cmd/dmap/main.go
@@ -4,69 +4,78 @@ import (
"context"
"flag"
"os"
+ "sync"
+
+ "net/http"
+ _ "net/http"
+ _ "net/http/pprof"
"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/dlog"
"github.com/mimecast/dtail/internal/io/signal"
"github.com/mimecast/dtail/internal/omode"
+ "github.com/mimecast/dtail/internal/source"
"github.com/mimecast/dtail/internal/user"
"github.com/mimecast/dtail/internal/version"
)
// The evil begins here.
func main() {
- var cfgFile string
- var debugEnable bool
var displayVersion bool
- var noColor bool
- var queryStr string
- var sshPort int
+ var pprof string
- args := clients.Args{
+ args := config.Args{
Mode: omode.MapClient,
}
-
userName := user.Name()
- 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.NoColor, "noColor", false, "Disable ANSII terminal colors")
flag.BoolVar(&args.Quiet, "quiet", false, "Quiet output mode")
- flag.IntVar(&args.ConnectionsPerCPU, "cpc", 10, "How many connections established per CPU core concurrently")
+ 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.SSHPort, "port", config.DefaultSSHPort, "SSH server port")
flag.IntVar(&args.Timeout, "timeout", 0, "Max time dtail server will collect data until disconnection")
- flag.IntVar(&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.LogDir, "logDir", "~/log", "Log dir")
+ flag.StringVar(&args.Logger, "logger", config.DefaultClientLogger, "Logger name")
+ flag.StringVar(&args.LogLevel, "logLevel", config.DefaultLogLevel, "Log level")
flag.StringVar(&args.PrivateKeyPathFile, "key", "", "Path to private key")
+ flag.StringVar(&args.QueryStr, "query", "", "Map reduce query")
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(&queryStr, "query", "", "Map reduce query")
+ flag.StringVar(&pprof, "pprof", "", "Start PProf server this address")
flag.Parse()
-
- config.Read(cfgFile, sshPort)
- color.Colored = !noColor
+ config.Setup(source.Client, &args, flag.Args())
if displayVersion {
version.PrintAndExit()
}
- 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, source.Client)
+
+ if pprof != "" {
+ go http.ListenAndServe(pprof, nil)
+ dlog.Client.Info("Started PProf", pprof)
+ }
- client, err := clients.NewMaprClient(args, queryStr, clients.DefaultMode)
+ client, err := clients.NewMaprClient(args, clients.DefaultMode)
if err != nil {
- panic(err)
+ dlog.Client.FatalPanic(err)
}
status := client.Start(ctx, signal.InterruptCh(ctx))
- logger.Flush()
+ cancel()
+
+ wg.Wait()
os.Exit(status)
}
diff --git a/cmd/dserver/main.go b/cmd/dserver/main.go
index 07f5270..24143eb 100644
--- a/cmd/dserver/main.go
+++ b/cmd/dserver/main.go
@@ -3,52 +3,54 @@ package main
import (
"context"
"flag"
- "fmt"
"net/http"
_ "net/http"
_ "net/http/pprof"
"os"
"os/signal"
+ "sync"
"syscall"
"time"
- "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/dlog"
"github.com/mimecast/dtail/internal/server"
+ "github.com/mimecast/dtail/internal/source"
"github.com/mimecast/dtail/internal/user"
"github.com/mimecast/dtail/internal/version"
)
// The evil begins here.
func main() {
- var cfgFile string
- var debugEnable bool
+ var args config.Args
+ var color bool
var displayVersion bool
- var noColor bool
- var pprof int
+ var pprof string
var shutdownAfter int
- var sshPort int
user.NoRootCheck()
- flag.BoolVar(&debugEnable, "debug", false, "Activate debug messages")
+ flag.BoolVar(&color, "color", false, "Enable ANSII terminal colors")
+ flag.BoolVar(&config.ServerRelaxedAuthEnable, "relaxedAuth", false,
+ "Enable relaxced SSH auth mode (don't use in production!)")
flag.BoolVar(&displayVersion, "version", false, "Display version")
- flag.BoolVar(&config.ServerRelaxedAuthEnable, "relaxedAuth", false, "Enable relaxced SSH auth mode (don't use in production!)")
- flag.BoolVar(&noColor, "noColor", false, "Disable ANSII terminal colors")
- flag.IntVar(&pprof, "pprof", -1, "Start PProf server this port")
- flag.IntVar(&shutdownAfter, "shutdownAfter", 0, "Automatically shutdown after so many seconds")
- flag.IntVar(&sshPort, "port", 2222, "SSH server port")
- flag.StringVar(&cfgFile, "cfg", "", "Config file path")
+ flag.IntVar(&args.SSHPort, "port", config.DefaultSSHPort, "SSH server port")
+ flag.IntVar(&shutdownAfter, "shutdownAfter", 0, "Shutdown after so many seconds")
+ flag.StringVar(&args.ConfigFile, "cfg", "", "Config file path")
+ flag.StringVar(&args.LogDir, "logDir", "", "Log dir")
+ flag.StringVar(&args.LogLevel, "logLevel", config.DefaultLogLevel, "Log level")
+ flag.StringVar(&args.Logger, "logger", config.DefaultServerLogger, "Logger name")
+ flag.StringVar(&args.SSHBindAddress, "bindAddress", "", "The SSH bind address")
+ flag.StringVar(&pprof, "pprof", "", "Start PProf server this address")
flag.Parse()
-
- config.Read(cfgFile, sshPort)
- color.Colored = !noColor
+ args.NoColor = !color
+ config.Setup(source.Server, &args, flag.Args())
if displayVersion {
version.PrintAndExit()
}
+ version.Print()
ctx, cancel := context.WithCancel(context.Background())
if shutdownAfter > 0 {
@@ -66,21 +68,23 @@ func main() {
}
}()
- logger.Start(ctx, logger.Modes{Server: true, Debug: debugEnable || config.Common.DebugEnable})
+ var wg sync.WaitGroup
+ wg.Add(1)
+ dlog.Start(ctx, &wg, source.Server)
if config.ServerRelaxedAuthEnable {
- logger.Fatal("SSH relaxed-auth mode enabled")
+ dlog.Server.Fatal("SSH relaxed-auth mode enabled")
}
- if pprof > -1 {
- // For debugging purposes only
- pprofArgs := fmt.Sprintf("0.0.0.0:%d", pprof)
- logger.Info("Starting PProf", pprofArgs)
- go http.ListenAndServe(pprofArgs, nil)
+ if pprof != "" {
+ dlog.Server.Info("Starting PProf", pprof)
+ go http.ListenAndServe(pprof, nil)
}
serv := server.New()
status := serv.Start(ctx)
- logger.Flush()
+ cancel()
+
+ wg.Wait()
os.Exit(status)
}
diff --git a/cmd/dtail/main.go b/cmd/dtail/main.go
index 2639b4b..ff0cea9 100644
--- a/cmd/dtail/main.go
+++ b/cmd/dtail/main.go
@@ -8,115 +8,122 @@ import (
_ "net/http"
_ "net/http/pprof"
"os"
+ "sync"
"time"
"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/dlog"
"github.com/mimecast/dtail/internal/io/signal"
"github.com/mimecast/dtail/internal/omode"
+ "github.com/mimecast/dtail/internal/source"
"github.com/mimecast/dtail/internal/user"
"github.com/mimecast/dtail/internal/version"
)
// The evil begins here.
func main() {
- var args clients.Args
- var cfgFile string
+ var args config.Args
var checkHealth bool
- var debugEnable bool
+ var displayColorTable bool
+ var displayWideColorTable bool
var displayVersion bool
var grep string
- var noColor bool
- var pprof int
- var queryStr string
+ var pprof string
var shutdownAfter int
- 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.TrustAllHosts, "trustAllHosts", false, "Auto trust all unknown host keys")
- flag.BoolVar(&checkHealth, "checkHealth", false, "Only check for server health")
- flag.BoolVar(&debugEnable, "debug", false, "Activate debug messages")
+ flag.BoolVar(&args.Spartan, "spartan", false, "Spartan output mode")
+ flag.BoolVar(&args.TrustAllHosts, "trustAllHosts", false, "Trust all unknown host keys")
+ flag.BoolVar(&checkHealth, "checkHealth", false, "Deprecated, flag will be removed soon")
+ flag.BoolVar(&displayColorTable, "colorTable", false, "Show color table")
+ flag.BoolVar(&displayWideColorTable, "wideColorTable", false, "Show a large color table")
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.IntVar(&args.ConnectionsPerCPU, "cpc", 10, "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.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.IntVar(&args.Timeout, "timeout", 0, "Max time dtail server will collect data until disconnection")
- flag.IntVar(&pprof, "pprof", -1, "Start PProf server this port")
- flag.IntVar(&shutdownAfter, "shutdownAfter", 3600*24, "Automatically shutdown after so many seconds")
- flag.IntVar(&sshPort, "port", 2222, "SSH server port")
+ flag.IntVar(&shutdownAfter, "shutdownAfter", 3600*24, "Shutdown after so many seconds")
+ 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", config.DefaultLogLevel, "Log level")
flag.StringVar(&args.PrivateKeyPathFile, "key", "", "Path to private key")
+ flag.StringVar(&args.QueryStr, "query", "", "Map reduce query")
+ 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(&queryStr, "query", "", "Map reduce query")
-
- // Line context awareness.
- flag.StringVar(&args.RegexStr, "regex", ".", "Regular expression")
flag.StringVar(&grep, "grep", "", "Alias for -regex")
- flag.IntVar(&args.LContext.BeforeContext, "before", 0, "Print lines of leading context before matching lines")
- flag.IntVar(&args.LContext.AfterContext, "after", 0, "Print lines of trailing context after matching lines")
- flag.IntVar(&args.LContext.MaxCount, "max", 0, "Stop reading file after NUM matching lines")
+ flag.StringVar(&pprof, "pprof", "", "Start PProf server this address")
flag.Parse()
-
if grep != "" {
args.RegexStr = grep
}
-
- config.Read(cfgFile, sshPort)
- color.Colored = !noColor
-
+ config.Setup(source.Client, &args, flag.Args())
if displayVersion {
version.PrintAndExit()
}
+ if !args.Spartan {
+ if displayWideColorTable {
+ color.TablePrintAndExit(true)
+ }
+ if displayColorTable {
+ color.TablePrintAndExit(false)
+ }
+ }
ctx, cancel := context.WithCancel(context.Background())
- defer cancel()
-
if shutdownAfter > 0 {
+ // TODO: This does not work (auto shutdown)
ctx, cancel = context.WithTimeout(ctx, time.Duration(shutdownAfter)*time.Second)
defer cancel()
}
+ var wg sync.WaitGroup
+ wg.Add(1)
+ dlog.Start(ctx, &wg, source.Client)
+
if checkHealth {
- healthClient, _ := clients.NewHealthClient(omode.HealthClient)
- os.Exit(healthClient.Start(ctx))
+ fmt.Println("WARN: DTail health check has moved to separate binary dtailhealth" +
+ " - please adjust the monitoring scripts!")
+ cancel()
+ os.Exit(1)
}
- logger.Start(ctx, logger.Modes{
- Debug: debugEnable || config.Common.DebugEnable,
- Quiet: args.Quiet,
- })
-
- if pprof > -1 {
- // For debugging purposes only
- pprofArgs := fmt.Sprintf("0.0.0.0:%d", pprof)
- logger.Info("Starting PProf", pprofArgs)
- go http.ListenAndServe(pprofArgs, nil)
+ if pprof != "" {
+ go http.ListenAndServe(pprof, nil)
+ dlog.Client.Info("Started PProf", pprof)
}
var client clients.Client
var err error
args.Mode = omode.TailClient
- switch queryStr {
+ switch args.QueryStr {
case "":
if client, err = clients.NewTailClient(args); err != nil {
panic(err)
}
default:
- if client, err = clients.NewMaprClient(args, queryStr, clients.DefaultMode); err != nil {
+ if client, err = clients.NewMaprClient(args, clients.DefaultMode); err != nil {
panic(err)
}
}
status := client.Start(ctx, signal.InterruptCh(ctx))
- logger.Flush()
+ cancel()
+
+ wg.Wait()
os.Exit(status)
}
diff --git a/cmd/dtailhealth/main.go b/cmd/dtailhealth/main.go
new file mode 100644
index 0000000..326c43a
--- /dev/null
+++ b/cmd/dtailhealth/main.go
@@ -0,0 +1,53 @@
+package main
+
+import (
+ "context"
+ "flag"
+ "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"
+ "github.com/mimecast/dtail/internal/io/signal"
+ "github.com/mimecast/dtail/internal/source"
+ "github.com/mimecast/dtail/internal/version"
+)
+
+// The evil begins here.
+func main() {
+ var args config.Args
+ var displayVersion bool
+ var pprof string
+
+ flag.BoolVar(&displayVersion, "version", false, "Display version")
+ flag.StringVar(&args.Logger, "logger", config.DefaultHealthCheckLogger, "Logger name")
+ flag.StringVar(&args.LogLevel, "logLevel", "none", "Log level")
+ flag.StringVar(&args.ServersStr, "server", "", "Remote server to connect")
+ flag.StringVar(&pprof, "pprof", "", "Start PProf server this address")
+ flag.Parse()
+
+ if displayVersion {
+ version.PrintAndExit()
+ }
+
+ config.Setup(source.HealthCheck, &args, flag.Args())
+
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
+ var wg sync.WaitGroup
+ wg.Add(1)
+ dlog.Start(ctx, &wg, source.HealthCheck)
+
+ if pprof != "" {
+ go http.ListenAndServe(pprof, nil)
+ dlog.Client.Info("Started PProf", pprof)
+ }
+
+ healthClient, _ := clients.NewHealthClient(args)
+ os.Exit(healthClient.Start(ctx, signal.NoCh(ctx)))
+}