Nagios is a powerful monitoring system that enables organizations to identify and resolve IT infrastructure problems before they affect critical business processes.
Another incredible capability of Nagios is that it can monitor both hosts and services e.g., it can monitor IP addresses and TCP/UDP port numbers. To explain a little, let us assume that there is a web server that we want to monitor. Nagios can check whether the server is online by running ping on the IP/name of the server as well as it can be set up to provide warnings in case the round trip time (RTT) to the server increases. Further, Nagios can also check whether TCP port 80 (web server) is reachable e.g., the server is online but Apache/IIS is not responding.
Nagios Features can you
click here
Installing Package
root@cyber:~# apt-get install nagios3
Set password for user "nagiosadmin" and press enter
Confirmation password for user "nagiosadmin"
Adding Host Template
The templates defining what to do with a type host is defined. We use the files provided with the installation as sample.
First, define a host template for Linux devices
root@cyber:~# cd /etc/nagios3/conf.d/
root@cyber:/etc/nagios3/conf.d# cp generic-host_nagios2.cfg linux-server.cfg
Edit linux-server.cfg as follows. The parts with bold font are modified.
root@cyber:/etc/nagios3/conf.d# nano linux-server.cfg
define host{
name linux-server
notifications_enabled 1
event_handler_enabled 1
flap_detection_enabled 1
failure_prediction_enabled 1
process_perf_data 1
retain_status_information 1
retain_nonstatus_information 1
check_command example-host-check ; the script to be used while checkingcheck_interval 3 ; the interval between consecutive checksmax_check_attempts 3 ; number of rechecking before generating email alertsnotification_interval 0
notification_period 24x7
notification_options d,u,r
contact_groups admins ; the group where emails will be sentregister 0
}
Adding Host
Now that the host template is defined, the actual host to be monitored is added. Again, the files provided by default are used as sample.
root@cyber:/etc/nagios3/conf.d# cp localhost_nagios2.cfg example.cfg
root@cyber:/etc/nagios3/conf.d# nano example.cfg
# Host 1
define host{
use linux-server ; Name of host template to use
host_name our-server ; The hostname to be used by nagios
alias our-server
address 10.10.101.23 ; The IP address of the host
}
Host Group Definition
For ease of management when there are multiple hosts, it is advisable that hosts of similar types are grouped together
root@cyber:/etc/nagios3/conf.d# nano hostgroups_nagios2.cfg
definehostgroup {
hostgroup_name linux-server ; the name of the host group
alias Linux Servers
members our-server ; comma separated list of members
}
Service Definition
First, the command example-host-check is defined with warning value of 100 ms for latency and 20% for packet loss. Critical values are 5000 ms for latency and 100% packet loss. One IPv4 ping request is transmitted.
root@cyber:~# nano /etc/nagios-plugins/config/ping.cfg
define command{
command_name example-host-check
command_line /usr/lib/nagios/plugins/check_ping -H '$HOSTADDRESS$' -w 100,20% -c 5000,100% -p 1 -4
}
Then, the command is associated with host groups.
root@cyber:/etc/nagios3/conf.d/# nano services_nagios2.cfg
define service {
hostgroup_name linux-server
service_description Linux Servers
check_command example-host-check
use generic-service
notification_interval 0 ; set > 0 if you want to be renotified
}
Contact Definition
The required address for sending email added to Nagios.
root@cyber:/etc/nagios3/conf.d/# nano contacts_nagios2.cfg
define contact{
contact_name root
alias Root
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,r
service_notification_commands notify-service-by-email
host_notification_commands notify-host-by-email
email root@localhost, sys@mikrolink.net
}
Finally, a dry run is initiated to check whether there are any configuration errors. If there are no errors, Nagios can be (re)started safely.
root@cyber:~# nagios –v /etc/nagios3/nagios.cfg
root@cyber:~# service nagios3 restart
Access Nagios after Configuration
Now you are ready to use Nagios.
Nagios can be accessed by opening the URL http://IP/nagios3 in case of Ubuntu/Debian.
e.g. http://10.10.101.23/nagios3
The user "nagiosadmin" needs to be authenticated to access the page.