本文整理匯總了Golang中bosh/platform/stats.StatsCollector類的典型用法代碼示例。如果您正苦於以下問題:Golang StatsCollector類的具體用法?Golang StatsCollector怎麽用?Golang StatsCollector使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了StatsCollector類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: getDiskStats
func getDiskStats(platform boshstats.StatsCollector, devicePath string) (stats boshmbus.DiskStats) {
diskStats, err := platform.GetDiskStats(devicePath)
if err != nil {
return
}
percent := float64(diskStats.Used) / float64(diskStats.Total) * 100
inodePercent := float64(diskStats.InodeUsed) / float64(diskStats.InodeTotal) * 100
stats.Percent = fmt.Sprintf("%.0f", percent)
stats.InodePercent = fmt.Sprintf("%.0f", inodePercent)
return
}
示例2: updateWithSwapStats
func updateWithSwapStats(platform boshstats.StatsCollector, hb boshmbus.Heartbeat) (updatedHb boshmbus.Heartbeat) {
updatedHb = hb
swapStats, err := platform.GetSwapStats()
if err != nil {
return
}
percent := float64(swapStats.Used) / float64(swapStats.Total) * 100
kb := swapStats.Used / 1024
updatedHb.Vitals.UsedSwap = boshmbus.MemStats{
Percent: fmt.Sprintf("%.0f", percent),
Kb: fmt.Sprintf("%d", kb),
}
return
}
示例3: updateWithCpuLoad
func updateWithCpuLoad(platform boshstats.StatsCollector, hb boshmbus.Heartbeat) (updatedHb boshmbus.Heartbeat) {
updatedHb = hb
load, err := platform.GetCpuLoad()
if err != nil {
return
}
one := fmt.Sprintf("%.2f", load.One)
five := fmt.Sprintf("%.2f", load.Five)
fifteen := fmt.Sprintf("%.2f", load.Fifteen)
updatedHb.Vitals.CpuLoad = []string{one, five, fifteen}
return
}
示例4: updateWithCpuStats
func updateWithCpuStats(platform boshstats.StatsCollector, hb boshmbus.Heartbeat) (updatedHb boshmbus.Heartbeat) {
updatedHb = hb
cpuStats, err := platform.GetCpuStats()
if err != nil {
return
}
user := float64(cpuStats.User) / float64(cpuStats.Total) * 100
sys := float64(cpuStats.Sys) / float64(cpuStats.Total) * 100
wait := float64(cpuStats.Wait) / float64(cpuStats.Total) * 100
updatedHb.Vitals.Cpu = boshmbus.CpuStats{
User: fmt.Sprintf("%.1f", user),
Sys: fmt.Sprintf("%.1f", sys),
Wait: fmt.Sprintf("%.1f", wait),
}
return
}