Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1
Email: sales@nagios.com

Login

Remember Me

Directory Tree

check_lxc_resources

Current Version
1.0
Last Release Date
2014-08-24
Compatible With
  • Nagios 3.x
  • Nagios 4.x
Owner
License
GPL
Hits
19423
Network Monitoring Software - Download Nagios XI
Log Management Software - Nagios Log Server - Download
Netflow Analysis Software - Nagios Network Analyzer - Download
You can check your LXC containers memory and swap usages from the host machine with that check.
Usage

Usage : check_lxc_resources -h -n -w -c [-d]
-h : set container name
-n : set container namespace to check (memory|swap)
-w : set warning percent alert
-c : set critical percent alert
-d : debug mode
-help : print this message

Output will looks like this for memory:

memory usage is 42.95% (219M/512M) / 292M free / 177M cached

And like this for swap:

swap usage is 0.02% (0M/464M) / 463M free

Configuration

To make it work, you have to define this command:

define command {
command_name check_lxc_resources
command_line /usr/lib/nagios/plugins/check_nrpe -H $_HOSTPARENT$ -c check_lxc_resources -a $HOSTALIAS$ $ARG2$ $ARG3$ $ARG4$
}

$_HOSTPARENT$: this can be a defined macro to indicate the parent host (which is the host machine)

You can use hostgroups templating:

define hostgroup {
hostgroup_name lxc
alias lxc containers
}

define service{
use generic-service
hostgroup_name lxc
service_description Memory usage
check_command check_lxc_resources!''!'memory'!90!95
}

define service{
use generic-service
hostgroup_name lxc
service_description SWAP usage
check_command check_lxc_resources!''!'swap'!2!5
}

And then you can declare to your hosts:

define host{
use generic-host,host-pnp
host_name hostname.domain.com
alias hostname
address hostname.domain.com
hostgroups lxc
_PARENT parenthost.domain.com
}