File: diff-top-output

package info (click to toggle)
zeekctl 2.2.0%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,544 kB
  • sloc: python: 5,639; sh: 1,374; makefile: 71; awk: 24
file content (21 lines) | stat: -rwxr-xr-x 686 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#! /usr/bin/env bash
#
# Replace columns from "zeekctl top" output that are not predictable
# (such as PID) with Xs.

awk '{
    if ( $1 !~ /Name/ )
    {
        # Check the format of each field, and replace with Xs only if the
        # format is expected (some fields have unpredictable length, but
        # we need a constant-width string of Xs).
        if ( $4 ~ /^[0-9]+$/ ) { $4 = "XXXXX" }       # Pid
        if ( $5 ~ /^[0-9]+[KMG]$/ ) { $5 = "XXX" }    # VSize
        if ( $6 ~ /^[0-9]+[KMG]$/ ) { $6 = "XXX" }    # Rss
        if ( $7 ~ /^[0-9]+%$/ ) { $7 = "XX%" }        # Cpu
        if ( $8 ~ /^(zeek|[Pp]ython.*)$/ ) { $8 = "XXX" } # Cmd
    }

    print
}' | sort