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


Golang stats.StatsCollector類代碼示例

本文整理匯總了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
}
開發者ID:ian-plosker,項目名稱:bosh,代碼行數:14,代碼來源:heartbeat.go

示例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
}
開發者ID:ian-plosker,項目名稱:bosh,代碼行數:16,代碼來源:heartbeat.go

示例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
}
開發者ID:ian-plosker,項目名稱:bosh,代碼行數:16,代碼來源:heartbeat.go

示例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
}
開發者ID:ian-plosker,項目名稱:bosh,代碼行數:18,代碼來源:heartbeat.go


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