proc

package
v0.0.0-...-05f6ae7 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PATH_ROOT     = "/proc"
	PREFIX_SOCKET = "socket:["
)

Variables

This section is empty.

Functions

func AccessProc

func AccessProc() bool

func DoNetstat

func DoNetstat(path string, peers map[string]int, result map[string]*SockTabEntry) error

DoNetstat - collect information about network port status

func FindAllProcesses

func FindAllProcesses() (map[int]bool, error)

func GetComm

func GetComm(pid int) (string, error)

func GetCommandLine

func GetCommandLine(pid int) (string, error)

reads the command line arguments of a Linux process from the cmdline file in the /proc filesystem and converts them into a string

func GetContainerIDFromCGroup

func GetContainerIDFromCGroup(pid int) (string, error)

getContainerIDFromCGroup returns the id of the container from the cgroup file. If no container id found, an empty string will be returned.

func GetExeName

func GetExeName(pid int) (string, error)

The exe Symbolic Link: Inside each process's directory in /proc, there is a symbolic link named exe. This link points to the executable file that was used to start the process. For instance, if a process was started from /usr/bin/python, the exe symbolic link in that process's /proc directory will point to /usr/bin/python.

func GetHostName

func GetHostName(pid int) (string, error)

func GetNetNamespace

func GetNetNamespace(pid int) (string, error)

func ListVMMatchNetSocks

func ListVMMatchNetSocks(peers map[string]int) (map[string]*SockTabEntry, error)

func Path

func Path(pid int, subpath ...string) string

func SkipBlackCmdline

func SkipBlackCmdline(cmdLine string) bool

func SkipBlackComm

func SkipBlackComm(comm string) bool

Types

type ProcInfo

type ProcInfo struct {
	ProcessID    int
	ExeName      string
	CmdLine      string
	Comm         string
	HostName     string
	ContainerId  string
	NetNamespace string
	Ignore       bool
}

func ScanProc

func ScanProc(pid int) (p *ProcInfo)

func (*ProcInfo) GetMatchNetSockets

func (p *ProcInfo) GetMatchNetSockets(socks map[string]*SockTabEntry) []string

func (*ProcInfo) ListMatchNetSocks

func (p *ProcInfo) ListMatchNetSocks(peers map[string]int) (map[string]*SockTabEntry, error)

type Process

type Process struct {
	Pid  int
	Name string
}

Process holds the PID and process name to which each socket belongs

func (*Process) String

func (p *Process) String() string

type SockAddr

type SockAddr struct {
	IP   net.IP
	Port uint16
}

SockAddr represents an ip:port pair

func (*SockAddr) String

func (s *SockAddr) String() string

type SockTabEntry

type SockTabEntry struct {
	Ino        string
	LocalAddr  *SockAddr
	RemoteAddr *SockAddr
}

SockTabEntry type represents each line of the /proc/net/[tcp|udp]

Jump to

Keyboard shortcuts

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