Documentation ¶
Index ¶
- Constants
- Variables
- func AddResult(query, result string, history bool)
- func ExprResult(query string, expressions []string, result, prevResult storage.Result) storage.Result
- func FilterResult(result storage.Result, filters, labels []string) storage.Result
- func FilterSlice[T interface{}](in []T, indexes []int) (out []T)
- func GetNextSliceRing[T comparable](in []T, current T) T
- func GetPrevResults(query string, filters []string) (results []storage.Result)
- func GetResult(query string, filters []string) (result storage.Result)
- func GetResultWait(query string) (result storage.Result)
- func GraphDisplay(query string, filter string, expressions []string, ...)
- func Query(queryMode, attempts, delay int, queries []string, port string, history bool, ...) (chan bool, map[string]chan bool)
- func RawDisplay(query string, filters, expressions []string)
- func Read(port string) (done chan int)
- func RelativePerc(limitingPerc, globalRelativePerc int) int
- func Results(ctx context.Context, displayMode DisplayMode, query string, history bool, ...)
- func StreamDisplay(query string, filters, expressions []string, displayConfig *DisplayConfig)
- func TableDisplay(query string, filters, expressions []string, displayConfig *DisplayConfig)
- func TokenizeResult(result string) (parsedResult []interface{})
- type Config
- type DisplayConfig
- type DisplayDriver
- type DisplayMode
Constants ¶
const ( DEFAULT_HELP_SIZE = 10 DEFAULT_LOGS_SIZE = 15 DEFAULT_OUTER_PADDING_BOTTOM = 5 DEFAULT_OUTER_PADDING_LEFT = 10 DEFAULT_OUTER_PADDING_RIGHT = 10 DEFAULT_OUTER_PADDING_TOP = 5 DEFAULT_RESULTS_SIZE = 75 DEFAULT_TABLE_PADDING = 2 )
Defaults for display configs.
const ( QUERY_MODE_COMMAND int = iota + 1 // Queries are commands. QUERY_MODE_PROFILE // Queries are PIDs to profile. QUERY_MODE_STDIN // Results are fron stdin. )
const (
HELP_TEXT = "(ESC) Quit | (Space) Pause | (Tab) Next Display | (n) Next Query"
)
Misc. constants.
Variables ¶
var ( ProfileLabels = []string{ "State", "Age (s)", "Threads", "CPU Usage (%)", "Resident Memory (GB)", "Virtual Memory (GB)", "Swap (GB)", "IO Read (MB)", "IO Write (MB)", } // Labels supplied for profile results. )
Functions ¶
func AddResult ¶
Adds a result to the result store based on a string. It is assumed that all processing has ocurred on the result itself.
func ExprResult ¶
func ExprResult( query string, expressions []string, result, prevResult storage.Result, ) storage.Result
Returns a result after applying expressions. Requires a previous result for calculations requiring history. It is expected that a query can tolerate the potential emptyness of prevResult, namely on the first execution.
func FilterResult ¶
Creates a result with filtered values.
func FilterSlice ¶
func FilterSlice[T interface{}](in []T, indexes []int) (out []T)
Pick items from an arbitrary slice according to provided indexes. If indexes is empty, it will just return the original slice.
func GetNextSliceRing ¶
func GetNextSliceRing[T comparable](in []T, current T) T
Gets the next element in a slice, with wrap-around if selecting from the last element.
func GetPrevResults ¶
Get results previous to the last read result.
func GetResultWait ¶
Retrieves a next result, waiting for a non-empty return in a non-blocking manner.
func GraphDisplay ¶
func GraphDisplay(query string, filter string, expressions []string, displayConfig *DisplayConfig)
Creates a graph of results for the results pane.
func Query ¶
func Query( queryMode, attempts, delay int, queries []string, port string, history bool, resultsReadyChan chan bool, ) (chan bool, map[string]chan bool)
Entrypoint for 'query' mode.
func RelativePerc ¶
Gives a new percentage based on globalRelativePerc after reducing totality by limiting Perc.
For example, given a three-way percentage split of 80/10/10, this function will return 50 if given the arguments 80 and 10.
func Results ¶
func Results( ctx context.Context, displayMode DisplayMode, query string, history bool, displayConfig *DisplayConfig, inputConfig *Config, inputPauseQueryChans map[string]chan bool, resultsReadyChan chan bool, )
Entry-point function for results.
func StreamDisplay ¶
func StreamDisplay(query string, filters, expressions []string, displayConfig *DisplayConfig)
Update the results pane with new results as they are generated.
func TableDisplay ¶
func TableDisplay(query string, filters, expressions []string, displayConfig *DisplayConfig)
Creates a table of results for the results pane.
func TokenizeResult ¶
func TokenizeResult(result string) (parsedResult []interface{})
Parses a result into tokens for compound storage.
Types ¶
type Config ¶
type Config struct {
Count, Delay, DisplayMode, Mode int
ElasticsearchAddr, ElasticsearchIndex, ElasticsearchPassword, ElasticsearchUser string
Expressions, Filters, Labels, Queries []string
History, LogMulti, ReadStdin, Silent bool
LogLevel string
Port string
PrometheusExporterAddr string
PushgatewayAddr string
}
Shareable configuration. See CLI flags for further details.
func (*Config) SlogLogLevel ¶
Retrieves an Slog level from a human-readable level string.
type DisplayConfig ¶
type DisplayConfig struct {
HelpSize, LogsSize, ResultsSize int // Proportional size of widgets.
OuterPaddingBottom, OuterPaddingLeft, OuterPaddingRight, OuterPaddingTop int // Padding for the full display.
ShowHelp, ShowLogs, ShowStatus bool // Whether or not to show widgets.
TablePadding int // Padding for table cells in table displays.
}
General configuration for display modes.
type DisplayDriver ¶
type DisplayDriver int
Represents the display driver.
const ( DISPLAY_RAW DisplayDriver = iota + 1 // Used for direct output. DISPLAY_TVIEW // Used when tview is the TUI driver. DISPLAY_TERMDASH // Used when termdash is the TUI driver. )
Display driver constants. Each display mode uses a specific display driver.
type DisplayMode ¶
type DisplayMode int
Represents the display mode.
const ( DISPLAY_MODE_RAW DisplayMode = iota + 1 // For running in 'raw' display mode. DISPLAY_MODE_STREAM // For running in 'stream' display mode. DISPLAY_MODE_TABLE // For running in 'table' display mode. DISPLAY_MODE_GRAPH // For running in 'graph' display mode. )
Display mode constants.