summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO.md3
-rw-r--r--docker/Makefile4
-rw-r--r--internal/clients/args.go46
-rw-r--r--internal/clients/baseclient.go3
-rw-r--r--internal/clients/handlers/basehandler.go7
-rw-r--r--internal/config/client.go4
6 files changed, 54 insertions, 13 deletions
diff --git a/TODO.md b/TODO.md
index f019b4c..f21fa71 100644
--- a/TODO.md
+++ b/TODO.md
@@ -12,9 +12,8 @@ This is a loose list of what to do. Maybe for the next releae or maybe for a lat
[x] Adjust dmap with color schemas
[x] Auto limit stdout map output to 10 results.
[ ] Fix JSONSchema for the colors
-[ ] Implement Benchmark cat-ing a file and compare to prev version.
[?] Client 4.x should print a warning when trying to connect to a 3.x server.
[ ] Update docs for color configuration
[ ] Update animated gifs
-[ ] Canary/RC deployment
[x] Fix dmap so that it always reads to the end of file
+[ ] Add more default fields to the default MAPREDUCE format.
diff --git a/docker/Makefile b/docker/Makefile
index 5cdb931..75aed79 100644
--- a/docker/Makefile
+++ b/docker/Makefile
@@ -12,10 +12,12 @@ spindown:
./spindown.sh 10
dtail:
../dtail --servers serverlist.txt --files '/var/log/dserver/*' --trustAllHosts --debug
+dtail2:
+ ../dtail --servers serverlist.txt --files '/var/log/dserver/*' --trustAllHosts --debug --query 'from stats select max(goroutines),count($$hostname),$$hostname,last($$time) group by $$hostname order by max(goroutines)'
dgrep:
../dgrep --servers serverlist.txt --files '/var/log/dserver/*' --regex MAPREDUCE --trustAllHosts
dcat:
- ../dcat --servers serverlist.txt --files '/etc/passwd' --trustAllHosts --debug
+ ../dcat --servers serverlist.txt --files '/etc/passwd' --trustAllHosts
dmap:
../dmap --servers serverlist.txt --files '/var/log/dserver/*' --trustAllHosts --query 'from stats select avg(goroutines),max(goroutines),min(goroutines),last(goroutines),count($$hostname),$$hostname group by $$hostname order by avg(goroutines)'
dmap2:
diff --git a/internal/clients/args.go b/internal/clients/args.go
index 7f782f1..7ce1634 100644
--- a/internal/clients/args.go
+++ b/internal/clients/args.go
@@ -1,6 +1,13 @@
package clients
import (
+ "fmt"
+ "os"
+ "path/filepath"
+ "strings"
+
+ "github.com/mimecast/dtail/internal/config"
+ "github.com/mimecast/dtail/internal/io/logger"
"github.com/mimecast/dtail/internal/omode"
gossh "golang.org/x/crypto/ssh"
@@ -22,5 +29,42 @@ type Args struct {
SSHAuthMethods []gossh.AuthMethod
SSHHostKeyCallback gossh.HostKeyCallback
PrivateKeyPathFile string
- Quiet bool
+ Quiet bool
+}
+
+// When no servers are given, connect to localhost!
+func (a *Args) handleEmptyServer() {
+ if a.Discovery != "" || a.ServersStr != "" {
+ return
+ }
+
+ fqdn, err := os.Hostname()
+ if err != nil {
+ logger.FatalExit(err)
+ }
+ a.ServersStr = fmt.Sprintf("%s:%d", fqdn, config.Common.SSHPort)
+ // I am trusting my own hostname.
+ a.TrustAllHosts = true
+ logger.Debug("Will connect to local server", a.ServersStr)
+
+ cleanPath := func(dirtyPath string) string {
+ cleanPath, err := filepath.EvalSymlinks(dirtyPath)
+ if err != nil {
+ logger.FatalExit("Unable to evaluate symlinks", dirtyPath, err)
+ }
+ cleanPath, err = filepath.Abs(cleanPath)
+ if err != nil {
+ logger.FatalExit("Unable to make file path absolute", dirtyPath, cleanPath, err)
+ }
+ return cleanPath
+ }
+
+ logger.Debug("Dirty file paths", a.What)
+ var filePaths []string
+ for _, dirtyPath := range strings.Split(a.What, ",") {
+ filePaths = append(filePaths, cleanPath(dirtyPath))
+ }
+
+ a.What = strings.Join(filePaths, ",")
+ logger.Debug("Clean file paths", a.What)
}
diff --git a/internal/clients/baseclient.go b/internal/clients/baseclient.go
index de0c101..455174e 100644
--- a/internal/clients/baseclient.go
+++ b/internal/clients/baseclient.go
@@ -41,6 +41,9 @@ type baseClient struct {
func (c *baseClient) init() {
logger.Debug("Initiating base client")
+ // When empty server list provided, connect to localhost by default.
+ c.Args.handleEmptyServer()
+
flag := regex.Default
if c.Args.RegexInvert {
flag = regex.Invert
diff --git a/internal/clients/handlers/basehandler.go b/internal/clients/handlers/basehandler.go
index 51f33c1..74559e9 100644
--- a/internal/clients/handlers/basehandler.go
+++ b/internal/clients/handlers/basehandler.go
@@ -112,12 +112,5 @@ func (h *baseHandler) handleHiddenMessage(message string) {
switch {
case strings.HasPrefix(message, ".syn close connection"):
h.SendMessage(".ack close connection")
- select {
- case <-time.After(time.Second * 5):
- logger.Debug("Shutting down client after timeout and sending ack to server")
- h.Shutdown()
- case <-h.Done():
- return
- }
}
}
diff --git a/internal/config/client.go b/internal/config/client.go
index 795c4a4..152ab15 100644
--- a/internal/config/client.go
+++ b/internal/config/client.go
@@ -169,8 +169,8 @@ func newDefaultClientConfig() *ClientConfig {
SeverityErrorAttr: color.AttrBold,
SeverityErrorBg: color.BgRed,
SeverityErrorFg: color.FgWhite,
- SeverityFatalAttr: color.AttrBlink,
- SeverityFatalBg: color.BgRed,
+ SeverityFatalAttr: color.AttrBold,
+ SeverityFatalBg: color.BgMagenta,
SeverityFatalFg: color.FgWhite,
SeverityWarnAttr: color.AttrBold,
SeverityWarnBg: color.BgBlack,