This post will cover step by step Nagios installation.
In current world everything is available online, every organization is trying to reduce their downtime. Almost all Data Centers are running hundreds of services. It is not possible for human being to monitor all services, this is where Nagios is useful. Administrator can use Nagios to monitor all hosts, services, network devices.
Nagios can be configured to check critical services on different time intervals. And can be used to send Email alerts to system admins.
Here I will cover installation, host & service configuration, service details, & upgradation.
Installation
Download Nagios & Nagios-plugins from http://www.nagios.org/download/
assuming you have stored source packages in /downloads/
(I prefer to use /tmp/ for package installation)
cd /tmp tar zxvf /downloads/nagios-3.0.6.tar.gz cd nagios-3.0.6/ ./configure make all #nagios user useradd nagios #installs the main program, CGIs, and HTML files make install #installs init script in /etc/rc.d/init.d make install-init #installs and configures permissions on the directory for holding the external command file make install-commandmode #installs SAMPLE config files in /usr/local/nagios/etc make install-config #installs the Apache config file for the Nagios web interface make install-webconf |
#for Nagios web authentication. htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin |
This was all required to start Nagios server.
service nagios restart service httpd restart |
Install nagios-plugins
cd /tmp tar zxvf /downloads/nagios-plugins-1.4.13.tar.gz cd nagios-plugins-1.4.13/ ./configure --libexecdir=/usr/local/nagios/libexec/ make all make install |
This was all required to start Nagios server with limited available plugins.
By default during installation localhost is configured with few services.
You can access Nagios using http://nagios_server_ip/nagios (it will prompt you for authentication, use nagiosadmin as user & password you entered while creating htpasswd.users).
Nagios panel will display only localhost, if you can see status of localhost you can continue adding hosts & services.
Basic Configuration
To add more hosts.
I recommend to create separate host files in /usr/local/nagios/etc/objects/ e.g linux.cfg, windows.cfg, router.cfg etc. If you are planning to put all your services to monitor, you can segregate configuration files as per requirement. It helps to easily search & modify configuration whenever required.
You need to mention created .cfg files in /usr/local/nagios/etc/nagios.conf e.g cfg_file=/usr/local/nagios/etc/objects/linux.cfg This will guide Nagios to load manually created configuration files.
cd /usr/local/nagios/etc/objects
Followings is the contains of sample linux.cfg file.
#Linux define host{ use generic-host ; Name of host template to use host_name Linux alias Linux address 192.168.1.12 check_command check-host-alive max_check_attempts 10 check_period 24x7 notification_interval 120 notification_period 24x7 notification_options d,r contact_groups admins } #ping define service{ use generic-service ; Name of service template to use host_name Linux service_description PING is_volatile 0 check_period 24x7 max_check_attempts 4 normal_check_interval 5 retry_check_interval 1 contact_groups admins notification_options w,u,c,r notification_interval 960 notification_period 24x7 check_command check_ping!100.0,20%!500.0,60% } #http define service{ use generic-service ; Name of service template to use host_name Linux service_description HTTP is_volatile 0 check_period 24x7 max_check_attempts 4 normal_check_interval 5 retry_check_interval 1 contact_groups admins notification_options w,u,c,r notification_interval 960 notification_period 24x7 check_command check_http } #smtp define service{ use generic-service ; Name of service template to use host_name Linux service_description SMTP is_volatile 0 check_period 24x7 max_check_attempts 4 normal_check_interval 5 retry_check_interval 1 contact_groups admins notification_options w,u,c,r notification_interval 960 notification_period 24x7 check_command check_smtp } |
/usr/local/nagios/bin/nagios -v ../nagios.cfg #to check nagios configuration service nagios reload |
Click for service related details. Refer to section Service Definition
I have added Linux host in hostgroup available in localhost.cfg
Recommended way is to create separate groups.cfg.
Now you should be able to see Linux (host) on nagios panel.
To add more timeperiods & contacts you can refer to default config of timeperiods.cfg & contacts.cfg respectively.
Upgradation
tar zxvf /downloads/nagios-3.4.0.tar.gz cd nagios ./configure && make all make install make install-init make install-commandmode service nagios restart |

Pingback: Monitor your Blog / Web | LinuxReaders