2 minutes
Nagios Server Setup
As the internet of shit has been hitting the fan this week, it has given me pause to do some home monitoring. Someone in my house loves iot devices and we have a few on the network that absolutley could be doing something I am not aware of. Anyway, it has driven me to pursue setting up a virtual nagios server in my kvm server.
Setup and Pre-Req Installation
So the first thing was to setup a new virtual machine for this, so I went ahead and followed my earlier guide. kvm guest setup. Once that is completed, I start installing all of the pre-req’s.
sudo apt-get install apache2 libapache2-mod-php5 build-essential libgd-dev unzip apache2-utils
Add the needed user and setup the group
Next, I have to setup the nagios user and group. Then add the user and the apache user to the group.
sudo useradd nagios
sudo passwd nagios
sudo groupadd nagcmd
sudo usermod -a -G nagcmd nagios
sudo usermod -a -G nagcmd www-data
#Download source Downloading the zipped files for both the core and the plugins…
mkdir ~/downloads
cd ~/downloads
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.2.1.tar.gz
wget https://nagios-plugins.org/download/nagios-plugins-2.1.2.tar.gz
#Unzip and compile the core
First extract the files
tar xzf nagios-4.2.1.tar.gz
cd nagios-4.2.1
then configure it with the group and make it
sudo ./configure --with-command-group=nagcmd
sudo make all
and lastly install it.
sudo make install
sudo make install-init
sudo make install-config
sudo make install-commandmode
Change the configuration file to point to your own email address.
sudo nano /usr/local/nagios/etc/objects/contacts.cfg
Configure the web interface
To make the web interface work on Ubuntu 14.04 I had to create a few directories before running the make-install command.
sudo mkdir /etc/httpd
sudo mkdir /etc/httpd/conf.d
sudo mkdir /etc/httpd/conf.d/nagios.conf
sudo make install-webconf
Then create a web user and a password (I hope you are keeping track of these passwords). Restart apache for the settings to work.
sudo a2enmod rewrite
sudo a2enmod cgi
sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
sudo ln -s /etc/httpd/conf.d/nagios.conf/httpd.conf /etc/apache2/sites-enabled/
sudo service apache2 restart
Compile the nagios plugins
Unzip the plugins:
cd ~/downloads
tar xzf nagios-plugins-2.1.2.tar.gz
cd nagios-plugins-2.1.2
Configure and install the plugins:
./configure --with-nagios-user=nagios --with-nagios-group=nagios
sudo make
sudo make install
Startup Nagios
Set the system to start nagios on boot:
ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios
Perform “pre-flight” check:
sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Assuming all good - go ahead and start the service (if not start the googling)
sudo service nagios restart
Credits:
Nagios Quick Start contains most of this. How-To-Forge also has a very thorough walk-through on this. These two sources were most of what I used to make this happen