Skip to content

Commit c380dd8

Browse files
committed
tetra: print tracingpolicy stats
Signed-off-by: Kornilios Kourtis <[email protected]>
1 parent 4fb1ae6 commit c380dd8

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

cmd/tetra/common/utils.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ func HumanizeByteCount(b int) string {
3232
func PrintTracingPolicies(output io.Writer, policies []*tetragon.TracingPolicyStatus, skipPolicy func(pol *tetragon.TracingPolicyStatus) bool) {
3333
// tabwriter config imitates kubectl default output, i.e. 3 spaces padding
3434
w := tabwriter.NewWriter(output, 0, 0, 3, ' ', 0)
35-
fmt.Fprintln(w, "ID\tNAME\tSTATE\tFILTERID\tNAMESPACE\tSENSORS\tKERNELMEMORY\tMODE")
35+
header := "ID\tNAME\tSTATE\tFILTERID\tNAMESPACE\tSENSORS\tKERNELMEMORY\tMODE\tNPOST\tNENFORCE\tNMONITOR"
36+
fmt.Fprintln(w, header)
3637

3738
for _, pol := range policies {
3839
if skipPolicy != nil && skipPolicy(pol) {
@@ -70,7 +71,8 @@ func PrintTracingPolicies(output io.Writer, policies []*tetragon.TracingPolicySt
7071
}
7172
}
7273

73-
fmt.Fprintf(w, "%d\t%s\t%s\t%d\t%s\t%s\t%s\t%s\t\n",
74+
counters := pol.GetStats().GetActionCounters()
75+
fmt.Fprintf(w, "%d\t%s\t%s\t%d\t%s\t%s\t%s\t%s\t%d\t%d\t%d\n",
7476
pol.Id,
7577
pol.Name,
7678
strings.TrimPrefix(strings.ToLower(pol.State.String()), "tp_state_"),
@@ -79,7 +81,9 @@ func PrintTracingPolicies(output io.Writer, policies []*tetragon.TracingPolicySt
7981
sensors,
8082
HumanizeByteCount(int(pol.KernelMemoryBytes)),
8183
strings.TrimPrefix(strings.ToLower(pol.Mode.String()), "tp_mode_"),
82-
)
84+
counters.GetPost(),
85+
counters.GetSignal()+counters.GetOverride()+counters.GetNotifyEnforcer(),
86+
counters.GetMonitorSignal()+counters.GetMonitorOverride()+counters.GetMonitorNotifyEnforcer())
8387
}
8488
w.Flush()
8589
}

0 commit comments

Comments
 (0)