Now cadvisor is useful as a container montor tool. Not only it can monitor many container level metrics, but also can expand some metrics which we need.

It`s a open source project URL: https://github.com/google/cadvisor.git

its master branch has a lot of defects. One of the problem is the daemon. url was wrote dead.In docker/container/clients.go, it was wrote to"unix://xxxxxxx",

In order to expand, it should be a dynamic parameter.

eg: func clients (clients string){

   ******

  }

run a docker container:

download the images:

go get githun.com/google/cadvisor /  git clone https://github.com/google/cadvisor.git /  download the zip package and unzip

docker command

sudo docker run \
  --volume=/:/rootfs:ro \
  --volume=/var/run:/var/run:rw \
  --volume=/sys:/sys:ro \
  --volume=/var/lib/docker/:/var/lib/docker:ro \
  --volume=/dev/disk/:/dev/disk:ro \
  --publish=: \
  --detach=true \
  --name=cadvisor \
  google/cadvisor:latest

the default port is 8080.

the cadvisor container is running on localhost:8080. The metrics infomation is on localhost:8080/metrics The graph show on localhost:8080/graph

Every metrics colector is achived in google/cadvisor/collector/.... We can overwrite the collector and describle interface to register new collector.But if we update this change in vendor, we can not promisor the tags version.(glide up -v or glide up install)

 // Returns a new CollectorManager that is thread-compatible.
 func NewCollectorManager() (CollectorManager, error) {
     return &GenericCollectorManager{
         Collectors:         []*collectorData{},
         NextCollectionTime: time.Now(),
     }, nil
 }

 func GetCollectorConfigs(labels map[string]string) map[string]string {
     configs := map[string]string{}
     for k, v := range labels {
         if strings.HasPrefix(k, metricLabelPrefix) {
             name := strings.TrimPrefix(k, metricLabelPrefix)
             configs[name] = v
         }
     }
     return configs
 }

 func (cm *GenericCollectorManager) RegisterCollector(collector Collector) error {
     cm.Collectors = append(cm.Collectors, &collectorData{
         collector:          collector,
         nextCollectionTime: time.Now(),
     })
     return nil
 }

 func (cm *GenericCollectorManager) GetSpec() ([]v1.MetricSpec, error) {
     metricSpec := []v1.MetricSpec{}
     for _, c := range cm.Collectors {
         specs := c.collector.GetSpec()
         metricSpec = append(metricSpec, specs...)
     }

     return metricSpec, nil
 }

 func (cm *GenericCollectorManager) Collect() (time.Time, map[string][]v1.MetricVal, error) {
     var errors []error

     // Collect from all collectors that are ready.
     var next time.Time
     metrics := map[string][]v1.MetricVal{}
     for _, c := range cm.Collectors {
         if c.nextCollectionTime.Before(time.Now()) {
             var err error3
             c.nextCollectionTime, metrics, err = c.collector.Collect(metrics)
             if err != nil {
                 errors = append(errors, err)
             }
         }

         // Keep track of the next collector that will be ready.
         if next.IsZero() || next.After(c.nextCollectionTime) {
             next = c.nextCollectionTime
         }
     }
     cm.NextCollectionTime = next
     return next, metrics, compileErrors(errors)
 }

We can build a new image in the localhost by achive the interface instead of use the default package by glide up -v.

for example:

we can set up a socket client with docker daemon. and get the inspect infomation.Docker inspect info has a container restart count.

we can expand this metrics by user follow step:

(1) register the collector

(2) new a collector client including some infomation (metric name , mode, help and so on)

(3) achive the collect and the descible interface.

CAdvisor container monitor的更多相关文章

  1. k8s debug记录之kubelet user.slice container monitor failure

    在kubernetes中,如果使用其自带的单机启动脚本./hack/local-up-cluster.sh来启动一个本地集群的话,会在kubelet的日志中观察到类似以下内容的日志: Failed t ...

  2. 7、Docker监控方案(cAdvisor+InfluxDB+Grafana)

    一.组件介绍 我们采用现在比较流行的cAdvisor+InfluxDB+Grafana组合进行Docker监控. 1.cAdvisor(数据采集) 开源软件cAdvisor(Container Adv ...

  3. Docker 数据收集利器:cadvisor

    gitHub地址:https://github.com/google/cadvisor cAdvisor cAdvisor (Container Advisor) provides container ...

  4. 利用谷歌开源工具cAdvisor 结合influxdb存储+Grafana前端展示进行Docker容器的监控

    一.Docker 监控方式 1.利用docker 的 docker stats API 命令: docker stats [容器ID/容器名称] [root@docker ~]# docker sta ...

  5. 从Container内存监控限制到CPU使用率限制方案

    转自:http://blog.csdn.net/Androidlushangderen/article/details/50282593 前言 最近在运维我们部门的hadoop集群时,发现了很多Job ...

  6. Docker源码分析(八):Docker Container网络(下)

    1.Docker Client配置容器网络模式 Docker目前支持4种网络模式,分别是bridge.host.container.none,Docker开发者可以根据自己的需求来确定最适合自己应用场 ...

  7. 50+ Useful Docker Tools

    As containers take root, dozens of tools have sprung up to support them. Check out your options for ...

  8. docker 源码分析 六(基于1.8.2版本),Docker run启动过程

    上一篇大致了解了docker 容器的创建过程,其实主要还是从文件系统的视角分析了创建一个容器时需要得建立 RootFS,建立volumes等步骤:本章来分析一下建立好一个容器后,将这个容器运行起来的过 ...

  9. hadoop之yarn详解(框架进阶篇)

    前面在hadoop之yarn详解(基础架构篇)这篇文章提到了yarn的重要组件有ResourceManager,NodeManager,ApplicationMaster等,以及yarn调度作业的运行 ...

随机推荐

  1. leaflet简单例子,绘制多边形

    var crs = L.CRS.EPSG900913; var map = L.map('map', { crs: crs, width: '100%', height: '100%', maxZoo ...

  2. 开源小工具 酷狗、网易音乐缓存文件转mp3工具

    发布一个开源小工具,支持将酷狗和网易云音乐的缓存文件转码为MP3文件. 以前写过kgtemp文件转mp3工具,正好当前又有网易云音乐缓存文件需求,因此就在原来小工具的基础上做了一点修改,增加了对网易云 ...

  3. swift 创建九宫格在后面加按钮

    项目中的需求是前面图片,在图片最后面始终有按钮如图 图片 let space:CGFloat = 10 for i in 0..model.count{ let itemWidth:CGFloat = ...

  4. C语言--函数嵌套

    一.实验作业 注意: 1.可以先初始化2个结构体数组数据以便测试. 2.要求用模块化方式组织程序结构,合理设计各自定义函数.同时,程序能够进行异常处理,检查用户输入数据的有效性,用户输入数据有错误,如 ...

  5. 201621123062《java程序设计》第12周作业总结

    1. 本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结多流与文件相关内容. 思维导图: 2. 面向系统综合设计-图书馆管理系统或购物车 使用流与文件改造你的图书馆管理系统或购物车. 2. ...

  6. Linux下进程间通信的六种机制详解

    linux下进程间通信的几种主要手段:        1.管道(Pipe)及有名管道(named pipe):管道可用于具有亲缘关系进程间的通信,有名管道克服了管道没有名字的限制,因此,除具有管道所具 ...

  7. Archlinux安装和使用技巧

    一 准备工作 1  文件下载及启动盘制作 文件可以在https://mirrors.ustc.edu.cn/,这是个中科大的镜像网,选择如下: 下载完成后,就是制作一个启动盘,我使用的是Linux下强 ...

  8. Flask 学习 六 大型程序结构

    pip freeze >requirement.txt 自动生成版本号 pip install -r requirement.txt 自动下载对应的库 梳理结构 config.py #!/usr ...

  9. webview缓存及跳转时截取url地址、监听页面变化

    缓存及一些设定 我在做一些项目时,h5做的项目手机浏览器能使用,但是在搬到webview时候不能用,这个时候通过查阅资料,原来是webview没有设定好,包括缓存.缓存大小及路径等等 mWebview ...

  10. HTML标签小记文本类标签

    文本类标签: <input type="text" name="" value="">文本框  type(方式,方法)name文 ...