Rabu, 28 September 2016

Client Nagios WIndows

Untuk memantau OS Windows lakukan langkah-langkah sbb:
  1. Install NSClient++ addon pada OS WIndows
  2. Konfigurasi Pada Nagios Server demi OS Windows
  3. Konfigurasi service dan IP Host /Windows yang hendak dimonitoring
  4. Restart Ulang Nagios Service
Praktik:
jika gagal install gunakan file yang versi lamanya bisa donload di : https://sourceforge.net/projects/nscplus/files/OldFiles/NSClient%2B%2B-0.0.2-a2.zip/download atau sumber semuanya di :

+extract ke D:\NSClient
+jalankan run (via Administrator)

+cd D:\NSCLient
+ketik nsclient++ /install
+ketik nsclient++ SysTray


Lalu pada RUN ketik: services.msc
aktifkan / start NSCLient services



buka file NSC.INI pada drektori C:\NSClient
=>
uncomment all the modules defined in the “modules” section, except for CheckWMI.dll and RemoteConfiguration.dll.

Bentuk akhirnya adalah sbb:


[log]
# LOG DEBUG
# Set to 1 if you want debug message printed in the log file (debug messages are always printed to stdout when run with -test)
;debug=0
# LOG FILE
# The file to print log statements to
;file=NSC.log


[Settings]
;# ALLOWED HOST ADDRESSES
;  This is a comma-delimited list of IP address of hosts that are allowed to talk to the all daemons.
;  If leave this blank anyone can access the deamon remotly (NSClient still requires a valid password).
;  The syntax is host or ip/mask so 192.168.0.0/24 will allow anyone on that subnet access
allowed_hosts=192.168.1.103

[systray]
# SYSTRAY INJECT COMMAND
# The default command to show in the inject dialog from the event log.
defaultCommand=CheckEventLog Application warn.require.eventType=error warn.require.eventType=warning critical.require.eventType=error critical.exclude.eventType=info truncate=1024 descriptions

[NSClient]
# NSCLIENT PORT NUMBER
# This is the port the NSClientListener.dll will listen to.
port=12489
# PASSWORD
# This is the password (-s) that is required to access NSClient remotely
;password=
# ALLOWED HOST ADDRESSES
# This is a comma-delimited list of IP address of hosts that are allowed to talk to the NRPE daemon.
;allowed_hosts=
 ;adress=w.x.y.z (not yet implemented)

[NRPE]
# NRPE PORT NUMBER
# This is the port the NRPEListener.dll will listen to.
;port=5666
# ALLOWED HOST ADDRESSES
# This is a comma-delimited list of IP address of hosts that are allowed to talk to the NRPE daemon.
;allowed_hosts=
# COMMAND TIMEOUT
# This specifies the maximum number of seconds that the NRPE daemon will allow plug-ins to finish executing before killing them off.
;command_timeout=60
# COMMAND ARGUMENT PROCESSING
# This option determines whether or not the NRPE daemon will allow clients to specify arguments to commands that are executed.
;allow_arguments=0
# COMMAND ALLOW NASTY META CHARS
# This option determines whether or not the NRPE daemon will allow clients to specify nasty (as in |`&><'"\[]{}) characters in arguments.
;allow_nasty_meta_chars=0
 ;adress=w.x.y.z (not yet implemented)
 ;dont_blame_nrpe (renamed to 'allow_arguments' as it seemd to make more sense)

[NRPE Handlers]
# COMMAND DEFINITIONS
# Command definitions that this daemon will run.
# Can be either NRPE syntax: 
command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
# Or simplified syntax:
test=c:\test.bat foo $ARG1$ bar
check_disk1=/usr/local/nagios/libexec/check_disk -w 5 -c 10
# Or even loopback (inject) syntax (to run internal commands)
# This is a way to run "NSClient" commands and other internal module commands such as check eventlog etc.
check_cpu=inject checkCPU warn=80 crit=90 5 10 15
check_eventlog=inject CheckEventLog Application warn.require.eventType=error warn.require.eventType=warning critical.require.eventType=error critical.exclude.eventType=info truncate=1024 descriptions
# But be careful:
; dont_check=inject dont_check This will "loop forever" so be careful with the inject command...

