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


Golang gosigar.ConcreteSigar類代碼示例

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


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

示例1: GetLoad1

func GetLoad1() float64 {
	concreteSigar := sigar.ConcreteSigar{}

	avg, err := concreteSigar.GetLoadAverage()
	if err != nil {
		log.Debug("Failed to get load average")
		return -1
	}

	return avg.One
}
開發者ID:Graylog2,項目名稱:collector-sidecar,代碼行數:11,代碼來源:sigar.go

示例2: GetSystemLoad

func GetSystemLoad() (*SystemLoad, error) {

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

	return &SystemLoad{
		Load1:  avg.One,
		Load5:  avg.Five,
		Load15: avg.Fifteen,
	}, nil
}
開發者ID:radoondas,項目名稱:apachebeat,代碼行數:14,代碼來源:system.go

示例3: main

func main() {
	concreteSigar := gosigar.ConcreteSigar{}

	uptime := gosigar.Uptime{}
	uptime.Get()
	avg, err := concreteSigar.GetLoadAverage()
	if err != nil {
		fmt.Printf("Failed to get load average")
		return
	}

	fmt.Fprintf(os.Stdout, " %s up %s load average: %.2f, %.2f, %.2f\n",
		time.Now().Format("15:04:05"),
		uptime.Format(),
		avg.One, avg.Five, avg.Fifteen)
}
開發者ID:ChongFeng,項目名稱:beats,代碼行數:16,代碼來源:uptime.go

示例4: 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

示例5:

package sigar_test

import (
	"time"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"

	sigar "github.com/elastic/gosigar"
)

var _ = Describe("ConcreteSigar", func() {
	var concreteSigar *sigar.ConcreteSigar

	BeforeEach(func() {
		concreteSigar = &sigar.ConcreteSigar{}
	})

	Describe("CollectCpuStats", func() {
		It("immediately makes first CPU usage available even though it's not very accurate", func() {
			samplesCh, stop := concreteSigar.CollectCpuStats(500 * time.Millisecond)

			firstValue := <-samplesCh
			Expect(firstValue.User).To(BeNumerically(">", 0))

			stop <- struct{}{}
		})

		It("makes CPU usage delta values available", func() {
			samplesCh, stop := concreteSigar.CollectCpuStats(500 * time.Millisecond)
開發者ID:davidsoloman,項目名稱:beats,代碼行數:30,代碼來源:concrete_sigar_test.go


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