Nagios - The Industry Standard in IT Infrastructure Monitoring 2020
$ sudo apt-get update $ sudo apt-get install apache2 $ sudo service apache2 restart
We can get it from:
$ sudo wget http://assets.nagios.com/downloads/nagiosxi/xi-latest.tar.gz
Unzip it:
$ tar xvzf xi-latest.tar.gz $ cd nagiosxi
We'll install CentOS 6 on the hosted virtual machine (WMWare Workstation 10):
$ sudo add-apt-repository ppa:nagiosinc/ppa
We can now refresh our package database and install the agent package by running these commands:
$ sudo apt-get update $ sudo apt-get install nagios-agent
During the installation process, we will be prompted for the IP address of our Nagios server(s), which is a security directive specifying where to accept connections from. This can be changed later using the following command:
dpkg-reconfigure nagios-agent
We need to download http://library.nagios.com/Nagios XI:
It will be installed ~/Downloads folder.
$ mv xi-2014r1.4.tar.gz /tmp $ cd /tmp $ tar xvzf xi-2014r1.4.tar.gz $ cd nagiosxi
$ ./fullinstall
$ apt-get install apache2 libapache2-mod-php5 build-essential libgd2-xpm-dev libssl-dev sendmail-bin sendmail heirloom-mailx wget apache2-utils curl daemon apt-file libnet-snmp-perl libpq5 libradius1 libsensors4 libsnmp-base libtalloc2 libtdb1 libwbclient0 samba-common samba-common-bin smbclient snmp whois mrtg libmysqlclient15-dev libcgi-pm-perl librrds-perl libgd-gd2-perl
Nagios runs as its own user and has its own groups. We need to create this user and groups:
$ sudo useradd nagios $ sudo groupadd nagcmd $ sudo usermod -a -G nagcmd nagios
$ sudo mkdir -p /usr/local/src/nagios4 $ cd /usr/local/src/nagios4 $ sudo wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.0.8.tar.gz $ sudo tar xf nagios-4.0.8.tar.gz $ cd nagios-4.0.8 $ sudo mkdir -p /usr/local/nagios/share/{stylesheets,images}
configure:
$ sudo ./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios --with-command-user=nagios --with-command-group=nagcmd
The poutput should look like this:
... *** Configuration summary for nagios 4.0.8 08-12-2014 ***: General Options: ------------------------- Nagios executable: nagios Nagios user/group: nagios,nagios Command user/group: nagios,nagcmd Event Broker: yes Install ${prefix}: /usr/local/nagios Install ${includedir}: /usr/local/nagios/include/nagios Lock file: ${prefix}/var/nagios.lock Check result directory: ${prefix}/var/spool/checkresults Init directory: /etc/init.d Apache conf.d directory: /etc/httpd/conf.d Mail program: /bin/mail Host OS: linux-gnu IOBroker Method: epoll Web Interface Options: ------------------------ HTML URL: http://localhost/nagios/ CGI URL: http://localhost/nagios/cgi-bin/ Traceroute (used by WAP): Review the options above for accuracy. If they look okay, type 'make all' to compile the main program and CGIs.
Let's make it:
$ sudo make all
Install the main program, CGIs, and HTML files:
$ sudo make install
Install the init script in /etc/init.d:
$ sudo make install-init
Output:
This package will be built according to these values: 0 - Maintainer: [ k@k ] 1 - Summary: [ ] 2 - Name: [ nagios-init ] 3 - Version: [ 4.0.8 ] 4 - Release: [ 1 ] 5 - License: [ GPL ] 6 - Group: [ checkinstall ] 7 - Architecture: [ amd64 ] 8 - Source location: [ nagios-4.0.8 ] 9 - Alternate source location: [ ] 10 - Requires: [ ] 11 - Provides: [ nagios-init ] 12 - Conflicts: [ ] 13 - Replaces: [ ] ... Done. The new package has been installed and saved to /usr/local/src/nagios4/nagios-4.0.8/nagios-init_4.0.8-1_amd64.deb You can remove it from your system anytime using: dpkg -r nagios-init ...
Install sample config files in /usr/local/nagios/etc:
$ sudo make install-config
Output:
... This package will be built according to these values: 0 - Maintainer: [ root@k ] 1 - Summary: [ Package created with checkinstall 1.6.2 ] 2 - Name: [ nagios-config ] 3 - Version: [ 4.0.8 ] 4 - Release: [ 1 ] 5 - License: [ GPL ] 6 - Group: [ checkinstall ] 7 - Architecture: [ amd64 ] 8 - Source location: [ nagios-4.0.8 ] 9 - Alternate source location: [ ] 10 - Requires: [ ] 11 - Provides: [ nagios-config ] 12 - Conflicts: [ ] 13 - Replaces: [ ] ... Done. The new package has been installed and saved to /usr/local/src/nagios4/nagios-4.0.8/nagios-config_4.0.8-1_amd64.deb You can remove it from your system anytime using: dpkg -r nagios-config ...
Install and configure permissions on the directory for holding the external command file:
$ sudo make install-commandmode
Output:
... This package will be built according to these values: 0 - Maintainer: [ root@k ] 1 - Summary: [ Package created with checkinstall 1.6.2 ] 2 - Name: [ nagios-commandmode ] 3 - Version: [ 4.0.8 ] 4 - Release: [ 1 ] 5 - License: [ GPL ] 6 - Group: [ checkinstall ] 7 - Architecture: [ amd64 ] 8 - Source location: [ nagios-4.0.8 ] 9 - Alternate source location: [ ] 10 - Requires: [ ] 11 - Provides: [ nagios-commandmode ] 12 - Conflicts: [ ] 13 - Replaces: [ ] ... Done. The new package has been installed and saved to /usr/local/src/nagios4/nagios-4.0.8/nagios-commandmode_4.0.8-1_amd64.deb You can remove it from your system anytime using: dpkg -r nagios-commandmode
Install the Apache config file for the Nagios web interface:
$ sudo /usr/bin/install -c -m 644 sample-config/httpd.conf /etc/apache2/conf-available/nagios.conf $ sudo ln -s /etc/apache2/conf-available/nagios.conf /etc/apache2/conf-enabled/nagios.conf
Create a plugin folder and download the plugin:
$ mkdir -p /usr/local/src/nagios-plugins $ cd /usr/local/src/nagios-plugins $ wget https://www.nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz $ tar -xf nagios-plugins-2.0.3.tar.gz $ cd nagios-plugins-2.0.3
Config and compile:
$ sudo ./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl=/usr/bin/openssl --enable-perl-modules --enable-libtap
Output:
... --with-apt-get-command: /usr/bin/apt-get --with-ping6-command: --with-ping-command: /bin/ping -n -U -w %d -c %d %s --with-ipv6: yes --with-mysql: /usr/bin/mysql_config --with-openssl: yes --with-gnutls: no --enable-extra-opts: yes --with-perl: /usr/bin/perl --enable-perl-modules: yes --with-cgiurl: /nagios/cgi-bin --with-trusted-path: /bin:/sbin:/usr/bin:/usr/sbin --enable-libtap: yes
The, make:
$ sudo make $ sudo make install
Let's set up a user account for the new nagios user with password 'admin':
$ sudo apt-get install apache2-utils $ sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin $ sudo chown nagios:nagcmd /usr/local/nagios/etc/htpasswd.users
$ service nagios restart $ service apache2 restart
Ph.D. / Golden Gate Ave, San Francisco / Seoul National Univ / Carnegie Mellon / UC Berkeley / DevOps / Deep Learning / Visualization