2016/06/09

How to install Nagios Core Server and Client Agent on Ubuntu Server 14.04

-------Install Prerequisites-------
[user@localhost ~]$ sudo su
[root@localhost ~]$ apt-get update
[root@localhost ~]$ apt-get -y install build-essential libgd2-xpm-dev apache2 apache2-utils unzip
[root@localhost ~]$ useradd -m nagios
[root@localhost ~]$ passwd nagios
[root@localhost ~]$ groupadd nagcmd
[root@localhost ~]$ usermod -a -G nagcmd nagios
[root@localhost ~]$ usermod -a -G nagcmd www-data

-------Install Nagios Core Server-------
[root@localhost ~]$ wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.1.1.tar.gz
[root@localhost ~]$ tar xzf nagios-4.1.1.tar.gz
[root@localhost ~]$ cd nagios-4.1.1
[root@localhost ~]$ ./configure --with-command-group=nagcmd
[root@localhost ~]$ make all
[root@localhost ~]$ make install-webconf
[root@localhost ~]$ /usr/bin/install -c -m 644 sample-config/httpd.conf /etc/apache2/sites-enabled/nagios.conf
[root@localhost ~]$ ls -l /etc/apache2/sites-enabled/


-------Set Nagios Website Password-------
[root@localhost ~]$ htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
[root@localhost ~]$ service apache2 restart

-------Install Nagios Server Plugin-------
[root@localhost ~]$ wget http://www.nagios-plugins.org/download/nagios-plugins-2.1.1.tar.gz
[root@localhost ~]$ tar xzf nagios-plugins-2.1.1.tar.gz
[root@localhost ~]$ cd nagios-plugins-2.1.1/
[root@localhost ~]$ ./configure --with-nagios-user=nagios --with-nagios-group=nagios
[rootr@localhost ~]$ make
[root@localhost ~]$ make install
[root@localhost ~]$

-------Nagios Server Set Email-------
[root@localhost ~]$ nano /usr/local/nagios/etc/objects/contacts.cfg

email        xxx@ooo.com

-------Nagios Server Set Config-------
[root@localhost ~]$ nano /etc/apache2/sites-enabled/nagios.conf
Order deny,allow
Deny from all
Allow from 127.0.0.1 192.168.xxx.0/24

-------Nagios Server Command-------
[root@localhost ~]$ nano /usr/local/nagios/etc/objects/commands.cfg

Add check_nrpe Command to the end of the file:

define command{
        command_name check_nrpe
        command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}

[root@localhost ~]$ a2enmod rewrite
[root@localhost ~]$ a2enmod cgi
[root@localhost ~]$ service apache2 restart

-------Check Nagios Info-------
[root@localhost ~]$ /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
[root@localhost ~]$ service nagios start

-------Nagios Client Install-------
[root@localhost ~]$ sudo apt-get update
[root@localhost ~]$ apt-get -y install nagios-nrpe-server nagios-plugins

-------Nagios Client Config-------
[root@localhost ~]$ nano /etc/nagios/nrpe.cfg
allowed_hosts=127.0.0.1 192.168.10.xx

[root@localhost ~]$ /etc/init.d/nagios-nrpe-server restart


-------Nagios Server Monitoring Config-------
[root@localhost ~]$ nano /usr/local/nagios/etc/nagios.cfg
cfg_dir=/usr/local/nagios/etc/servers

[root@localhost ~]$ mkdir /usr/local/nagios/etc/servers
[root@localhost ~]$ nano /usr/local/nagios/etc/servers/clients.cfg

define host{
use                             linux-server
host_name               ooo.com
alias                           server
address                         192.168.1.xxx
max_check_attempts              5
check_period                    24x7
notification_interval           30
notification_period             24x7
}
define service {
        use                             generic-service
        host_name                       ooo.com
        service_description             SSH
        check_command                   check_ssh
        notifications_enabled           0
        }

[root@localhost ~]$ service nagios restart

Reference Link: How To Install Nagios Core 4.1.1 In Ubuntu 15.10/16.04

沒有留言:

張貼留言