runtime

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

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

Go to latest
Published: Apr 12, 2024 License: MIT Imports: 12 Imported by: 1

Documentation

Overview

Package runtime 提供一些可以在运行环境中一定程度上唯一标识在一个集群中一台机器、一个进程的信息

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IPIsLAN

func IPIsLAN(ip net.IP) bool

IPIsLAN 判断一个 IP 是不是局域网地址

Types

type Addr

type Addr struct {
	IP   string `json:"ip"`
	Mask string `json:"mask"`
}

type AllStatic

type AllStatic struct {
	Host       Host       `json:"host"`
	Kubernetes Kubernetes `json:"kubernetes"`
	Docker     Docker     `json:"docker"`
	Networks   []NIC      `json:"networks"`
	Process    Process    `json:"process"`
}

AllStatic 表示可以获取的全部运行时静态信息

func GetAllStatic

func GetAllStatic() AllStatic

GetAllStatic 获取全部

type Docker

type Docker struct {
	// 是否可能在 Docker 容器中
	MayInDocker bool `json:"may_in_docker"`
	// 凭什么判断可能在 Docker 容器中
	WhyInDocker string `json:"why_in_docker,omitempty"`
}

Docker docker container 特殊信息

func GetDocker

func GetDocker() (d Docker)

GetDocker 读取 K8s 信息

type Host

type Host struct {
	OS       string `json:"os"`
	Arch     string `json:"arch"`
	Hostname string `json:"hostname"`
	Username string `json:"username"`
	HomeDir  string `json:"home_dir"`
}

Host 操作系统信息

func GetHost

func GetHost() (h Host)

GetHost 获取操作系统信息

type Kubernetes

type Kubernetes struct {
	ServiceHost string `json:"service_host,omitempty"` // KUBERNETES_SERVICE_HOST
	ServicePort int    `json:"service_port,omitempty"` // KUBERNETES_SERVICE_PORT

	MayInK8s bool   `json:"may_in_k8s"`           // 是否可能在 K8s pod 中
	WhyInK8s string `json:"why_in_k8s,omitempty"` // 凭什么判断可能在 K8s pod 中
}

Kubernetes K8s pod 特殊信息

func GetKubernetes

func GetKubernetes() (k Kubernetes)

GetKubernetes 读取 K8s 信息

type NIC

type NIC struct {
	Name string `json:"name,omitempty"`
	// 以太网 MAC 地址
	Ether string `json:"ether,omitempty"`
	// IP 地址
	Addrs []Addr `json:"addrs"`
	// 是否环回地址
	IsLoopback bool `json:"is_loopback,omitempty"`
	// 是否局域网地址 (环回地址不算)
	IsLAN bool `json:"is_lan,omitempty"`
}

NIC 网络适配卡信息

func GetNICs

func GetNICs() (nicList []NIC)

GetNICs 获取网络适配卡列表

type Process

type Process struct {
	Name    string    `json:"name"`
	PID     int       `json:"pid"`
	StartAt time.Time `json:"start_at"`
	BinSize uint64    `json:"bin_size"`
}

Process 当前进程信息

func GetProcess

func GetProcess() (p Process)

GetProcess 获取进程消息

Directories

Path Synopsis
Package caller provides packaging for system runtime.Caller
Package caller provides packaging for system runtime.Caller
Package env 提供一些环境变量相关的工具
Package env 提供一些环境变量相关的工具

Jump to

Keyboard shortcuts

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