home whoami phone maas rPI4 FreeBSD

Nagios on MAAS machines

install ~ configure ~ DHCP ~ commission ~ deploy ~ jq-tricks ~ ssh-in ~ jq-tricks++ ~ nagios


Using Nagios on MAAS machines

A while back, somebody asked me if I'd ever run Nagios on my MAAS machines, to monitor them. I hadn't, although I do have some considerable experience with Nagios. Using NRPE on MAAS machines presents considerable challenges, because machines are completely wiped out every time they are released. The ideas of working out (1) how to get Nagios to work with MAAS machines to begin with, and (2) how to make NRPE persistent across machine re-deployments were kinda irresistable, so here I am, trying it for real.

Simple guide to getting Nagios on the MAAS host machine

The first step is to get a Nagios server up and running, and it only makes sense to put this on the MAAS host (the box where MAAS is running), since that's where you know you have network access to the various machines from there. I have set up a Nagios server many times before, but, full disclaimer, I found this page to be very helpful at remembering all the steps. I've laid out my own process below, but it's heavily guided by the referenced piece, so credit where credit is due.

First step: Install the package dependencies

The first step is to install the dependencies, that is, the packages Nagios needs in order to build. These include:

  • apache2
  • autoconf
  • bc
  • build-essential
  • dc
  • gawk
  • gcc
  • gettext
  • libapache2-mod-php
  • libc6
  • libgd-dev
  • libmcrypt-dev
  • libnet-snmp-perl
  • libssl-dev
  • make
  • php
  • unzip
  • snmp
  • wget

The two steps for installing these are:

sudo apt update
sudo apt install -y {list of dependencies above}

Installing Nagios Core

The latest version of Nagios Core (the free version) as of this writing is 4.4.6. You can download it from nagios with your browser, or you can wget it like this:

wget https://github.com/NagiosEnterprises/nagioscore/archive/nagios-4.4.6.tar.gz

It helps if you either (a) put it in your home directory, or (b) create a dedicated directory so that you don't lose track of the download.

Once you've got it, you need to compile and install it. Pretty standard stuff:

sudo ./configure --with-httpd-conf=/etc/apache2/sites-enabled
sudo make all

When that's done, you'll want to get the nagios user squared away (it may have been done for you, FWIW):

sudo make install-groups-users
sudo usermod -a -G nagios www-data

Then install a boatload of stuff:

sudo make install
sudo make install-daemoninit
sudo make install-commandmode
sudo make install-config
sudo make install-webconf
sudo a2enmod rewrite cgi

Restarting the Apache service probably won't work now, but you can try:

systemctl restart apache2

You'll probably need to add a couple of files:

$ a2enmod auth_digest
Considering dependency authn_core for auth_digest:
Module authn_core already enabled
Enabling module auth_digest.
To activate the new configuration, you need to run:
  systemctl restart apache2

$ a2enmod authz_groupfile
Considering dependency authz_core for authz_groupfile:
Module authz_core already enabled
Enabling module authz_groupfile.
To activate the new configuration, you need to run:
  systemctl restart apache2

Then just try restarting Apache again:

systemctl restart apache2

Create your nagiosadmin user

Next step is to create a usable Nagios admin user; for this exercise, we'll call that user nagionsadmin:

sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

You'll need to type a password in this step.

Setup the Unix firewall

If you've got the firewall turned on, or you're planning on using it, you'll want to set it up, like this:

for svc in Apache ssh
do
ufw allow $svc
done
ufw enable

That gets the Nagios core installed and running; next is the NRPE plugins on the Nagios core server.


Updated 2021-02-11 Thu 20:01 by stormrider (stormrider)


Copyright (C) 2020 by Bill Wear. All rights reserved, but asking to use is permitted and welcome.