當前位置: 首頁>>代碼示例>>Golang>>正文


Golang gosigar.CpuList類代碼示例

本文整理匯總了Golang中github.com/elastic/gosigar.CpuList的典型用法代碼示例。如果您正苦於以下問題:Golang CpuList類的具體用法?Golang CpuList怎麽用?Golang CpuList使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了CpuList類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: GetCpuTimesList

func GetCpuTimesList() ([]CpuTimes, error) {

	cpuList := sigar.CpuList{}
	err := cpuList.Get()
	if err != nil {
		return nil, err
	}

	cpuTimes := make([]CpuTimes, len(cpuList.List))

	for i, cpu := range cpuList.List {
		cpuTimes[i] = CpuTimes{
			User:    cpu.User,
			Nice:    cpu.Nice,
			System:  cpu.Sys,
			Idle:    cpu.Idle,
			IOWait:  cpu.Wait,
			Irq:     cpu.Irq,
			SoftIrq: cpu.SoftIrq,
			Steal:   cpu.Stolen,
		}
	}

	return cpuTimes, nil
}
開發者ID:Ingensi,項目名稱:dockerbeat,代碼行數:25,代碼來源:sigar.go

示例2: GetCpuTimesList

func GetCpuTimesList() ([]CpuTimes, error) {

	cpuList := sigar.CpuList{}
	err := cpuList.Get()
	if err != nil {
		return nil, err
	}

	cpuTimes := make([]CpuTimes, len(cpuList.List))

	for i, cpu := range cpuList.List {
		cpuTimes[i] = CpuTimes{Cpu: cpu}
	}

	return cpuTimes, nil
}
開發者ID:andrewkroh,項目名稱:beats,代碼行數:16,代碼來源:helper.go

示例3: GetSystemLoad

func GetSystemLoad() (*SystemLoad, error) {

	concreteSigar := sigar.ConcreteSigar{}
	avg, err := concreteSigar.GetLoadAverage()
	if err != nil {
		return nil, err
	}

	cpuList := sigar.CpuList{}
	cpuList.Get()
	numCore := len(cpuList.List)

	return &SystemLoad{
		Load1:  avg.One,
		Load5:  avg.Five,
		Load15: avg.Fifteen,

		LoadNorm1:  avg.One / float64(numCore),
		LoadNorm5:  avg.Five / float64(numCore),
		LoadNorm15: avg.Fifteen / float64(numCore),
	}, nil
}
開發者ID:YaSuenag,項目名稱:hsbeat,代碼行數:22,代碼來源:helper.go


注:本文中的github.com/elastic/gosigar.CpuList類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。