tools

package
v0.0.0-...-9c67f8c Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: Apache-2.0 Imports: 21 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MinikubePid = -1

Functions

func DetectCgroupPath

func DetectCgroupPath() (string, error)

DetectCgroupPath returns the first-found mount point of type cgroup2

func FileExists

func FileExists(filePath string) bool

FileExists checks if a file exists

func FindChildProcesses

func FindChildProcesses(parentProcess *process.Process) ([]*process.Process, error)

FindChildProcesses finds child process(es) from a parent process. Return nil for empty

func FindChildProcessesUnderMinikubeWithDockerDriver

func FindChildProcessesUnderMinikubeWithDockerDriver(pid int) ([]*process.Process, error)

func GetAllProcessFromContainer

func GetAllProcessFromContainer(containerStatus v1.ContainerStatus, nodeContainerRuntime string) ([]*process.Process, error)

GetAllProcessFromContainer get all processes from one container

func GetContainerFileSystemRoot

func GetContainerFileSystemRoot(containerID string, runtime string) (string, error)

GetContainerFileSystemRoot get root path on the local machine file system

func GetContainerStatuses

func GetContainerStatuses(targetPod v1.Pod) ([]v1.ContainerStatus, error)

GetContainerStatuses gets all container statuses from pod object

func GetDefaultKubeConfig

func GetDefaultKubeConfig() string

GetDefaultKubeConfig gets default kubeconfig file path

func GetDockerContainerInfo

func GetDockerContainerInfo(containerID string) (types.ContainerJSON, error)

func GetNodeContainerRuntime

func GetNodeContainerRuntime(kubeconfig string, nodeName string) (string, string, error)

GetNodeContainerRuntime gets container runtime version

func GetNodeName

func GetNodeName() (string, error)

GetNodeName gets local machine's hostname, aka node name

func GetPidUnderRootPidNamespace

func GetPidUnderRootPidNamespace(ppid, pid int) (int, error)

func GetPodNameFromNodeAndLabel

func GetPodNameFromNodeAndLabel(kubeconfig string, namespace string, nodeName string, labelSelector string) (string, error)

GetPodNameFromNodeAndLabel finds target pod by node name and label

func GetSidecarBinaryPath

func GetSidecarBinaryPath(containerID string, runtime string) (string, error)

func HostToNetLong

func HostToNetLong(i uint32) uint32

HostToNetLong converts a 32-bit integer from host to network byte order, aka "htonl"

func HostToNetShort

func HostToNetShort(i uint16) uint16

HostToNetShort converts a 16-bit integer from host to network byte order, aka "htons"

func IpToUint32

func IpToUint32(ipAddr string) (uint32, error)

IpToUint32 converts IP in string (e.g. 127.0.0.1) to int (e.g. 0x100007f)

func IsInMinikubeMode

func IsInMinikubeMode() bool

IsInMinikubeMode returns ture if running on minikube

func LocateTargetPod

func LocateTargetPod(kubeconfig string, podName string, namespace string) (*v1.Pod, error)

LocateTargetPod finds target pod by name and namespace

func NetToHostLong

func NetToHostLong(i uint32) uint32

NetToHostLong converts a 32-bit integer from network to host byte order, aka "ntohl"

func NetToHostShort

func NetToHostShort(i uint16) uint16

NetToHostShort converts a 16-bit integer from network to host byte order, aka "ntohs"

Types

type Ipv4Address

type Ipv4Address uint32

func (Ipv4Address) ToString

func (ip Ipv4Address) ToString() string

type Ipv6Address

type Ipv6Address uint128

func (Ipv6Address) ToString

func (ip Ipv6Address) ToString() string

type Mac

type Mac struct {
	Data [6]uint8
}

func (Mac) ToString

func (m Mac) ToString() string

type UnifiedAddress

type UnifiedAddress struct {
	Hi uint64
	Lo uint64
}

func (UnifiedAddress) ToString

func (ip UnifiedAddress) ToString(version int) string

ToString converts binary UnifiedAddress by provided IP version

Jump to

Keyboard shortcuts

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