libspector

package module
v0.0.0-...-91cd204 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2017 License: GPL-3.0 Imports: 10 Imported by: 2

README

libspector

Library for inspecting dynamically linked libraries of running processes.

Documentation

Overview

Package libspector provides query functions for finding installed libraries and libraries used by active processes.

This functionality is implemented by running various platform-native commands, concurrency safety is not implemented.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoPackage = errors.New("no package provided")

Functions

func ErrParse

func ErrParse(output string) error

func IsParseError

func IsParseError(err error) bool

Types

type Library

type Library interface {
	// Path returns the absolute path of the library on the filesystem.
	Path() string

	// Ctime returns the last ctime of the library on the filesystem.
	Ctime() (time.Time, error)

	// Outdated returns whether Process was started earlier than the Ctime time of this library.
	Outdated(Process) bool

	// Distribution package manager's dependency that owns this library.
	Package() (Package, error)
}

Library is a file representing a dynamically linked library or shared object.

func FindLibrary

func FindLibrary(path string) ([]Library, error)

FindLibrary uses `dpkg -S` to find libraries with the given path substring.

type Package

type Package interface {
	// Name of the package.
	Name() string

	// Version of the package installed.
	Version() string
}

Package that is managed by the distribution's package manager.

type ParseError

type ParseError struct {
	Line    string
	Command string
}

func (*ParseError) Error

func (err *ParseError) Error() string

type Process

type Process interface {
	// PID returns the process ID.
	PID() int

	// Started returns the time when the process was started, if it's still running.
	Started() (time.Time, error)

	// Find libraries used by this process
	Libraries() ([]Library, error)

	// Command line used to start the process
	CommandArgs() (string, error)

	CommandName() (string, error)
}

Process is a currently-running process.

func AllProcesses

func AllProcesses() ([]Process, error)

func FindProcess

func FindProcess(command string) ([]Process, error)

FindProcess uses `pgrep` to find all processes that match a command.

func ProcessByPID

func ProcessByPID(pid int) Process

type Query

type Query interface {
	// AllProcesses returns all the running processes on the system.
	AllProcesses() ([]Process, error)

	// FindProcess finds all running processes that match the command substring.
	FindProcess(command string) ([]Process, error)

	// FindLibrary finds all the installed libraries that match the path substring.
	FindLibrary(path string) ([]Library, error)
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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