Page 1 of 1

Issue with LXD monitoring

Posted: Fri Sep 28, 2018 2:20 am
by Ivajlo911
Hi,
we would like to start monitoring LXD containers from the Linux host without having an agent in the container itself.

Can you help with some recommendations?

Details of our implementation:
CentOS Linux release 7.4.1708 (Core)
Manual Install of Nagios XI
No special configurations on our system, ie; is Gnome installed
We are not using a proxy
We are using Nagios XI 5.4.13.

Thank you.

Re: Issue with LXD monitoring

Posted: Fri Sep 28, 2018 8:20 am
by mcapra
It appears as though you can send curl requests to the Unix socket and get JSON back:

Code: Select all

#~ curl --unix-socket /var/lib/lxd/unix.socket lxd/1.0/containers/c1/state | jq .metadata
{
  "status": "Running",
  "status_code": 103,
  "disk": {
    "root": {
      "usage": 9805824
    }
  },
  "memory": {
    "usage": 111071232,
    "usage_peak": 234029056,
    "swap_usage": 0,
    "swap_usage_peak": 0
  },
  "network": {
    "eth0": {
      "addresses": [
        {
          "family": "inet",
          "address": "10.204.119.69",
          "netmask": "24",
          "scope": "global"
        },
        {
          "family": "inet6",
          "address": "2001:470:b368:4242:216:3eff:fef4:db69",
          "netmask": "64",
          "scope": "global"
        },
        {
          "family": "inet6",
          "address": "fe80::216:3eff:fef4:db69",
          "netmask": "64",
          "scope": "link"
        }
      ],
      "counters": {
        "bytes_received": 57945,
        "bytes_sent": 4876,
        "packets_received": 417,
        "packets_sent": 38
      },
      "hwaddr": "00:16:3e:f4:db:69",
      "host_name": "vethSJ6ABH",
      "mtu": 1500,
      "state": "up",
      "type": "broadcast"
    },
    "lo": {
      "addresses": [
        {
          "family": "inet",
          "address": "127.0.0.1",
          "netmask": "8",
          "scope": "local"
        },
        {
          "family": "inet6",
          "address": "::1",
          "netmask": "128",
          "scope": "local"
        }
      ],
      "counters": {
        "bytes_received": 0,
        "bytes_sent": 0,
        "packets_received": 0,
        "packets_sent": 0
      },
      "hwaddr": "",
      "host_name": "",
      "mtu": 65536,
      "state": "up",
      "type": "loopback"
    }
  },
  "pid": 22156,
  "processes": 29,
  "cpu": {
    "usage": 6312866518
  }
}
More info:
https://gist.github.com/jaytaylor/56a99 ... be64396b03
https://lxd.readthedocs.io/en/latest/

That's really all this check_lxd plugin I found is doing, communicating with the Unix socket and returning some sort of interpreted markup (in this case YAML):
https://github.com/alex-left/check-lxd/ ... eck_lxd.py

Very similar to Docker in this case; A socket connection that returns well formatted responses.

More info on using custom plugins with Nagios XI:
https://assets.nagios.com/downloads/nag ... ios-XI.pdf

Re: Issue with LXD monitoring

Posted: Fri Sep 28, 2018 9:14 am
by scottwilkerson
Thanks @mcapra!