monitoringartist / zabbix-docker-monitoring

:whale: Docker/Kubernetes/Mesos/Marathon/Chronos/LXC/LXD/Swarm container monitoring - Docker image, Zabbix template and C module
https://hub.docker.com/r/monitoringartist/zabbix-agent-xxl-limited/
GNU General Public License v2.0
1.19k stars 268 forks source link

docker.info to get DriverStatus #84

Closed galindro closed 6 years ago

galindro commented 6 years ago

I'm using ECS optmized AMI to run docker containers and this AMI uses devicemapper driver for Docker storage laying on LVM. How could I use docker.info to get/parse the bellow metrics? I've tried docker.info[DriverStatus] but it returned ZBX_NOTSUPPORTED: Cannot find the [DriverStatus] item in the received JSON object.

$ curl -s --no-buffer -XGET --unix-socket /var/run/docker.sock http://v1.21/info |jq '.DriverStatus'
[
  [
    "Pool Name",
    "docker-docker--pool"
  ],
  [
    "Pool Blocksize",
    "524.3kB"
  ],
  [
    "Base Device Size",
    "10.74GB"
  ],
  [
    "Backing Filesystem",
    "ext4"
  ],
  [
    "Data file",
    ""
  ],
  [
    "Metadata file",
    ""
  ],
  [
    "Data Space Used",
    "4.135GB"
  ],
  [
    "Data Space Total",
    "23.33GB"
  ],
  [
    "Data Space Available",
    "19.19GB"
  ],
  [
    "Metadata Space Used",
    "1.958MB"
  ],
  [
    "Metadata Space Total",
    "25.17MB"
  ],
  [
    "Metadata Space Available",
    "23.21MB"
  ],
  [
    "Thin Pool Minimum Free Space",
    "2.333GB"
  ],
  [
    "Udev Sync Supported",
    "true"
  ],
  [
    "Deferred Removal Enabled",
    "true"
  ],
  [
    "Deferred Deletion Enabled",
    "true"
  ],
  [
    "Deferred Deleted Device Count",
    "0"
  ],
  [
    "Library Version",
    "1.02.135-RHEL7 (2016-11-16)"
  ]
]
jangaraj commented 6 years ago

Unfortunately, that's not possible because current code supports only non list values. docker.info[DriverStatus] -> that's a request to return whole list:

  [
    "Pool Name",
    "docker-docker--pool"
  ],
  [
    "Pool Blocksize",
    "524.3kB"
  ],
...

What should be the output in this case? String? What if you want to select only one particular item value from the list? It needs some good syntax to cover all posible options, for example: docker.info[DriverStatus,*] - returns whole list as a plain text docker.info[DriverStatus,="Pool Blocksize"] - returns item from the list, which contains "Pool Blocksize" key docker.info[DriverStatus,2] - returns 2nd item from the list ...

Feel free to create pull request for that. You need to modify https://github.com/monitoringartist/zabbix-docker-monitoring/blob/0dd6cde8a4007593d555eef3e6e9f8639485d59d/src/modules/zabbix_module_docker/zabbix_module_docker.c#L1850-L1861

In the theory you can use Zabbix 3.4+ and JSON preprocessing to parse that values. That's also concept of https://github.com/monitoringartist/zabbix-docker-monitoring-ng