本文整理汇总了Golang中github.com/cloudfoundry/gosigar.Cpu类的典型用法代码示例。如果您正苦于以下问题:Golang Cpu类的具体用法?Golang Cpu怎么用?Golang Cpu使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Cpu类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: GetCpuTimes
func GetCpuTimes() (*CpuTimes, error) {
cpu := sigar.Cpu{}
err := cpu.Get()
if err != nil {
return nil, err
}
return &CpuTimes{Cpu: cpu}, nil
}
开发者ID:tfksilent,项目名称:collector-sidecar,代码行数:10,代码来源:sigar.go
示例2: GetCpuStats
func (p ubuntu) GetCpuStats() (stats CpuStats, err error) {
cpu := sigar.Cpu{}
err = cpu.Get()
if err != nil {
return
}
stats.User = cpu.User
stats.Sys = cpu.Sys
stats.Wait = cpu.Wait
stats.Total = cpu.Total()
return
}
开发者ID:simonleung8,项目名称:bosh,代码行数:14,代码来源:ubuntu_sys_stats.go
示例3: GetCpuStats
func (s sigarStatsCollector) GetCpuStats() (stats CpuStats, err error) {
cpu := sigar.Cpu{}
err = cpu.Get()
if err != nil {
err = bosherr.WrapError(err, "Getting Sigar Cpu")
return
}
stats.User = cpu.User
stats.Sys = cpu.Sys
stats.Wait = cpu.Wait
stats.Total = cpu.Total()
return
}
开发者ID:ian-plosker,项目名称:bosh,代码行数:15,代码来源:sigar_stats_collector.go
示例4:
package sigar_test
import (
"io/ioutil"
"time"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
sigar "github.com/cloudfoundry/gosigar"
)
var _ = Describe("sigarLinux", func() {
Describe("CPU", func() {
var (
statFile string
cpu sigar.Cpu
)
BeforeEach(func() {
procd, err := ioutil.TempDir("", "sigarTests")
Expect(err).ToNot(HaveOccurred())
sigar.Procd = procd
statFile = procd + "/stat"
cpu = sigar.Cpu{}
statContents := []byte("cpu 25 1 2 3 4 5 6 7")
err = ioutil.WriteFile(statFile, statContents, 0644)
Expect(err).ToNot(HaveOccurred())
})
开发者ID:BarthV,项目名称:gosigar,代码行数:31,代码来源:sigar_linux_test.go
示例5:
var procd string
BeforeEach(func() {
var err error
procd, err = ioutil.TempDir("", "sigarTests")
Expect(err).ToNot(HaveOccurred())
sigar.Procd = procd
})
AfterEach(func() {
sigar.Procd = "/proc"
})
Describe("CPU", func() {
var (
statFile string
cpu sigar.Cpu
)
BeforeEach(func() {
statFile = procd + "/stat"
cpu = sigar.Cpu{}
})
Describe("Get", func() {
It("gets CPU usage", func() {
statContents := []byte("cpu 25 1 2 3 4 5 6 7")
err := ioutil.WriteFile(statFile, statContents, 0644)
Expect(err).ToNot(HaveOccurred())
err = cpu.Get()
Expect(err).ToNot(HaveOccurred())
开发者ID:msempere,项目名称:gosigar,代码行数:32,代码来源:sigar_linux_test.go
注:本文中的github.com/cloudfoundry/gosigar.Cpu类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论