format

package
v1.6.0-rc6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 16, 2019 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package format provides stdout formatting of monitor messages for reuse by command-line clients of the monitor event channel.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LostEvent

func LostEvent(lost uint64, cpu int)

LostEvent formats a lost event using the specified payload parameters.

Types

type MonitorFormatter

type MonitorFormatter struct {
	EventTypes monitorAPI.MessageTypeFilter
	FromSource Uint16Flags
	ToDst      Uint16Flags
	Related    Uint16Flags
	Verbose    bool
	Hex        bool
	JSONOutput bool
	Verbosity  Verbosity
}

MonitorFormatter filters and formats monitor messages from a buffer.

func NewMonitorFormatter

func NewMonitorFormatter(verbosity Verbosity) *MonitorFormatter

NewMonitorFormatter returns a new formatter with default configuration.

func (*MonitorFormatter) FormatEvent

func (m *MonitorFormatter) FormatEvent(pl *payload.Payload) bool

FormatEvent formats an event from the specified payload to stdout.

Returns true if the event was successfully printed, false otherwise.

func (*MonitorFormatter) FormatSample

func (m *MonitorFormatter) FormatSample(data []byte, cpu int)

FormatSample prints an event from the provided raw data slice to stdout.

For most monitor event types, 'data' corresponds to the 'data' field in bpf.PerfEventSample. Exceptions are MessageTypeAccessLog and MessageTypeAgent.

type Uint16Flags

type Uint16Flags []uint16

Uint16Flags is a slice of unsigned 16-bit ints with some convenience methods.

func (*Uint16Flags) Has added in v1.6.0

func (i *Uint16Flags) Has(value uint16) bool

Has returns true of value exist

func (*Uint16Flags) Set

func (i *Uint16Flags) Set(value string) error

Set converts the specified value into an integer and appends it to the flags. Returns an error if the value cannot be converted to a 16-bit unsigned value.

func (*Uint16Flags) String

func (i *Uint16Flags) String() string

String provides a human-readable string format of the received variable.

func (*Uint16Flags) Type

func (i *Uint16Flags) Type() string

Type returns a human-readable string representing the type of the receiver.

type Verbosity

type Verbosity uint8

Verbosity levels for formatting output.

const (

	// INFO is the level of verbosity in which summaries of Drop and Capture
	// messages are printed out when the monitor is invoked
	INFO Verbosity = iota + 1
	// DEBUG is the level of verbosity in which more information about packets
	// is printed than in INFO mode. Debug, Drop, and Capture messages are printed.
	DEBUG
	// VERBOSE is the level of verbosity in which the most information possible
	// about packets is printed out. Currently is not utilized.
	VERBOSE
	// JSON is the level of verbosity in which event information is printed out in json format
	JSON
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL