Issue with LXD monitoring

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
Ivajlo911
Posts: 38
Joined: Thu Mar 23, 2017 3:19 am

Issue with LXD monitoring

Post 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.
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Issue with LXD monitoring

Post 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
Former Nagios employee
https://www.mcapra.com/
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Issue with LXD monitoring

Post by scottwilkerson »

Thanks @mcapra!
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked