本文整理汇总了Golang中github.com/google/cadvisor/info/v1.PerDiskStats类的典型用法代码示例。如果您正苦于以下问题:Golang PerDiskStats类的具体用法?Golang PerDiskStats怎么用?Golang PerDiskStats使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PerDiskStats类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: DiskStatsCopy0
func DiskStatsCopy0(major, minor uint64) *info.PerDiskStats {
disk := info.PerDiskStats{
Major: major,
Minor: minor,
}
disk.Stats = make(map[string]uint64)
return &disk
}
示例2: DiskStatsCopy
func DiskStatsCopy(blkio_stats []cgroups.BlkioStatEntry) (stat []info.PerDiskStats) {
if len(blkio_stats) == 0 {
return
}
type DiskKey struct {
Major uint64
Minor uint64
}
disk_stat := make(map[DiskKey]*info.PerDiskStats)
for i := range blkio_stats {
major := blkio_stats[i].Major
minor := blkio_stats[i].Minor
disk_key := DiskKey{
Major: major,
Minor: minor,
}
diskp, ok := disk_stat[disk_key]
if !ok {
disk := info.PerDiskStats{
Major: major,
Minor: minor,
}
disk.Stats = make(map[string]uint64)
diskp = &disk
disk_stat[disk_key] = diskp
}
op := blkio_stats[i].Op
if op == "" {
op = "Count"
}
diskp.Stats[op] = blkio_stats[i].Value
}
i := 0
stat = make([]info.PerDiskStats, len(disk_stat))
for _, disk := range disk_stat {
stat[i] = *disk
i++
}
return
}