utils

package
v0.0.0-...-8a44fb0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2022 License: MIT, MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxCheckTimes = 10
)

Variables

View Source
var ClockTicks = 100 // default value

Functions

func GetCpuTime

func GetCpuTime() (*cpu.TimesStat, error)

copy from github.com/shirou/gopsutil@v3.21.8+incompatible/process/process_linux.go

func GetDateTime

func GetDateTime() (localTime string, utcTime string, unixTime int64)

GetDateTime: 获取系统当前时间

func GetEnv

func GetEnv(key string, dfault string, combineWith ...string) string

GetEnv retrieves the environment variable key. If it does not exist it returns the default. github.com/shirou/gopsutil@v3.21.8+incompatible/internal/common/common.go

func HashRawConfig

func HashRawConfig(config *beat.Config) (error, string)

HashRawConfig: 获取配置hash值

func IsInDocker

func IsInDocker() bool

当且仅当 /.dockerenv 的前提下 文件存在且 cgroup 权限为 ro 或者 /proc/1/sched 进程号不为 1

func Md5

func Md5(str string) string

Md5 获取字符md5

Types

type CPULimit

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

func NewCPULimit

func NewCPULimit(l, checkTimes int) *CPULimit

NewCPULimit: new cpu limit object

func (*CPULimit) Allow

func (c *CPULimit) Allow() bool

Allow: judge current

func (*CPULimit) GetCheckInterval

func (c *CPULimit) GetCheckInterval() time.Duration

GetCheckInterval: get cpu check interval

func (*CPULimit) GetCpuTimes

func (c *CPULimit) GetCpuTimes(p *process.Process) (*cpu.TimesStat, error)

func (*CPULimit) Start

func (c *CPULimit) Start()

Start: start cpu limit

func (*CPULimit) Stop

func (c *CPULimit) Stop()

Stop: stop cpu limit

Jump to

Keyboard shortcuts

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