[modules]
# NSCLIENT++ MODULES
# A list with DLLs to load at startup.
FileLogger.dll
CheckSystem.dll
CheckDisk.dll
NSClientListener.dll
NRPEListener.dll
SysTray.dll
CheckEventLog.dll
CheckHelpers.dll
;CheckWMI.dll
;
; RemoteConfiguration IS AN EXTREM EARLY IDEA SO DONT USE FOR PRODUCTION ENVIROMNEMTS!
;RemoteConfiguration.dll
; NSCA Agent is a new beta module use with care!
;NSCAAgent.dll
; LUA script module used to write your own "check deamon" (sort of) early beta.
;LUAScript.dll
; Script to check external scripts and/or internal aliases, early beta.
;CheckExternalScripts.dll
; Check other hosts through NRPE extreme beta and probably a bit dangerous! :)
;NRPEClient.dll


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Lalu restart : nsclient++ /start

NB ip 192.168.1.103 adalah ipnya server nagios



+++SELESAI DISII CLIENT SEKARANG TAMBAHKAN CODE DISISI SERVER

Configuring Nagios Server and Add Windows Hosts

SET IP CLIENT WINDOWS

Now Login into Nagios Server and add some object definitions in Nagios configuration files to monitor newWindows machine. Open windows.cfg file for editing with Vi editor.
[root@tecmint]# vi /usr/local/nagios/etc/objects/windows.cfg
A sample Windows host definition already defined for the Windows machine, you can simply change the host definition like host_namealias, and address fields to appropriate values of your Windows machine.
###############################################################################
###############################################################################
#
# HOST DEFINITIONS
#
###############################################################################
###############################################################################
# Define a host for the Windows machine we'll be monitoring
# Change the host_name, alias, and address to fit your situation
define host{
use             windows-server  ; Inherit default values from a template
host_name       winserver       ; The name we're giving to this host
alias           My Windows Server       ; A longer name associated with the host
address         172.31.41.53    ; IP address of the host
}
Following services are already added and enabled in windows.cfg file. If you wish to add some more other service definitions that needs to be monitored, you can simple add those definitions to same configuration file. Make sure to change the host_name for these all services with host_name defined in the above step.
define service{
use   generic-service
host_name  winserver
service_description NSClient++ Version
check_command  check_nt!CLIENTVERSION
}
Add the following service definition to monitor the uptime of the Windows server.
define service{
use   generic-service
host_name  winserver
service_description Uptime
check_command  check_nt!UPTIME
}
Add the following service definition to monitor the CPU utilization on the Windows server and generate a CRITICAL alert if the 5-minute CPU load is 90% or more or a WARNING alert if the 5-minute load is 80% or greater.
define service{
use   generic-service
host_name  winserver
service_description CPU Load
check_command  check_nt!CPULOAD!-l 5,80,90
}
Add the following service definition to monitor memory usage on the Windows server and generate a CRITICAL alert if memory usage is 90% or more or a WARNING alert if memory usage is 80% or greater.
define service{
use   generic-service
host_name  winserver
service_description Memory Usage
check_command  check_nt!MEMUSE!-w 80 -c 90
}
Add the following service definition to monitor usage of the C:\ drive on the Windows server and generate a CRITICAL alert if disk usage is 90% or more or a WARNING alert if disk usage is 80% or greater.
define service{
use   generic-service
host_name  winserver
service_description C:\ Drive Space
check_command  check_nt!USEDDISKSPACE!-l c -w 80 -c 90
}
Add the following service definition to monitor the W3SVC service state on the Windows machine and generate a CRITICAL alert if the service is stopped.
define service{
use   generic-service
host_name  winserver
service_description W3SVC
check_command  check_nt!SERVICESTATE!-d SHOWALL -l W3SVC
}
Add the following service definition to monitor the Explorer.exe process on the Windows machine and generate a CRITICAL alert if the process is not running.
define service{
use   generic-service
host_name  winserver
service_description Explorer
check_command  check_nt!PROCSTATE!-d SHOWALL -l Explorer.exe
}
Lastly, uncomment the windows.cfg file in /usr/local/nagios/etc/nagios.cfg.
[root@tecmint]# vi /usr/local/nagios/etc/nagios.cfg
# Definitions for monitoring a Windows machine
cfg_file=/usr/local/nagios/etc/objects/windows.cfg
Finally, verify the Nagios configuration files for any erros.
[root@tecmint]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Total Warnings: 0
Total Errors:   0
Things look okay - No serious problems were detected during the pre-flight check
If the verification process throws any error messages, fix those errors until the verification process completes without any error messages. Once’ you fix those errors, restart the Nagios service.
[root@tecmint]# service nagios restart
Running configuration check...done.
Stopping nagios: done.
Starting nagios: done.
That’s it. Now go to Nagios Monitoring Web interface at “http://Your-server-IP-address/nagios” or “http://FQDN/nagios” and Provide the username “nagiosadmin” and password. Check that the Remote Windows Host was added and is being monitored.

