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. 利用spring AOP实现每个请求的日志输出

    前提条件: 除了spring相关jar包外,还需要引入aspectj包. <dependency> <groupId>org.aspectj</groupId> & ...

  2. 【Pycharm】 写python代码的优秀IDE Pycharm

    Pycharm 在用pycharm之前,我一直用的是本身也是由python写的ulipad做我的IDE,在linux上的话就直接用vim编辑器.但是碰到pycharm之后觉得这玩意儿太NB了,虽然说不 ...

  3. [css 揭秘]:CSS揭秘 技巧(二):多重边框

    我的github地址:https://github.com/FannieGirl/ifannie/ 源码都在这上面哦! 喜欢的给我一个星吧 多重边框 问题:我们通常希望在css代码层面以更灵活的方式来 ...

  4. [poj1094]Sorting It All Out_拓扑排序

    Sorting It All Out poj-1094 题目大意:给出一些字符串之间的大小关系,问能否得到一个唯一的字符串序列,满足权值随下标递增. 注释:最多26个字母,均为大写. 想法:显然,很容 ...

  5. Post Office

    Post Office poj-1160 题目大意:给你在数轴上的n个村庄,建立m个邮局,使得每一个村庄距离它最近的邮局的距离和最小,求距离最小和. 注释:n<=300,m<=min(n, ...

  6. 慢查询日志分析(mysql)

    开启慢查询日志之后,慢查询sql会被存到数据库系统表mysql.slow_log或是文件中,可参考.有两个工具可以帮助我们分析输出报告,分别是mysqldumpslow和pt-query-digest ...

  7. Leetcode 14——Longest Common Prefix

    题目:Write a function to find the longest common prefix string amongst an array of strings. 很简单的一个描述,最 ...

  8. Leetcode 27——Remove Element

    Given an array and a value, remove all instances of that value in-place and return the new length. D ...

  9. MySQL之集合函数与分组查询

    这是分组查询用到的语句,也包括了排序以及常用的集合函数

  10. C语言第三次作业总结

    本次作业的亮点 总体情况 大部分同学基本掌握了单层循环结构的写法,懂得了代码调试的过程 PTA通过率及作业质量都不错,希望再接再厉 推荐博客 黄毓颖 推荐理由:代码思路清晰,格式良好:调试过程相当形象 ...