sysinfo

package
v0.0.0-...-b86a68b Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBootTime

func GetBootTime() (uint64, error)

func GetClockTick

func GetClockTick() uint64

func GetUptime

func GetUptime() (uint64, error)

Get uptime duration

Types

type Process

type Process interface {
	// Pid is the process ID for this process.
	Pid() uint

	// Command name running this process. This is not a path to the
	// executable.
	Command() string

	RunTime() uint64

	UserName() string
}

Process is the generic interface that is implemented on every platform and provides common operations for processes.

func FindProcess

func FindProcess(pid uint) (Process, error)

FindProcess looks up a single process by pid.

Process will be nil and error will be nil if a matching process is not found.

type UnixProcess

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

UnixProcess is an implementation of Process that contains Unix-specific fields and information.

func (*UnixProcess) Command

func (p *UnixProcess) Command() string

func (*UnixProcess) Pid

func (p *UnixProcess) Pid() uint

func (*UnixProcess) Refresh

func (p *UnixProcess) Refresh() error
// https://kb.novaordis.com/index.php/Linux_Process_Information
(1) pid           %d  The process ID
(2) comm          %s  The filename of the executable, in parentheses.
(3) state         %c
(4) ppid          %d  The PID of the parent of this process.
(5) pgrp          %d  The process group ID of the process.

(6) session       %d  The session ID of the process.
(7) tty_nr        %d  The controlling terminal of the process.
(8) tpgid         %d  The ID of the foreground process group
(9) flags         %u  The kernel flags word of the process.

(10) minflt       %lu The number of minor faults the process has made
(11) cminflt      %lu The number of minor faults that the process's waited-for children have made.
(12) majflt       %lu The number of major faults the process has made
(13) cmajflt      %lu The number of major faults that the process's
(14) utime        %lu Amount of time that this process has been scheduled in user mode
(15) stime        %lu Amount of time that this process has been scheduled in kernel mode

(16) cutime       %ld Amount of time that this process's waited-for chil
(17) cstime       %ld Amount of time that this process's waited-for chil
(18) priority     %ld
(19) nice         %ld The nice value (see setpriority(2))
(20) num_threads  %ld Number of threads in this process
(21) itrealvalue  %ld The time in jiffies before the next SIGALRM
(22) starttime    %llu The time the process started after system boot (clock ticks (divide by sysconf(_SC_CLK_TCK)).

...

Refresh reloads all the data associated with this process.

func (*UnixProcess) RunTime

func (p *UnixProcess) RunTime() uint64

func (*UnixProcess) UserName

func (p *UnixProcess) UserName() string

Jump to

Keyboard shortcuts

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