Nagios Monitor Windows Host

Client Nagios WIndows

Untuk memantau OS Windows lakukan langkah-langkah sbb:
  1. Install NSClient++ addon pada OS WIndows
  2. Konfigurasi Pada Nagios Server demi OS Windows
  3. Konfigurasi service dan IP Host /Windows yang hendak dimonitoring
  4. Restart Ulang Nagios Service
Praktik:
jika gagal install gunakan file yang versi lamanya bisa donload di : https://sourceforge.net/projects/nscplus/files/OldFiles/NSClient%2B%2B-0.0.2-a2.zip/download atau sumber semuanya di :

+extract ke D:\NSClient
+jalankan run (via Administrator)

+cd D:\NSCLient
+ketik nsclient++ /install
+ketik nsclient++ SysTray


Lalu pada RUN ketik: services.msc
aktifkan / start NSCLient services



buka file NSC.INI pada drektori C:\NSClient
=>
uncomment all the modules defined in the “modules” section, except for CheckWMI.dll and RemoteConfiguration.dll.

Bentuk akhirnya adalah sbb:


[log]
# LOG DEBUG
# Set to 1 if you want debug message printed in the log file (debug messages are always printed to stdout when run with -test)
;debug=0
# LOG FILE
# The file to print log statements to
;file=NSC.log


[Settings]
;# ALLOWED HOST ADDRESSES
;  This is a comma-delimited list of IP address of hosts that are allowed to talk to the all daemons.
;  If leave this blank anyone can access the deamon remotly (NSClient still requires a valid password).
;  The syntax is host or ip/mask so 192.168.0.0/24 will allow anyone on that subnet access
allowed_hosts=192.168.1.103

[systray]
# SYSTRAY INJECT COMMAND
# The default command to show in the inject dialog from the event log.
defaultCommand=CheckEventLog Application warn.require.eventType=error warn.require.eventType=warning critical.require.eventType=error critical.exclude.eventType=info truncate=1024 descriptions

[NSClient]
# NSCLIENT PORT NUMBER
# This is the port the NSClientListener.dll will listen to.
port=12489
# PASSWORD
# This is the password (-s) that is required to access NSClient remotely
;password=
# ALLOWED HOST ADDRESSES
# This is a comma-delimited list of IP address of hosts that are allowed to talk to the NRPE daemon.
;allowed_hosts=
 ;adress=w.x.y.z (not yet implemented)

[NRPE]
# NRPE PORT NUMBER
# This is the port the NRPEListener.dll will listen to.
;port=5666
# ALLOWED HOST ADDRESSES
# This is a comma-delimited list of IP address of hosts that are allowed to talk to the NRPE daemon.
;allowed_hosts=
# COMMAND TIMEOUT
# This specifies the maximum number of seconds that the NRPE daemon will allow plug-ins to finish executing before killing them off.
;command_timeout=60
# COMMAND ARGUMENT PROCESSING
# This option determines whether or not the NRPE daemon will allow clients to specify arguments to commands that are executed.
;allow_arguments=0
# COMMAND ALLOW NASTY META CHARS
# This option determines whether or not the NRPE daemon will allow clients to specify nasty (as in |`&><'"\[]{}) characters in arguments.
;allow_nasty_meta_chars=0
 ;adress=w.x.y.z (not yet implemented)
 ;dont_blame_nrpe (renamed to 'allow_arguments' as it seemd to make more sense)

