gops

package
v0.0.0-...-4316413 Latest Latest
Warning

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

Go to latest
Published: May 24, 2023 License: MIT Imports: 6 Imported by: 1

Documentation

Overview

Package gops extracts the information on running processes from gopsutil

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ByRSSDesc

type ByRSSDesc struct {
	ProcessNameGroups
}

ByRSSDesc is used to sort groups by decreasing RSS.

func (ByRSSDesc) Less

func (s ByRSSDesc) Less(i, j int) bool

Less returns whether the group at index i uses more RSS than the one at index j.

type ProcessInfo

type ProcessInfo struct {
	PID      int32
	PPID     int32
	Name     string
	RSS      uint64
	PctMem   float64
	VMS      uint64
	Username string
}

ProcessInfo contains information about a single process

func GetProcesses

func GetProcesses() ([]*ProcessInfo, error)

GetProcesses returns a slice of all the processes that are running

type ProcessNameGroup

type ProcessNameGroup struct {
	// contains filtered or unexported fields
}

ProcessNameGroup represents a group of processes, grouped by name

func NewProcessNameGroup

func NewProcessNameGroup() *ProcessNameGroup

NewProcessNameGroup returns a new empty ProcessNameGroup

func (*ProcessNameGroup) Name

func (pg *ProcessNameGroup) Name() string

Name returns the name of the group.

func (*ProcessNameGroup) PctMem

func (pg *ProcessNameGroup) PctMem() float64

PctMem returns the percentage of memory used by the group.

func (*ProcessNameGroup) Pids

func (pg *ProcessNameGroup) Pids() []int32

Pids returns the list of pids in the group.

func (*ProcessNameGroup) RSS

func (pg *ProcessNameGroup) RSS() uint64

RSS returns the RSS used by the group.

func (*ProcessNameGroup) Usernames

func (pg *ProcessNameGroup) Usernames() []string

Usernames returns a slice of the usernames, sorted alphabetically

func (*ProcessNameGroup) VMS

func (pg *ProcessNameGroup) VMS() uint64

VMS returns the vms of the group.

type ProcessNameGroups

type ProcessNameGroups []*ProcessNameGroup

ProcessNameGroups represents a list of ProcessNameGroup.

func GroupByName

func GroupByName(processInfos []*ProcessInfo) ProcessNameGroups

GroupByName groups the processInfos by name and return a slice of ProcessNameGroup

func TopRSSProcessGroups

func TopRSSProcessGroups(limit int) (ProcessNameGroups, error)

TopRSSProcessGroups returns an ordered slice of the process groups that use the most RSS

func (ProcessNameGroups) Len

func (s ProcessNameGroups) Len() int

Len returns the number of groups

func (ProcessNameGroups) Swap

func (s ProcessNameGroups) Swap(i, j int)

Swap swaps processes at index i and j

Jump to

Keyboard shortcuts

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