Public Repository

Last pushed: 2 years ago
Short Description
Forked version of Google's cAdvisor with support to InfluxDB 0.9 until PR 1040 is released.
Full Description

This is part of the verification of the Pull Request https://github.com/google/cadvisor/pull/1040. Support to the latest version of InfluxDB 0.9.x was added and needed verification.

Running

Docker Compose

If you just want to verify this quickly, just do the following:

  1. Create a file called docker-compose.yml with the contents below
  2. run docker-compose up
  3. Go to your browser, select the database cadvisor and select the query SHOW MEASUREMENTS after 1 minute the server is running
influxdbData:
  image: busybox
  volumes:
    - ./data/influxdb:/data

influxdb:
  image: tutum/influxdb
  environment:
    - PRE_CREATE_DB=cadvisor
  ports:
    - "8083:8083"
    - "8086:8086"
  expose:
    - "8090"
    - "8099"
  volumes_from:
    - "influxdbData"

cadvisor:
  image: marcellodesales/google-cadvisor:influxdb-0.9
  command: -storage_driver=influxdb -storage_driver_db=cadvisor -storage_driver_host=influxsrv:8086
  ports:
    - "9090:8080"
  volumes:
    - /:/rootfs:ro
    - /var/run:/var/run:rw
    - /sys:/sys:ro
    - /var/lib/docker/:/var/lib/docker:ro
  links:
    - influxdb:influxsrv

Latest InfluxDB

$ sudo docker run -d -p 8083:8083 -p 8086:8086 --expose 8090 --expose 8099 --name influxsrv tutum/influxdb

Follow https://github.com/tutumcloud/influxdb#configuring-your-influxdb

  • Create the db "cadvisor"
  • Create the user "root:root"
  • Grant permissions to the user.

Run this image

MAKE SURE to provide the InfluxDB host IP!

$ sudo docker run --volume=/:/rootfs:ro --volume=/var/run:/var/run:rw 
     --volume=/sys:/sys:ro --volume=/var/lib/docker/:/var/lib/docker:ro --publish=8080:8080 
     --detach=true --name=cadvisor-0.9 marcellodesales/google-cadvisor:influxdb-0.9 
     -storage_driver=influxdb -storage_driver_db=cadvisor -storage_driver_host=172.16.188.135:8086

Build Instructions

Got the code

$ go get -d github.com/google/cadvisor
package golang.org/x/net/context/ctxhttp: /home/mdesales/go/src/golang.org/x/net exists but /home/mdesales/go/src/golang.org/x/net/.git does not - stale checkout?
y
$ go get github.com/tools/godep

Checked out the merge commit

 $ git checkout 040bdd3c
Note: checking out '040bdd3c'.

$ git log
commit 040bdd3cb1b038f2b6aca48c62fa4a1a8cb8da6c
Merge: 1b62cef 706a954
Author: Vish Kannan <vishh@users.noreply.github.com>
Date:   Fri Jan 8 10:27:33 2016 -0800

    Merge pull request #1040 from jimmidyson/influxdb-0.9

    Upgrade InfluxDB storage to InfluxDB 0.9

Built, verified

$ godep go build .

$ ls -la cadvisor
-rwxr-xr-x 1 mdesales mdesales 19507383 Jan 27 16:15 cadvisor

$ file cadvisor
cadvisor: ELF 64-bit LSB  executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=befe7321680d19977d844d01e08f67af328eabe8, not stripped

Ran Unit test cases

$ godep go test ./... -test.short
?       github.com/google/cadvisor    [no test files]
ok      github.com/google/cadvisor/api    0.018s
?       github.com/google/cadvisor/cache    [no test files]
ok      github.com/google/cadvisor/cache/memory    0.324s
ok      github.com/google/cadvisor/client    0.685s
?       github.com/google/cadvisor/client/clientexample    [no test files]
ok      github.com/google/cadvisor/client/v2    0.042s
ok      github.com/google/cadvisor/collector    0.043s
ok      github.com/google/cadvisor/container    0.010s
?       github.com/google/cadvisor/container/docker    [no test files]
ok      github.com/google/cadvisor/container/libcontainer    0.044s
ok      github.com/google/cadvisor/container/raw    0.030s
ok      github.com/google/cadvisor/events    0.011s
ok      github.com/google/cadvisor/fs    0.740s
?       github.com/google/cadvisor/healthz    [no test files]
?       github.com/google/cadvisor/http    [no test files]
?       github.com/google/cadvisor/http/mux    [no test files]
ok      github.com/google/cadvisor/info/v1    0.072s
?       github.com/google/cadvisor/info/v1/test    [no test files]
?       github.com/google/cadvisor/info/v2    [no test files]
?       github.com/google/cadvisor/integration/common    [no test files]
?       github.com/google/cadvisor/integration/framework    [no test files]
?       github.com/google/cadvisor/integration/runner    [no test files]
ok      github.com/google/cadvisor/integration/tests/api    0.023s
ok      github.com/google/cadvisor/integration/tests/healthz    0.003s
ok      github.com/google/cadvisor/manager    0.036s
ok      github.com/google/cadvisor/metrics    0.007s
?       github.com/google/cadvisor/pages    [no test files]
?       github.com/google/cadvisor/pages/static    [no test files]
?       github.com/google/cadvisor/storage    [no test files]
?       github.com/google/cadvisor/storage/bigquery    [no test files]
?       github.com/google/cadvisor/storage/bigquery/client    [no test files]
?       github.com/google/cadvisor/storage/bigquery/client/example    [no test files]
?       github.com/google/cadvisor/storage/elasticsearch    [no test files]
?       github.com/google/cadvisor/storage/influxdb    [no test files]
?       github.com/google/cadvisor/storage/redis    [no test files]
?       github.com/google/cadvisor/storage/statsd    [no test files]
?       github.com/google/cadvisor/storage/statsd/client    [no test files]
?       github.com/google/cadvisor/storage/stdout    [no test files]
?       github.com/google/cadvisor/storage/test    [no test files]
ok      github.com/google/cadvisor/summary    0.026s
ok      github.com/google/cadvisor/utils    0.003s
?       github.com/google/cadvisor/utils/cloudinfo    [no test files]
?       github.com/google/cadvisor/utils/cpuload    [no test files]
?       github.com/google/cadvisor/utils/cpuload/netlink    [no test files]
?       github.com/google/cadvisor/utils/cpuload/netlink/example    [no test files]
ok      github.com/google/cadvisor/utils/machine    0.005s
ok      github.com/google/cadvisor/utils/oomparser    0.005s
?       github.com/google/cadvisor/utils/oomparser/oomexample    [no test files]
?       github.com/google/cadvisor/utils/procfs    [no test files]
?       github.com/google/cadvisor/utils/sysfs    [no test files]
?       github.com/google/cadvisor/utils/sysfs/fakesysfs    [no test files]
ok      github.com/google/cadvisor/utils/sysinfo    0.002s
ok      github.com/google/cadvisor/validate    0.008s
?       github.com/google/cadvisor/version    [no test files]