[NRPE Handlers]
# COMMAND DEFINITIONS
# Command definitions that this daemon will run.
# Can be either NRPE syntax: 
command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
# Or simplified syntax:
test=c:\test.bat foo $ARG1$ bar
check_disk1=/usr/local/nagios/libexec/check_disk -w 5 -c 10
# Or even loopback (inject) syntax (to run internal commands)
# This is a way to run "NSClient" commands and other internal module commands such as check eventlog etc.
check_cpu=inject checkCPU warn=80 crit=90 5 10 15
check_eventlog=inject CheckEventLog Application warn.require.eventType=error warn.require.eventType=warning critical.require.eventType=error critical.exclude.eventType=info truncate=1024 descriptions
# But be careful:
; dont_check=inject dont_check This will "loop forever" so be careful with the inject command...

[modules]
# NSCLIENT++ MODULES
# A list with DLLs to load at startup.
FileLogger.dll
CheckSystem.dll
CheckDisk.dll
NSClientListener.dll
NRPEListener.dll
SysTray.dll
CheckEventLog.dll
CheckHelpers.dll
;CheckWMI.dll
;
; RemoteConfiguration IS AN EXTREM EARLY IDEA SO DONT USE FOR PRODUCTION ENVIROMNEMTS!
;RemoteConfiguration.dll
; NSCA Agent is a new beta module use with care!
;NSCAAgent.dll
; LUA script module used to write your own "check deamon" (sort of) early beta.
;LUAScript.dll
; Script to check external scripts and/or internal aliases, early beta.
;CheckExternalScripts.dll
; Check other hosts through NRPE extreme beta and probably a bit dangerous! :)
;NRPEClient.dll


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Lalu restart : nsclient++ /start

NB ip 192.168.1.103 adalah ipnya server nagios



+++SELESAI DISII CLIENT SEKARANG TAMBAHKAN CODE DISISI SERVER

Configuring Nagios Server and Add Windows Hosts

Now Login into Nagios Server and add some object definitions in Nagios configuration files to monitor newWindows machine. Open windows.cfg file for editing with Vi editor.
[root@tecmint]# vi /usr/local/nagios/etc/objects/windows.cfg
A sample Windows host definition already defined for the Windows machine, you can simply change the host definition like host_namealias, and address fields to appropriate values of your Windows machine.
###############################################################################
###############################################################################
#
# HOST DEFINITIONS
#
###############################################################################
###############################################################################
# Define a host for the Windows machine we'll be monitoring
# Change the host_name, alias, and address to fit your situation
define host{
use             windows-server  ; Inherit default values from a template
host_name       winserver       ; The name we're giving to this host
alias           My Windows Server       ; A longer name associated with the host
address         172.31.41.53    ; IP address of the host
}
Following services are already added and enabled in windows.cfg file. If you wish to add some more other service definitions that needs to be monitored, you can simple add those definitions to same configuration file. Make sure to change the host_name for these all services with host_name defined in the above step.
define service{
use   generic-service
host_name  winserver
service_description NSClient++ Version
check_command  check_nt!CLIENTVERSION
}
Add the following service definition to monitor the uptime of the Windows server.
define service{
use   generic-service
host_name  winserver
service_description Uptime
check_command  check_nt!UPTIME
}
Add the following service definition to monitor the CPU utilization on the Windows server and generate a CRITICAL alert if the 5-minute CPU load is 90% or more or a WARNING alert if the 5-minute load is 80% or greater.
define service{
use   generic-service
host_name  winserver
service_description CPU Load
check_command  check_nt!CPULOAD!-l 5,80,90
}
Add the following service definition to monitor memory usage on the Windows server and generate a CRITICAL alert if memory usage is 90% or more or a WARNING alert if memory usage is 80% or greater.
define service{
use   generic-service
host_name  winserver
service_description Memory Usage
check_command  check_nt!MEMUSE!-w 80 -c 90
}
Add the following service definition to monitor usage of the C:\ drive on the Windows server and generate a CRITICAL alert if disk usage is 90% or more or a WARNING alert if disk usage is 80% or greater.
define service{
use   generic-service
host_name  winserver
service_description C:\ Drive Space
check_command  check_nt!USEDDISKSPACE!-l c -w 80 -c 90
}
Add the following service definition to monitor the W3SVC service state on the Windows machine and generate a CRITICAL alert if the service is stopped.
define service{
use   generic-service
host_name  winserver
service_description W3SVC
check_command  check_nt!SERVICESTATE!-d SHOWALL -l W3SVC
}
Add the following service definition to monitor the Explorer.exe process on the Windows machine and generate a CRITICAL alert if the process is not running.
define service{
use   generic-service
host_name  winserver
service_description Explorer
check_command  check_nt!PROCSTATE!-d SHOWALL -l Explorer.exe
}
Lastly, uncomment the windows.cfg file in /usr/local/nagios/etc/nagios.cfg.
[root@tecmint]# vi /usr/local/nagios/etc/nagios.cfg
# Definitions for monitoring a Windows machine
cfg_file=/usr/local/nagios/etc/objects/windows.cfg
Finally, verify the Nagios configuration files for any erros.
[root@tecmint]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Total Warnings: 0
Total Errors:   0
Things look okay - No serious problems were detected during the pre-flight check
If the verification process throws any error messages, fix those errors until the verification process completes without any error messages. Once’ you fix those errors, restart the Nagios service.
[root@tecmint]# service nagios restart
Running configuration check...done.
Stopping nagios: done.
Starting nagios: done.
That’s it. Now go to Nagios Monitoring Web interface at “http://Your-server-IP-address/nagios” or “http://FQDN/nagios” and Provide the username “nagiosadmin” and password. Check that the Remote Windows Host was added and is being monitored.
Nagios Monitor Windows Host
Nagios Monitor Windows Host

