strace

package
v0.0.0-...-d97d3d1 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2022 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TraceExecCommand

func TraceExecCommand(straceLogPath string, origCmd ...string) (*exec.Cmd, error)

TraceExecCommand returns an exec.Cmd suitable for tracking timings of execve{,at}() calls

func TraceFilesCommand

func TraceFilesCommand(straceLogPattern string, origCmd ...string) (*exec.Cmd, error)

TraceFilesCommand returns an exec.Cmd suitable for tracking files opened/used during execution

Types

type CommonFileInfo

type CommonFileInfo struct {
	// Path is where the file was measured as
	Path string
	// Size may be -1 if we cannot get the size of the file with os.Stat()
	Size int64
	// Program is the program that accessed this file
	Program string
	// contains filtered or unexported fields
}

CommonFileInfo contains the path of a file and the size of it

type DisplayOptions

type DisplayOptions struct {
	NoDisplayPrograms bool
}

DisplayOptions is a silly struct for passing in display options like whether to display programs or just files for the file command TODO: make this go away and do it more cleanly

type ExeRuntime

type ExeRuntime struct {
	Start    time.Time
	Exe      string
	TotalSec time.Duration
	// contains filtered or unexported fields
}

ExeRuntime is the runtime of an individual executable

type ExecvePaths

type ExecvePaths struct {
	AllFiles  []CommonFileInfo
	Processes []ProcessRuntime
	TotalTime time.Duration
	// contains filtered or unexported fields
}

ExecvePaths represents the set of processes and files accessed by those processes for a given program execution

func TraceExecveWithFiles

func TraceExecveWithFiles(
	straceLogPattern string,
	fileRegex, programRegex *regexp.Regexp,
	excludeListProgramPatterns []string,
) (*ExecvePaths, error)

TraceExecveWithFiles will merge strace logs matching the given pattern and produce a file report with all the files matching the specified pattern read by every process in the execution TODO: we could speed this up if we injected the provided regex into the regular expressions we use to match all the strace lines, but that requires some really tough regular expression work and may have odd user behavior for "simple" cases like `.*`, which probably the user wants to use as `.*?`, otherwise they would get filepaths like `/some/file/thing/", "` because the filepath really has to stop at the last `"` character

func (*ExecvePaths) Display

func (e *ExecvePaths) Display(w io.Writer, opts *DisplayOptions)

Display shows the final exec timing output

type ExecveTiming

type ExecveTiming struct {
	TotalTime   time.Duration
	ExeRuntimes []ExeRuntime
	// contains filtered or unexported fields
}

ExecveTiming measures the execve calls timings under strace. This is useful for performance analysis. It keeps the N slowest samples.

func TraceExecveTimings

func TraceExecveTimings(straceLog string, nSlowest int) (*ExecveTiming, error)

TraceExecveTimings will read an strace log and produce a timing report of the n slowest exec's

func (*ExecveTiming) Display

func (stt *ExecveTiming) Display(w io.Writer, opts *DisplayOptions)

Display shows the final exec timing output

type PathAccess

type PathAccess struct {
	Time    time.Time
	Path    string
	Syscall string
	// contains filtered or unexported fields
}

PathAccess represents a single syscall accessing a file

type ProcessRuntime

type ProcessRuntime struct {
	Start        time.Time
	Exe          string
	RunDuration  time.Duration
	PathAccesses []PathAccess
	// contains filtered or unexported fields
}

ProcessRuntime represents a single program and the file accesses over the course of it's lifetime

Jump to

Keyboard shortcuts

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