Nagios Installation and Configuration
Getting Nagios
You need root access on the server, where you
would like to install Nagios. Login as root.
Create a directory for downloads.
#mkdir -p /usr/src/backs/nagios #cd /usr/src/backs/nagios
#wget http://keihanna.dl.sourceforge.net/sourceforge /nagios/nagios-1.2.tar.gz #wget http://easynews.dl.sourceforge.net/sourceforge /nagiosplug/nagios-plugins-1.3.1.tar.gz
Compilation and installation of Nagios
Login as root and create a user, say “nagios”
#su #adduser nagios #passwd nagios Changing password for user nagios. New UNIX password: Retype new UNIX password: passwd: all authentication tokens updated successfully.
usermod -G mail nagios
mkdir -p /usr/src/works/nagios cd /usr/src/works/nagios/ tar -zxvf /usr/src/backs/nagios/nagios-1.2.tar.gz cd nagios-1.2/ ./configure The default is fine for normal operation. for details see the file 'INSTALL'. ./configure --prefix=prefix --with-cgiurl=cgiurl --with-htmurl=htmurl --with-nagios-user=someuser --with-nagios-grp=somegroup ./configure make all make install make install-init # Needed to add the service 'nagios'. make install-commandmode make install-config
cd ../ tar -zxvf /usr/src/backs/nagios/nagios-plugins-1.3.1.tar.gz cd nagios-plugins-1.3.1/ ./configure NOTE:- For mysql and postgresql plugins to work, their libraries have to be installed. so to avoid installing those we will use 'check_tcp' Instead later with seperate port for mysql and postgresql. make make check make install
If there is no contents do the following.
mkdir /usr/local/nagios/libexec mv /usr/lib/nagios/plugins/* /usr/local/nagios/libexec/ ln -s /lib/libcrypto.so.0.9.7a /lib/libcrypto.so.4
Post install Configuration of Nagios
vim /etc/httpd/conf/httpd.conf
Include /etc/httpd/conf/nagios.conf
vi /etc/httpd/conf/nagios.conf
————————————————-
ScriptAlias /nagios/cgi-bin/ /usr/local/nagios/sbin/
AllowOverride AuthConfig
Options ExecCGI
Allow from all
Order allow,deny
Alias /nagios/
/usr/local/nagios/share/
Options None
AllowOverride AuthConfig
Order allow,deny
Allow from all
————————————————–
Options None
AllowOverride AuthConfig
Order allow,deny
Allow from all
————————————————–
Make sure the updations done with http is fine
and restart apache.
#service httpd restart
#touch /usr/local/nagios/share/.htaccess #touch /usr/local/nagios/sbin/.htaccess
AuthName "Nagios Access" AuthType Basic AuthUserFile /usr/local/nagios/etc/htpasswd.users require valid-user
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin ls -l /usr/local/nagios/etc/htpasswd.users
chmod o+r /usr/local/nagios/etc/htpasswd.users
service httpd restart
Advanced Nagios Configurations.
cd /usr/local/nagios/etc/ for i in *sample ; do mv $i `echo "$i" |sed s/-sample//` ; done
check_external_commands=1
use_authentication=1 authorized_for_system_information=nagiosadmin authorized_for_configuration_information=nagiosadmin authorized_for_system_commands=nagiosadmin authorized_for_all_services=nagiosadmin authorized_for_all_hosts=nagiosadmin authorized_for_all_service_commands=nagiosadmin authorized_for_all_host_commands=nagiosadmin
Add servers that need to be monitored
Generic host definition template define host{ name generic-host notifications_enabled 1 event_handler_enabled 1 flap_detection_enabled 1 process_perf_data 1 retain_status_information 1 retain_nonstatus_information 1 register 0 } define host{ use generic-host ; Name of host template to use host_name alias address check_command check-host-alive max_check_attempts 10 notification_interval 120 notification_period 24x7 notification_options d,u,r }
Group them in hostgroups.cfg
define hostgroup{ hostgroup_name alias contact_groups members <,,..> }
Specify the services that need to be checked
Edit the details of all the services, we want
checked by Nagios in services.cfg.
Generic service definition template define service{ name generic-service active_checks_enabled 1 passive_checks_enabled 1 parallelize_check 1 obsess_over_service 1 check_freshness 0 notifications_enabled 1 event_handler_enabled 1 flap_detection_enabled 1 process_perf_data 1 retain_status_information 1 retain_nonstatus_information 1 register 0 } define service{ use generic-service host_name service_description is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 3 retry_check_interval 1 contact_groups to send> notification_interval 120 notification_period 24x7 notification_options w,u,c,r check_command }
Specify Alert Contacts
'nagios' contact definition define contact{ contact_name alias service_notification_period 24x7 host_notification_period 24x7 service_notification_options w,u,c,r host_notification_options d,u,r service_notification_commands notify-by-email,notify-by-epager host_notification_commands host-notify-by-email,host-notify-by-epager email pager }
Group the contacts
define contactgroup{ contactgroup_name alias members }
Escalation with nagios
define serviceescalation{ host_name service_description < name> first_notification 2 last_notification 6 contact_groups < groups (comma seperated)> notification_interval 0 }
service httpd restart
Add Nagios to system services.
chkconfig --add nagios service nagios restart
Enable nagios in runlevels, so that it starts on boot.
chkconfig nagios on
Create cron.daily entry if we want to restart the
service daily. Here is the script.
vi etc/cron.daily/nagios-restart.cron #!/bin/sh /sbin/service nagios restart >/dev/null 2>&1
chmod +x etc/cron.daily/nagios-restart.cron
http://NAGIOS-SERVER-NAME/nagios/index.html
No comments:
Post a Comment