Jumat, 23 September 2016

CLient Nagios Linux

Adding a Host to Monitor

In this tutorial you will add an Ubuntu host to monitor to the Nagios server we have made above.
Nagios Server IP : 192.168.1.101
Ubuntu Host IP : 192.168.1.102

Step 1 - Connect to ubuntu host

ssh root@192.168.1.102

Step 2 - Install NRPE Service

sudo apt-get install nagios-nrpe-server nagios-plugins

Step 3 - Configure NRPE

After the installation is complete, edit the nrpe file /etc/nagios/nrpe.cfg:
vim /etc/nagios/nrpe.cfg
... and add Nagios Server IP 192.168.1.101 to the server_address.

Step 4 - Restart NRPE

/etc/init.d/nagios-nrpe-server restart



DAFTARKAN CLIENT HOST DI SERVER :

Please connect to the Nagios server:
ssh root@192.168.1.101
Then create a new file for the host configuration in /usr/local/nagios/etc/servers/.
vim /usr/local/nagios/etc/servers/ubuntu_host.cfg
Add the following lines:
# Ubuntu Host configuration file

define host {
        use                          linux-server
        host_name                    ubuntu_host
        alias                        Ubuntu Host
        address                      192.168.1.102 #Ubuntu host IP
        register                     1
}

define service {
      host_name                       ubuntu_host
      service_description             PING
      check_command                   check_ping!100.0,20%!500.0,60%
      max_check_attempts              2
      check_interval                  2
      retry_interval                  2
      check_period                    24x7
      check_freshness                 1
      contact_groups                  admins
      notification_interval           2
      notification_period             24x7
      notifications_enabled           1
      register                        1
}

define service {
      host_name                       ubuntu_host
      service_description             Check Users
      check_command        check_local_users!20!50
      max_check_attempts              2
      check_interval                  2
      retry_interval                  2
      check_period                    24x7
      check_freshness                 1
      contact_groups                  admins
      notification_interval           2
      notification_period             24x7
      notifications_enabled           1
      register                        1
}

define service {
      host_name                       ubuntu_host
      service_description             Local Disk
      check_command                   check_local_disk!20%!10%!/
      max_check_attempts              2
      check_interval                  2
      retry_interval                  2
      check_period                    24x7
      check_freshness                 1
      contact_groups                  admins
      notification_interval           2
      notification_period             24x7
      notifications_enabled           1
      register                        1
}

define service {
      host_name                       ubuntu_host
      service_description             Check SSH
      check_command                   check_ssh
      max_check_attempts              2
      check_interval                  2
      retry_interval                  2
      check_period                    24x7
      check_freshness                 1
      contact_groups                  admins
      notification_interval           2
      notification_period             24x7
      notifications_enabled           1
      register                        1
}
You can find many check_command in /usr/local/nagios/etc/objects/commands.cfg file. See there if you want to add more services like DHCP, POP etc.
And now check the configuration:
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
... to see if the configuration is correct.

