ossobv / gocollect

Data collector using go, periodically posts json to a REST api
GNU General Public License v3.0
6 stars 1 forks source link

Collect dockersubpackages (and lxc and friends) #21

Open wdoekes opened 7 years ago

wdoekes commented 7 years ago

Similar to app.vzlist, an app.dockerps but with dpkg-listings..

Something like that...

wdoekes commented 7 years ago

virt.docker:

{"my_container": {
   "name": NAME,
   "uptime": UPTIME(?),
   "image_digest": HASH,
   "image_tag": TAG,
   "os.pkg": {

call os.pkg with container-root from /proc/$(docker inspect -f '{{.State.Pid}}' whmcs-web)/root/

}}}
wdoekes commented 7 years ago

Example info:

# printf 'GET /containers/json HTTP/1.0\r\n\r\n' | nc -U /var/run/docker.sock | sed -e '1,/^.$/d' | jq
[
  {
    "Id": "390...",
    "Names": [
      "/xxx_sip_1"
    ],
    "Image": "xxx_sip",
    "ImageID": "sha256:dba...",
    "Command": "/bin/sh -c 'while true; do sleep 60; done'",
    "Created": 1498636085,
    "Ports": [],
    "Labels": {
      "com.docker.compose.config-hash": "a8f...",
      "com.docker.compose.container-number": "1",
      "com.docker.compose.oneoff": "False",
      "com.docker.compose.project": "xxx",
      "com.docker.compose.service": "sip",
      "com.docker.compose.version": "1.13.0"
    },
    "State": "running",
    "Status": "Up 6 days",
    "HostConfig": {
      "NetworkMode": "xxx_net"
    },
    "NetworkSettings": {
      "Networks": {
        "xxx_net": {
          "IPAMConfig": null,
          "Links": null,
          "Aliases": null,
          "NetworkID": "484xxx",
          "EndpointID": "b81xxx",
          "Gateway": "172.20.0.254",
          "IPAddress": "172.20.0.4",
          "IPPrefixLen": 24,
          "IPv6Gateway": "",
          "GlobalIPv6Address": "",
          "GlobalIPv6PrefixLen": 0,
          "MacAddress": "02:42:ac:14:00:04"
        }
      }
    },
    "Mounts": []
  },

Missing info:

wdoekes commented 7 years ago

FYI: filters:

GET /v1.24/containers/json?filters=%7B%22name%22%3A%7B%22xxx_sip_1%22%3Atrue%7D%7D

No column limiting there.

Just fetch the docker containers through /containers/json | jq .[].Id directly.