procfs

package module
v0.0.0-...-f645421 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2015 License: MIT Imports: 10 Imported by: 2

README

Procfs

Procfs is a parser for the /proc virtual filesystem on Linux written in the Go programming lanugage.

Not all /proc interfaces are currently supported; but pull requests are welcome!

Installation

go get github.com/jandre/procfs

Examples

See the *_test files for usage, but in short:

import (
  "github.com/jandre/procfs"
)

// fetch all processes from /proc
// returns a map of pid -> *Process 
processes, err := procfs.Processes();

Documentation

Documentation can be found at: http://godoc.org/github.com/jandre/procfs

Documentation

Index

Constants

View Source
const NO_VALUE = 4294967295

Variables

This section is empty.

Functions

func Processes

func Processes(lazy bool) (map[int]*Process, error)

Load all processes from /proc

If lazy = true, do not load ancillary information (/proc/<pid>/stat, /proc/<pid>/statm, etc) immediately - load it on demand

Types

type Meminfo

type Meminfo struct {
	MemTotal      int64
	MemFree       int64
	Buffers       int64
	Cached        int64
	SwapCached    int64
	Active        int64
	Inactive      int64
	HighTotal     int64
	HighFree      int64
	LowTotal      int64
	LowFree       int64
	SwapTotal     int64
	SwapFree      int64
	Dirty         int64
	Writeback     int64
	AnonPages     int64
	Mapped        int64
	Slab          int64
	SReclaimable  int64
	SUnreclaim    int64
	PageTables    int64
	NFS_Unstable  int64
	Bounce        int64
	WritebackTmp  int64
	CommitLimit   int64
	Committed_AS  int64
	VmallocTotal  int64
	VmallocUsed   int64
	VmallocChunk  int64
	AnonHugePages int64
}

Meminfo is a parser for /proc/meminfo.

func NewMeminfo

func NewMeminfo() (*Meminfo, error)

NewMeminfo() creates a new Meminfo object that loads from /proc/meminfo.

func ParseMeminfo

func ParseMeminfo(path string) (*Meminfo, error)

ParseMeminfo() loads a Meminfo object from a supplied path string.

If the path cannot be found, it will return an error.

type Process

type Process struct {
	Pid     int               // Process ID
	Environ map[string]string // Environment variables
	Cmdline []string          // Command line of process (argv array)
	Cwd     string            // Process current working directory
	Exe     string            // Symlink to executed command.
	Root    string            // Per-process root (e.g. chroot)
	// contains filtered or unexported fields
}

Process describes a /proc/<pid> entry

func NewProcess

func NewProcess(pid int, lazy bool) (*Process, error)

Read /proc information for `pid`

func NewProcessFromPath

func NewProcessFromPath(pid int, prefix string, lazy bool) (*Process, error)

Read a process entry from a directory path

if lazy = true, then preload the stat, limits, and other files.

func (*Process) Limits

func (p *Process) Limits() (*limits.Limits, error)

Parser for /proc/<pid>/limits

func (*Process) Loginuid

func (p *Process) Loginuid() int

Parses contents of /proc/pid/loginuid (if present)

func (*Process) Sessionid

func (p *Process) Sessionid() int

Parses contents of /proc/pid/sessionid (if present)

func (*Process) Stat

func (p *Process) Stat() (*stat.Stat, error)

Parser for /proc/<pid>/stat

func (*Process) Statm

func (p *Process) Statm() (*statm.Statm, error)

Parser for /proc/<pid>/statm

func (*Process) Status

func (p *Process) Status() (*status.Status, error)

Parser for /proc/<pid>/status

Directories

Path Synopsis
limits.Limits describes data in /proc/<pid>/limits.
limits.Limits describes data in /proc/<pid>/limits.
stat.Stat describes data in /proc/<pid>/stat.
stat.Stat describes data in /proc/<pid>/stat.
statm.Statm describes data in /proc/<pid>/statm.
statm.Statm describes data in /proc/<pid>/statm.
status.Status describes select data in /proc/<pid>/status.
status.Status describes select data in /proc/<pid>/status.

Jump to

Keyboard shortcuts

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