Restart all services

On the Ubuntu Host start NRPE Service:
/etc/init.d/nagios-nrpe-server restart
... and on the Nagios server, start Apache and Nagios:
/etc/init.d/apache2 restart
/etc/init.d/nagios restart

Testing Ubuntu Host

Open the Nagios server from the browser and see the ubuntu_host being monitored.

Conclusion

Nagios is an open source application for monitoring a system. Nagios has been widely used because of the ease of configuration. Nagios in support by various plugins, and you can even create your own plugins. Look here for more informations.

Reff:
https://www.howtoforge.com/tutorial/how-to-install-nagios-on-ubuntu-15-04/

Installl NAGIOS Terbaru



Update dahulu inux nya

sudo apt-get update
sudo apt-get upgrade

Features

Using Nagios, you can:
  • Monitor your entire IT infrastructure.
  • Identify problems before they occur.
  • Know immediately when problems arise.
  • Share availability data with stakeholders.
  • Detect security breaches.
  • Plan and budget for IT upgrades.
  • Reduce downtime and business losses.

Scenario

For the purpose of this tutorial, I will be using the following two systems.

Nagios server:

  • Operating system : Ubuntu 15.10 Server
  • IP Address : 192.168.1.103/24

Nagios client:

  • Operating System : Ubuntu 14.04 Server
  • IP Address : 192.168.1.104/24
  • Hostname : server.unixmen.local

Prerequisites

Make sure your server have installed with fully working LAMP stack. If not, follow the below link to install LAMP server.
Then install the following prerequisites:
sudo apt-get install build-essential libgd2-xpm-dev apache2-utils unzip
untuk versi lebih lengkapnya:
 
apt-get install build-essential php5-gd wget libgd2-xpm-dev libapache2-mod-php5 apache2-utils daemon unzip

Create Nagios User And Group

Create a new nagios user account:
sudo useradd -m nagios
sudo passwd nagios
Create a new nagcmd group for allowing external commands to be submitted through the web interface. Add both the nagios user and the apache user to the group.
sudo groupadd nagcmd
sudo usermod -a -G nagcmd nagios
sudo usermod -a -G nagcmd www-data

Download Nagios And Plugins

Go to the nagios download page, and get the latest version. As of writing this, the latest version was 4.1.1.
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.1.1.tar.gz
And, download nagios plugins too. Nagios plugins allow you to monitor hosts, devices, services, protocols, and applications with Nagios
wget http://www.nagios-plugins.org/download/nagios-plugins-2.1.1.tar.gz

Install Nagios And Plugins

Install nagios:
Go to the folder where you’ve downloaded nagios, and extract it using command:
tar xzf nagios-4.1.1.tar.gz
Change to the nagios directory:
cd nagios-4.1.1/
Run the following commands one by one from the Terminal to compile and install nagios.
sudo ./configure --with-command-group=nagcmd
sudo make all
sudo make install
sudo make install-init
sudo make install-config
sudo make install-commandmode
Install Nagios Web interface:
Enter the following commands to compile and install nagios web interface.
sudo make install-webconf
You may get the following error:
/usr/bin/install -c -m 644 sample-config/httpd.conf /etc/httpd/conf.d/nagios.conf
 /usr/bin/install: cannot create regular file ‘/etc/httpd/conf.d/nagios.conf’: No such file or directory
 Makefile:296: recipe for target 'install-webconf' failed
 make: *** [install-webconf] Error 1
The above error message describes that nagios is trying to create the nagios.conf file inside the /etc/httpd.conf/directory. But, in Ubuntu systems the nagios.conf file should be placed in /etc/apache2/sites-enabled/directory.
So, run the following command instead of using sudo make install-webconf.
sudo /usr/bin/install -c -m 644 sample-config/httpd.conf /etc/apache2/sites-enabled/nagios.conf

JIKA GAGAL:
lalukan sbb(karena apache2 gagal terinstall):

apt-get install build-essential php5-gd wget libgd2-xpm-dev libapache2-mod-php5 apache2-utils daemon unzip




