Skip to content

Commit

Permalink
tetra: Add support to display throttle events
Browse files Browse the repository at this point in the history
Signed-off-by: Jiri Olsa <[email protected]>
  • Loading branch information
olsajiri committed Mar 4, 2024
1 parent 84184c3 commit 8840b2c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions pkg/encoder/encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,15 @@ func HumanStackTrace(response *tetragon.GetEventsResponse, colorer *Colorer) str
return out.String()
}

type Op tetragon.OpType

func (op Op) String() string {
return [...]string{
5: "EXECVE",
23: "CLONE",
}[op]
}

func (p *CompactEncoder) EventToString(response *tetragon.GetEventsResponse) (string, error) {
switch response.Event.(type) {
case *tetragon.GetEventsResponse_ProcessExec:
Expand All @@ -239,6 +248,16 @@ func (p *CompactEncoder) EventToString(response *tetragon.GetEventsResponse) (st
status = p.Colorer.Red.Sprint(exit.Status)
}
return CapTrailorPrinter(fmt.Sprintf("%s %s %s %s", event, processInfo, args, status), caps), nil
case *tetragon.GetEventsResponse_ProcessThrottle:
throttle := response.GetProcessThrottle()
if throttle.Process == nil {
return "", ErrMissingProcessInfo
}
event := p.Colorer.Red.Sprintf("🧬 %-7s", "throttle")
processInfo, caps := p.Colorer.ProcessInfo(response.NodeName, throttle.Process)
op := Op(throttle.Op).String()
return CapTrailorPrinter(fmt.Sprintf("%s %s %s", event, processInfo,
op), caps), nil
case *tetragon.GetEventsResponse_ProcessLoader:
loader := response.GetProcessLoader()
if loader.Process == nil {
Expand Down

0 comments on commit 8840b2c

Please sign in to comment.