Categories
Uncategorized

Installing Nagios 4.3.2 on Ubuntu 16.04

1.- Install LAMP

2.-Install additional dependencies, can be install when setting up LAMP

[su_note]sudo apt-get install wget build-essential apache2 php apache2-mod-php7.0 php-gd libgd-dev unzip[/su_note]

3.- Download Nagios Core 4.3.2 and Nagios Plugins

[su_note]wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.3.2.tar.gz wget http://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz[/su_note]

4.- Create nagios user and group memberships

[su_note]useradd nagios
groupadd nagcmd
usermod -a -G nagcmd nagios
usermod -a -G nagios,nagcmd www-data[/su_note]

Nagios Core Install:

[su_note]
tar zxvf nagios-4.3.2.tar.gz
tar zxvf nagios-plugins-2.2.1.tar.gz

cd nagios-4-3-2
./configure –with-command-group=nagcmd -–with-mail=/usr/bin/sendmail –with-httpd-conf=/etc/apache2/
[/su_note]

If the above step fails due to error: unrecognized option: `-–with-mail=/usr/bin/sendmail’ , then run

[su_note]./configure –with-command-group=nagcmd –with-httpd-conf=/etc/apache2/
[/su_note]

You should get a summary such as:

*** Configuration summary for nagios 4.3.2 2017-05-09 ***:

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/apache2/
Mail program: /usr/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.

…Continue with Install

[su_note]
make all
make install
make install-init
make install-config
make install-commandmode
make install-webconf

cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/
chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

The following step failed
sudo a2ensite nagios
Possible solution is to do: ln -s /etc/apache2/nagios.conf /etc/apache2/sites-available/nagios.conf
then do:
sudo a2ensite nagios.conf
sudo a2enmod rewrite cgi
[/su_note]

You’ll get a message:
To activate the new configuration, you need to run:
service apache2 restart
Wait, don’t run this command yet

[su_note]
sudo cp /etc/init.d/skeleton /etc/init.d/nagios
sudo nano /etc/init.d/nagios

#Add the following lines

DESC=”Nagios”
NAME=nagios
DAEMON=/usr/local/nagios/bin/$NAME
DAEMON_ARGS=”-d /usr/local/nagios/etc/nagios.cfg” PIDFILE=/usr/local/nagios/var/$NAME.lock
[/su_note]

[su_note]
systemctl restart apache2
systemctl start nagios <– This step failed. Working on a solution
[/su_note]

Create a nagios admin account:

[su_note]
htpasswd –c /usr/local/nagios/etc/htpasswd.users nagiosadmin
[/su_note]

Nagios Plugin installation:

[su_note]
cd /tmp/nagios-plugins-2.2.1
./configure –with-nagios-user=nagios –with-nagios-group=nagios
make
make install
[/su_note]

Verify nagios configuration:

[su_note]
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
#you should get
Total Warnings: 0
Total Errors: 0

[/su_note]

Start nagios:
[su_note]/etc/init.d/nagios start[/su_note]

Nagios service setup: The following steps didn’t work. Working on a solution

[su_note]
chkconfig –add nagios
chkconfig –level 35 nagios on
chkconfig –add httpd
chkconfig –level 35 httpd on
sudo update-rc.d nagios defaults

[/su_note]

Login with nagiosadmin
https://servername/nagios