Check if nagios.conf is placed in /etc/apache2/sites-enabled directory.
sudo ls -l /etc/apache2/sites-enabled/
Sample output:
total 4
lrwxrwxrwx 1 root root 35 Nov 28 16:49 000-default.conf -> ../sites-available/000-default.conf
-rw-r--r-- 1 root root 1679 Nov 28 17:02 nagios.conf
Create a nagiosadmin account for logging into the Nagios web interface. Remember the password you assign to this account. You’ll need it while logging in to nagios web interface..
sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Restart Apache to make the new settings take effect.
In Ubuntu 15.10/15.04:
sudo systemctl restart apache2
In Ubuntu 14.10 and previous versions:
sudo service apache2 restart
Install Nagios plugins:
Go to the directory where you downloaded the nagios plugins, and extract it.
tar xzf nagios-plugins-2.1.1.tar.gz
Change to the nagios plugins directory:
cd nagios-plugins-2.1.1/
Run the following commands one by one to compile and install it.
sudo ./configure --with-nagios-user=nagios --with-nagios-group=nagios
sudo make
sudo make install
Wait, We are not finished yet.

Configure Nagios

Nagios sample configuration files will be found in the /usr/local/nagios/etc directory. These sample files should work fine for getting started with Nagios. However, if you want, you’ll need to put your actual email ID to receive alerts.
To do that, Edit the /usr/local/nagios/etc/objects/contacts.cfg config file with your favorite editor and change the email address associated with the nagiosadmin contact definition to the address you’d like to use for receiving alerts.
sudo nano /usr/local/nagios/etc/objects/contacts.cfg
Find the following line and enter the email id:
[...]
define contact{
        contact_name                    nagiosadmin             ; Short name of user
        use                             generic-contact         ; Inherit default values from generic-contact template (defined above)
        alias                           Nagios Admin            ; Full name of user

        email                           sk@unixmen.com  ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
        }
[...]
Save and close the file.
Then, Edit file /etc/apache2/sites-enabled/nagios.conf,
sudo nano /etc/apache2/sites-enabled/nagios.conf
And edit the following lines if you want to access nagios administrative console from a particular IP series.
Here, I want to allow nagios administrative access from 192.168.1.0/24 series only. So, I edited this file as shown below.
[...]
## Comment the following lines ##
#   Order allow,deny
#   Allow from all

## Uncomment and Change lines as shown below ##
Order deny,allow
Deny from all
Allow from 127.0.0.1 192.168.1.0/24
[...]
Enable Apache’s rewrite and cgi modules:
sudo a2enmod rewrite
sudo a2enmod cgi
Restart apache service.
sudo systemctl restart apache2
Or,
sudo service apache2 restart
Check nagios,conf file for any syntax errors:
sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
If there are no errors, start nagios service and make it to start automatically on every boot.
sudo service nagios start
sudo ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios
Note: In Ubuntu 15.10/15.04, you will see the following error message while starting nagios service.
Failed to start nagios.service: Unit nagios.service failed to load: No such file or directory.
Or
[....] Starting nagios (via systemctl): nagios.serviceFailed to start nagios.service: Unit nagios.service failed to load: No such file or directory.
 failed!
To fix this error, copy /etc/init.d/skeleton to /etc/init.d/nagios using the following command:
sudo cp /etc/init.d/skeleton /etc/init.d/nagios
Edit file /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
Save and close the file.
Finally you need to change the permissions of the file
sudo chmod +x /etc/init.d/nagios
Now, you can start nagios service using command:
sudo /etc/init.d/nagios start

Access Nagios Web Interface

Open up your web browser and navigate to http://nagios-server-ip/nagios and enter the username as nagiosadmin and its password which we created in the earlier steps.
192.168.1.103-nagios – Google Chrome_001
Here it is how Nagios administrative console looks like:
Nagios Core – Google Chrome_002
Click on the “Hosts” section in the left pane of the console. You will see there the no of hosts being monitored by Nagios server. We haven’t added any hosts yet. So it simply monitors the localhost itself only.
Nagios Core – Google Chrome_003
Click on the localhost to display more details:
Nagios Core – Google Chrome_004
That’s it. We have successfully installed and configure Nagios core in our Ubuntu 15.04 server.
==============================================

PERSIAPAN CLIENT yang hendak di monitoring oleh NAGIOS

Add Monitoring targets to Nagios server

