Skip to content

Commit

Permalink
tetra: Add support to display throttle events
Browse files Browse the repository at this point in the history
Adding support to display throttle events in getevents like:

💥 exit    ubuntu-22 /home/jolsa/tetragon/contrib/tester-progs/forkbomb 10000000 1
🚀 process ubuntu-22 /usr/bin/git commit --amend
🧬 throttle ubuntu-22 /usr/bin/git session-154.scope CLONE
🚀 process ubuntu-22 /usr/bin/vim /home/jolsa/tetragon/.git/COMMIT_EDITMSG
🧬 throttle ubuntu-22 /home/jolsa/tetragon/contrib/tester-progs/forkbomb session-141.scope CLONE

Signed-off-by: Jiri Olsa <[email protected]>
  • Loading branch information
olsajiri committed Mar 13, 2024
1 parent eacbf9a commit 362bca3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
20 changes: 20 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,17 @@ 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)
cgroup := throttle.Cgroup
op := Op(throttle.Op).String()
return CapTrailorPrinter(fmt.Sprintf("%s %s %s %s", event, processInfo, cgroup,
op), caps), nil
case *tetragon.GetEventsResponse_ProcessLoader:
loader := response.GetProcessLoader()
if loader.Process == nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/grpc/exec/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,7 @@ func GetProcessThrottle(msg *MsgProcessThrottleUnix) *tetragon.ProcessThrottle {
Process: tetragonProcess,
Parent: tetragonParent,
Op: tetragon.OpType(msg.Event),
Cgroup: msg.Cgroup,
}

if ec := eventcache.Get(); ec != nil &&
Expand Down

0 comments on commit 362bca3

Please sign in to comment.