Generated the new Docker Image to push here.

$ make docker
Sending build context to Docker daemon 46.42 MB
Step 1 : FROM alpine:3.2
 ---> ab7e84202862
Step 2 : MAINTAINER dengnan@google.com vmarmol@google.com vishnuk@google.com jimmidyson@gmail.com
 ---> Using cache
 ---> 88671c112252
Step 3 : RUN apk add --update ca-certificates device-mapper &&     wget https://circle-artifacts.com/gh/andyshinn/alpine-pkg-glibc/8/artifacts/0/home/ubuntu/alpine-pkg-glibc/packages/x86_64/glibc-2.21-r2.apk &&     wget https://circle-artifacts.com/gh/andyshinn/alpine-pkg-glibc/8/artifacts/0/home/ubuntu/alpine-pkg-glibc/packages/x86_64/glibc-bin-2.21-r2.apk &&     apk add --allow-untrusted glibc-2.21-r2.apk glibc-bin-2.21-r2.apk &&     /usr/glibc/usr/bin/ldconfig /lib /usr/glibc/usr/lib &&     echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf &&     rm -rf /var/cache/apk/*
 ---> Running in da7cd7d9b138
fetch http://dl-4.alpinelinux.org/alpine/v3.2/main/x86_64/APKINDEX.tar.gz
(1/9) Installing run-parts (4.4-r0)
(2/9) Installing openssl (1.0.2e-r0)
(3/9) Installing lua5.2-libs (5.2.4-r0)
(4/9) Installing lua5.2 (5.2.4-r0)
(5/9) Installing ncurses-terminfo-base (5.9-r3)
(6/9) Installing ncurses-widec-libs (5.9-r3)
(7/9) Installing lua5.2-posix (33.3.1-r2)
(8/9) Installing ca-certificates (20141019-r2)
(9/9) Installing device-mapper (2.02.122-r3)
Executing busybox-1.23.2-r0.trigger
Executing ca-certificates-20141019-r2.trigger
OK: 8 MiB in 24 packages
Connecting to circle-artifacts.com (52.72.7.255:443)
glibc-2.21-r2.apk    100% |*******************************|  1813k  0:00:00 ETA
Connecting to circle-artifacts.com (52.71.104.154:443)
glibc-bin-2.21-r2.ap 100% |*******************************|  1018k  0:00:00 ETA
(1/3) Installing libgcc (4.9.2-r5)
(2/3) Installing glibc (2.21-r2)
(3/3) Installing glibc-bin (2.21-r2)
Executing glibc-bin-2.21-r2.trigger
OK: 15 MiB in 27 packages
 ---> dd061e106fba
Removing intermediate container da7cd7d9b138
Step 4 : ADD cadvisor /usr/bin/cadvisor
 ---> aa66b7ae0141
Removing intermediate container e73877928c84
Step 5 : EXPOSE 8080
 ---> Running in dafae0aa3f2e
 ---> 58e6ab9cc383
Removing intermediate container dafae0aa3f2e
Step 6 : ENTRYPOINT /usr/bin/cadvisor -logtostderr
 ---> Running in 8eff24631902
 ---> b6495090befb
Removing intermediate container 8eff24631902
Successfully built b6495090befb

 $ docker images | grep cadvisor
cadvisor                                                  040bdd3                       b6495090befb        8 seconds ago       36.52 MB

$ docker tag b6495090befb marcellodesales/google-cadvisor:influxdb-0.9
Docker Pull Command
Owner
marcellodesales

Comments (1)
guibod
2 years ago

Thanks for the InfluxDB 0.9 support.