Now, let us add some clients to monitor by Nagios server.
To do that we have to install nrpe and nagios-plugins in our monitoring targets.
On CentOS/RHEL/Scientifc Linux clients:
Add EPEL repository in your CentOS/RHEL/Scientific Linux 6.x or 7 clients to install nrpe package.
To install EPEL on CentOS 7, run the following command:
yum install epel-release
On CentOS 6.x systems, refer the following link.
Install “nrpe” and “nagios-plugins” packages in client systems:
yum install nrpe nagios-plugins-all openssl
On Debian/Ubuntu clients:
sudo apt-get update
sudo apt-get install nagios-nrpe-server nagios-plugins

Configure Monitoring targets

Edit /etc/nagios/nrpe.cfg file,
sudo nano /etc/nagios/nrpe.cfg
Add your Nagios server ip address:
[...]
## Find the following line and add the Nagios server IP ##
allowed_hosts=127.0.0.1 192.168.1.103
[...]
Start nrpe service on CentOS clients:
CentOS 7:
systemctl start nrpe
chkconfig nrpe on
CentOS 6.x:
service nrpe start
chkconfig nrpe on
For Debian/Ubuntu Clients, start nrpe service as shown below:
sudo /etc/init.d/nagios-nrpe-server restart
Now, go back to your Nagios server, and add the clients ( in the configuration file.
To do that, Edit “/usr/local/nagios/etc/nagios.cfg” file,
sudo nano /usr/local/nagios/etc/nagios.cfg
and uncomment the following lines.
## Find and uncomment the following line ##
cfg_dir=/usr/local/nagios/etc/servers
Create a directory called “servers” under “/usr/local/nagios/etc/”.
sudo mkdir /usr/local/nagios/etc/servers
Create config file to the monitoring target (client):
sudo nano /usr/local/nagios/etc/servers/clients.cfg
Add the following lines:
define host{

use                             linux-server

host_name                       server.unixmen.local

alias                           server

address                         192.168.1.104

max_check_attempts              5

check_period                    24x7

notification_interval           30

notification_period             24x7

}
Here, 192.168.1.104 is my nagios client IP address and server.unixmen.local is the client system’s hostname.
Finally, restart nagios service.
sudo /etc/init.d/nagios restart
Or
sudo service nagios restart
Wait for few seconds, and refresh nagios admin console in the browser and navigate to“Hosts” section in the left pane. Now, You will see the newly added client will be visible there. Click on the host to see if there is anything wrong or any alerts it has.
Nagios Core – Google Chrome_005
Click on the monitoring target (client system) to view the detailed output:
Nagios Core – Google Chrome_006
Similarly, you can define more clients by creating a separate config files“/usr/local/nagios/etc/servers”directory for each client.

Define services

We have just defined the monitoring host. Now, let us add some services of the monitoring host. For example, to monitor thessh service, add the following lines shown in bold in the“/usr/local/nagios/etc/servers/clients.cfg” file.
sudo nano /usr/local/nagios/etc/servers/clients.cfg
Add the following lines shown in bold:
define host{

use                             linux-server

host_name                       server.unixmen.local

alias                           server

address                         192.168.1.104

max_check_attempts              5

check_period                    24x7

notification_interval           30

notification_period             24x7

}

define service {
        use                             generic-service
        host_name                       server.unixmen.local
        service_description             SSH
        check_command                   check_ssh
        notifications_enabled           0
        }
Save and close the file. Restart Nagios.
sudo /etc/init.d/nagios restart
Or,
sudo service nagios restart
Wait for few seconds (90 seconds by default), and check for the added services (i.e ssh) in the nagios web interface. Navigate to Services section on the left side bar, you’ll see thessh service there.
Nagios Core – Google Chrome_007
To know more about object definitions such as Host definitions, service definitions, contact definitions, please visit here. This page will explain you the description and format of all object definitions.

Additional Tip:

If you’re trying to use check_http with the -S flag (for https), this guide misses a big step.
Make sure you install openssl and libssl-dev first. And yes, even if your Nagios server is checking a remote client, you need openssl and libssl-dev locally.
The when you get to configuring the Nagios plugins, add –with-openssl so you end up with:
./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl
That’s it. Cheers!


Referensi:
https://www.unixmen.com/how-to-install-nagios-core-4-1-1-in-ubuntu-15-10/