• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang libcontainer.GetStats函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/google/cadvisor/container/libcontainer.GetStats函数的典型用法代码示例。如果您正苦于以下问题:Golang GetStats函数的具体用法?Golang GetStats怎么用?Golang GetStats使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了GetStats函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: GetStats

func (self *rawContainerHandler) GetStats() (*info.ContainerStats, error) {
	stats, err := libcontainer.GetStats(self.cgroupPaths, &self.libcontainerState)
	if err != nil {
		return stats, err
	}

	err = self.getFsStats(stats)
	if err != nil {
		return stats, err
	}

	// Fill in network stats for root.
	nd, err := self.GetRootNetworkDevices()
	if err != nil {
		return stats, err
	}
	if len(nd) != 0 {
		// ContainerStats only reports stat for one network device.
		// TODO(rjnagal): Handle multiple physical network devices.
		stats.Network, err = sysinfo.GetNetworkStats(nd[0].Name)
		if err != nil {
			return stats, err
		}
	}
	return stats, nil
}
开发者ID:vrosnet,项目名称:kubernetes,代码行数:26,代码来源:handler.go


示例2: GetStats

func (handler *rktContainerHandler) GetStats() (*info.ContainerStats, error) {
	stats, err := libcontainer.GetStats(handler.cgroupManager, handler.rootFs, handler.pid, handler.ignoreMetrics)
	if err != nil {
		return stats, err
	}

	// Get filesystem stats.
	err = handler.getFsStats(stats)
	if err != nil {
		return stats, err
	}

	return stats, nil
}
开发者ID:Clarifai,项目名称:kubernetes,代码行数:14,代码来源:handler.go


示例3: GetStats

func (self *rawContainerHandler) GetStats() (*info.ContainerStats, error) {
	stats, err := libcontainer.GetStats(self.cgroupManager, self.rootFs, os.Getpid())
	if err != nil {
		return stats, err
	}

	// Get filesystem stats.
	err = self.getFsStats(stats)
	if err != nil {
		return stats, err
	}

	return stats, nil
}
开发者ID:johnmccawley,项目名称:origin,代码行数:14,代码来源:handler.go


示例4: GetStats

// TODO(vmarmol): Get from libcontainer API instead of cgroup manager when we don't have to support older Dockers.
func (self *dockerContainerHandler) GetStats() (*info.ContainerStats, error) {
	config, err := self.readLibcontainerConfig()
	if err != nil {
		return nil, err
	}

	var networkInterfaces []string
	if len(config.Networks) > 0 {
		// ContainerStats only reports stat for one network device.
		// TODO(vmarmol): Handle multiple physical network devices.
		for _, n := range config.Networks {
			// Take the first non-loopback.
			if n.Type != "loopback" {
				networkInterfaces = []string{n.HostInterfaceName}
				break
			}
		}
	}
	stats, err := containerLibcontainer.GetStats(self.cgroupManager, networkInterfaces)
	if err != nil {
		return stats, err
	}

	// TODO(rjnagal): Remove the conversion when network stats are read from libcontainer.
	net := stats.Network
	// Ingress for host veth is from the container.
	// Hence tx_bytes stat on the host veth is actually number of bytes received by the container.
	stats.Network.RxBytes = net.TxBytes
	stats.Network.RxPackets = net.TxPackets
	stats.Network.RxErrors = net.TxErrors
	stats.Network.RxDropped = net.TxDropped
	stats.Network.TxBytes = net.RxBytes
	stats.Network.TxPackets = net.RxPackets
	stats.Network.TxErrors = net.RxErrors
	stats.Network.TxDropped = net.RxDropped

	// Get filesystem stats.
	err = self.getFsStats(stats)
	if err != nil {
		return stats, err
	}

	return stats, nil
}
开发者ID:SivagnanamCiena,项目名称:calico-kubernetes,代码行数:45,代码来源:handler.go


示例5: GetStats

func (self *rawContainerHandler) GetStats() (*info.ContainerStats, error) {
	nd, err := self.GetRootNetworkDevices()
	if err != nil {
		return new(info.ContainerStats), err
	}
	networkInterfaces := make([]string, len(nd))
	for i := range nd {
		networkInterfaces[i] = nd[i].Name
	}
	stats, err := libcontainer.GetStats(self.cgroupManager, networkInterfaces)
	if err != nil {
		return stats, err
	}

	// Get filesystem stats.
	err = self.getFsStats(stats)
	if err != nil {
		return stats, err
	}

	return stats, nil
}
开发者ID:jhadvig,项目名称:origin,代码行数:22,代码来源:handler.go


示例6: GetStats

func (self *dockerContainerHandler) GetStats() (stats *info.ContainerStats, err error) {
	if self.isDockerRoot() {
		return &info.ContainerStats{}, nil
	}
	config, err := self.readLibcontainerConfig()
	if err != nil {
		if err == fileNotFound {
			glog.Errorf("Libcontainer config not found for container %q", self.name)
			return &info.ContainerStats{}, nil
		}
		return
	}
	state, err := self.readLibcontainerState()
	if err != nil {
		if err == fileNotFound {
			glog.Errorf("Libcontainer state not found for container %q", self.name)
			return &info.ContainerStats{}, nil
		}
		return
	}

	return containerLibcontainer.GetStats(config, state)
}
开发者ID:jmyounker,项目名称:cadvisor,代码行数:23,代码来源:handler.go


示例7: GetStats

// TODO(vmarmol): Get from libcontainer API instead of cgroup manager when we don't have to support older Dockers.
func (self *dockerContainerHandler) GetStats() (*info.ContainerStats, error) {
	config, err := self.readLibcontainerConfig()
	if err != nil {
		return nil, err
	}

	var networkInterfaces []string
	if len(config.Networks) > 0 {
		// ContainerStats only reports stat for one network device.
		// TODO(vmarmol): Handle multiple physical network devices.
		for _, n := range config.Networks {
			// Take the first non-loopback.
			if n.Type != "loopback" {
				networkInterfaces = []string{n.HostInterfaceName}
				break
			}
		}
	}
	stats, err := containerLibcontainer.GetStats(self.cgroupManager, networkInterfaces)
	if err != nil {
		return stats, err
	}

	// TODO(rjnagal): Remove the conversion when network stats are read from libcontainer.
	convertInterfaceStats(&stats.Network.InterfaceStats)
	for i := range stats.Network.Interfaces {
		convertInterfaceStats(&stats.Network.Interfaces[i])
	}

	// Get filesystem stats.
	err = self.getFsStats(stats)
	if err != nil {
		return stats, err
	}

	return stats, nil
}
开发者ID:chenzhen411,项目名称:kubernetes,代码行数:38,代码来源:handler.go


示例8: GetStats

func (self *dockerContainerHandler) GetStats() (stats *info.ContainerStats, err error) {
	if self.isDockerRoot() {
		return &info.ContainerStats{}, nil
	}
	state, err := self.readLibcontainerState()
	if err != nil {
		if err == fileNotFound {
			glog.Errorf("Libcontainer state not found for container %q", self.name)
			return &info.ContainerStats{}, nil
		}
		return
	}

	stats, err = containerLibcontainer.GetStats(&self.cgroup, state)
	if err != nil {
		return
	}
	err = self.getFsStats(stats)
	if err != nil {
		return
	}

	return stats, nil
}
开发者ID:wulibin163,项目名称:cadvisor,代码行数:24,代码来源:handler.go



注:本文中的github.com/google/cadvisor/container/libcontainer.GetStats函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang raw.Register函数代码示例发布时间:2022-05-23
下一篇:
Golang libcontainer.GetProcesses函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap