diff options
| author | Paul Buetow <paul@buetow.org> | 2026-02-03 17:09:18 +0200 |
|---|---|---|
| committer | Paul Buetow <pbuetow@mimecast.com> | 2026-02-03 17:09:34 +0200 |
| commit | d89b9e6760e2aadf9779faa6f23678f67c731e1e (patch) | |
| tree | 5e5136a70a0fd2f315c4751c31629fd97de4ece9 /internal/clients | |
| parent | 4cbd559c5d66a82358029dc4b00f5174c94c8ebc (diff) | |
Add SSH agent key selection and fix MapReduce outfile handling
This commit adds two major features and fixes:
1. SSH Agent Key Selection:
- Add --agentKeyIndex flag to select specific SSH agent key (0-based)
- Solves "too many authentication failures" with multiple SSH keys
- Default -1 uses all keys (backwards compatible)
- Available in dtail, dcat, dgrep, dmap commands
2. MapReduce Outfile Fixes:
- CSV files now written at every interval, not just on exit
- Proper signal handling (SIGTERM/SIGINT) with graceful shutdown
- 5-second grace period for cleanup before force exit
- Fixes issue where outfile remained as .tmp during execution
Usage:
dtail --servers host --agentKeyIndex 0 --query '...' outfile results.csv
This is particularly useful with YubiKey/hardware tokens where many
keys are loaded in the SSH agent, and for monitoring MapReduce results
in real-time as they're computed.
Co-authored-by: Cursor <cursoragent@cursor.com>
Diffstat (limited to 'internal/clients')
| -rw-r--r-- | internal/clients/baseclient.go | 2 | ||||
| -rw-r--r-- | internal/clients/maprclient.go | 8 |
2 files changed, 8 insertions, 2 deletions
diff --git a/internal/clients/baseclient.go b/internal/clients/baseclient.go index 013f2f2..e7a13f5 100644 --- a/internal/clients/baseclient.go +++ b/internal/clients/baseclient.go @@ -54,7 +54,7 @@ func (c *baseClient) init() { } c.sshAuthMethods, c.hostKeyCallback = client.InitSSHAuthMethods( c.Args.SSHAuthMethods, c.Args.SSHHostKeyCallback, c.Args.TrustAllHosts, - c.throttleCh, c.Args.SSHPrivateKeyFilePath) + c.throttleCh, c.Args.SSHPrivateKeyFilePath, c.Args.SSHAgentKeyIndex) } func (c *baseClient) makeConnections(maker maker) { diff --git a/internal/clients/maprclient.go b/internal/clients/maprclient.go index 226f76c..cfbffee 100644 --- a/internal/clients/maprclient.go +++ b/internal/clients/maprclient.go @@ -99,9 +99,12 @@ func (c *MaprClient) Start(ctx context.Context, statsCh <-chan string) (status i go c.periodicReportResults(ctx) status = c.baseClient.Start(ctx, statsCh) + + // Always write final result for cumulative mode (includes outfile case) if c.cumulative { - dlog.Client.Debug("Received final mapreduce result") + dlog.Client.Debug("Writing final mapreduce result") c.reportResults(true) + dlog.Client.Debug("Final result written") } return @@ -210,13 +213,16 @@ func (c *MaprClient) printResults() { } func (c *MaprClient) writeResultsToOutfile(finalResult bool) { + dlog.Client.Debug("writeResultsToOutfile called", "finalResult", finalResult, "cumulative", c.cumulative) if c.cumulative { if err := c.globalGroup.WriteResult(c.query, finalResult); err != nil { dlog.Client.FatalPanic(err) } + dlog.Client.Debug("WriteResult completed for cumulative mode") return } if err := c.globalGroup.SwapOut().WriteResult(c.query, true); err != nil { dlog.Client.FatalPanic(err) } + dlog.Client.Debug("WriteResult completed for non-cumulative mode") } |
