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/mapr | |
| 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/mapr')
| -rw-r--r-- | internal/mapr/groupsetresult.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/internal/mapr/groupsetresult.go b/internal/mapr/groupsetresult.go index 47bdab8..26e4b12 100644 --- a/internal/mapr/groupsetresult.go +++ b/internal/mapr/groupsetresult.go @@ -248,12 +248,17 @@ func (g *GroupSet) resultWriteUnformatted(query *Query, rows []result, fd *os.Fi } } - if !query.Outfile.AppendMode && finalResult { + // Always rename .tmp to .csv after writing (not just on final result) + // This ensures the .csv file is updated at every interval + if !query.Outfile.AppendMode { tmpOutfile := fmt.Sprintf("%s.tmp", query.Outfile.FilePath) + dlog.Common.Debug("Renaming outfile", tmpOutfile, "to", query.Outfile.FilePath) if err := os.Rename(tmpOutfile, query.Outfile.FilePath); err != nil { + dlog.Common.Error("Failed to rename outfile", tmpOutfile, "error", err) os.Remove(tmpOutfile) return err } + dlog.Common.Info("Successfully renamed outfile to", query.Outfile.FilePath) } return nil |
