add record id

pull/137/head
Simon Let 6 years ago
parent 7905252762
commit 2e0737fab8
  1. 2
      cmd/collect/main.go
  2. 3
      cmd/postcollect/main.go
  3. 4
      pkg/records/records.go
  4. 3
      scripts/hooks.sh

@ -53,6 +53,7 @@ func main() {
shell := flag.String("shell", "", "actual shell") shell := flag.String("shell", "", "actual shell")
uname := flag.String("uname", "", "uname") uname := flag.String("uname", "", "uname")
sessionID := flag.String("sessionId", "", "resh generated session id") sessionID := flag.String("sessionId", "", "resh generated session id")
recordID := flag.String("recordId", "", "resh generated record id")
// recall metadata // recall metadata
recallActions := flag.String("recall-actions", "", "recall actions that took place before executing the command") recallActions := flag.String("recall-actions", "", "recall actions that took place before executing the command")
@ -195,6 +196,7 @@ func main() {
Shell: *shell, Shell: *shell,
Uname: *uname, Uname: *uname,
SessionID: *sessionID, SessionID: *sessionID,
RecordID: *recordID,
// posix // posix
Home: *home, Home: *home,

@ -44,6 +44,8 @@ func main() {
cmdLine := flag.String("cmdLine", "", "command line") cmdLine := flag.String("cmdLine", "", "command line")
exitCode := flag.Int("exitCode", -1, "exit code") exitCode := flag.Int("exitCode", -1, "exit code")
sessionID := flag.String("sessionId", "", "resh generated session id") sessionID := flag.String("sessionId", "", "resh generated session id")
recordID := flag.String("recordId", "", "resh generated record id")
shlvl := flag.Int("shlvl", -1, "$SHLVL") shlvl := flag.Int("shlvl", -1, "$SHLVL")
shell := flag.String("shell", "", "actual shell") shell := flag.String("shell", "", "actual shell")
@ -118,6 +120,7 @@ func main() {
CmdLine: *cmdLine, CmdLine: *cmdLine,
ExitCode: *exitCode, ExitCode: *exitCode,
SessionID: *sessionID, SessionID: *sessionID,
RecordID: *recordID,
Shlvl: *shlvl, Shlvl: *shlvl,
Shell: *shell, Shell: *shell,

@ -23,6 +23,7 @@ type BaseRecord struct {
Shell string `json:"shell"` Shell string `json:"shell"`
Uname string `json:"uname"` Uname string `json:"uname"`
SessionID string `json:"sessionId"` SessionID string `json:"sessionId"`
RecordID string `json:"recordId"`
// posix // posix
Home string `json:"home"` Home string `json:"home"`
@ -232,6 +233,9 @@ func (r *Record) Merge(r2 Record) error {
if r.CmdLine != r2.CmdLine { if r.CmdLine != r2.CmdLine {
return errors.New("Records to merge are not parts of the same records - r1:" + r.CmdLine + " r2:" + r2.CmdLine) return errors.New("Records to merge are not parts of the same records - r1:" + r.CmdLine + " r2:" + r2.CmdLine)
} }
if r.RecordID != r2.RecordID {
return errors.New("Records to merge do not have the same ID - r1:" + r.RecordID + " r2:" + r2.RecordID)
}
// r.RealtimeBefore != r2.RealtimeBefore - can't be used because of bash-preexec runs when it's not supposed to // r.RealtimeBefore != r2.RealtimeBefore - can't be used because of bash-preexec runs when it's not supposed to
r.ExitCode = r2.ExitCode r.ExitCode = r2.ExitCode
r.PwdAfter = r2.PwdAfter r.PwdAfter = r2.PwdAfter

@ -9,6 +9,7 @@ __resh_reset_variables() {
__RESH_HIST_RECALL_ACTIONS="" __RESH_HIST_RECALL_ACTIONS=""
__RESH_HIST_NO_PREFIX_MODE=0 __RESH_HIST_NO_PREFIX_MODE=0
__RESH_HIST_RECALL_STRATEGY="" __RESH_HIST_RECALL_STRATEGY=""
__RESH_RECORD_ID=$(__resh_get_uuid)
} }
__resh_preexec() { __resh_preexec() {
@ -81,6 +82,7 @@ __resh_collect() {
-shell "$__RESH_SHELL" \ -shell "$__RESH_SHELL" \
-uname "$__RESH_UNAME" \ -uname "$__RESH_UNAME" \
-sessionId "$__RESH_SESSION_ID" \ -sessionId "$__RESH_SESSION_ID" \
-recordId "$__RESH_RECORD_ID" \
-cols "$__RESH_COLS" \ -cols "$__RESH_COLS" \
-home "$__RESH_HOME" \ -home "$__RESH_HOME" \
-lang "$__RESH_LANG" \ -lang "$__RESH_LANG" \
@ -157,6 +159,7 @@ __resh_precmd() {
-realtimeBefore "$__RESH_RT_BEFORE" \ -realtimeBefore "$__RESH_RT_BEFORE" \
-exitCode "$__RESH_EXIT_CODE" \ -exitCode "$__RESH_EXIT_CODE" \
-sessionId "$__RESH_SESSION_ID" \ -sessionId "$__RESH_SESSION_ID" \
-recordId "$__RESH_RECORD_ID" \
-shell "$__RESH_SHELL" \ -shell "$__RESH_SHELL" \
-shlvl "$__RESH_SHLVL" \ -shlvl "$__RESH_SHLVL" \
-pwdAfter "$__RESH_PWD_AFTER" \ -pwdAfter "$__RESH_PWD_AFTER" \

Loading…
Cancel
Save