Skip to content

Instantly share code, notes, and snippets.

@sfluor
Created December 20, 2018 17:15
Show Gist options
  • Save sfluor/a7e1dca57891f020ad4c35c8a603e2c2 to your computer and use it in GitHub Desktop.
Save sfluor/a7e1dca57891f020ad4c35c8a603e2c2 to your computer and use it in GitHub Desktop.

Units:

  • string-list: list of strings
  • string: one string
  • int: one int over 32bits
  • bool

Strings are not all equal in size but we will make the assumption they are, same for lists

Connection

Contains:

  • 23 ints
  • 8 strings
  • 2 lists of (1 int, 1 string-list)
type Connection struct {
	Pid int32
	Laddr *Addr
	Raddr *Addr
	BytesSent     float32
	BytesReceived float32
	Family        int32
	Type          int32
	PidCreateTime int64
	TotalBytesSent     uint64
	TotalBytesReceived uint64
}

Process

Contains:

  • 71 ints
  • 8 string
  • 2 string-list
  • list of (1 int, 1 string-list)
  • list of (1 int, 1 string)
type Process struct {
	Key     uint32
	Pid     int32
	Host    *Host
	Command *Command
	User    *ProcessUser
	Memory                 *MemoryStat (8 uint64)
	Cpu                    *CPUStat
	CreateTime             int64
	Container              *Container
	OpenFdCount            int32
	State                  int32
	IoStat                 *IOStat (4 float32)
	ContainerId            string
	ContainerKey           uint32
	VoluntaryCtxSwitches   uint64
	InvoluntaryCtxSwitches uint64
	ByteKey                []byte
	ContainerByteKey       []byte
}

Other types used

Container

Contains:

  • 7 string
  • 28 int
  • 1 string-list
  • list of (1 int, 1 string-list)
  • list of (2 int, 1 string)
type Container struct {
	Type        string
	Id          string
	Name        string
	Image       string
	CpuLimit    float32
	MemoryLimit uint64
	State      int32
	Health     int32
	Created    int64
	Rbps       float32
	Wbps       float32
	Key        uint32
	NetRcvdPs  float32
	NetSentPs  float32
	NetRcvdBps float32
	NetSentBps float32
	UserPct    float32
	SystemPct  float32
	TotalPct   float32
	MemRss     uint64
	MemCache   uint64
	Host       *Host
	Started    int64
	ByteKey    []byte
	Tags       []string
	Addresses  []*ContainerAddr
}

CPUStat

Contains:

  • 9 int
  • 1 string
  • list of (1 int, 1 string)
type CPUStat struct {
	LastCpu    string
	TotalPct   float32
	UserPct    float32
	SystemPct  float32
	NumThreads int32
	Cpus       []*SingleCPUStat
	Nice       int32
	UserTime   int64
	SystemTime int64
}

ProcessUser

Contains:

  • 6 ints
  • 1 string
type ProcessUser struct {
	Name string
	Uid  int32
	Gid  int32
	Euid int32
	Egid int32
	Suid int32
	Sgid int32
}

Command

Contains:

  • 1 string-list
  • 3 strings
  • 2 int
  • 1 bool
type Command struct {
	Args   []string
	Cwd    string
	Root   string
	OnDisk bool
	Ppid   int32
	Pgroup int32
	Exe    string
}

Addr

Contains:

  • 6 ints
  • 4 string
  • list of (1 int, 1 string-list)
type Addr struct {
	Host        *Host
	Ip          string
	Port        int32
	HostId      string
	ContainerId string
}

Host

Contains:

  • 5 ints
  • 1 string
  • 1 string-list
  • list of (1 int, 1 string-list)
type Host struct {
	Id          int32
	OrgId       int32
	Name        string
	Tags        []*HostTags
	AllTags     []string
	NumCpus     int32
	TotalMemory int64
}

Host Tags

Contains:

  • 1 int
  • 1 string-list
type HostTags struct {
	SourceType uint32
	Tags       []string
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment