Using NAGIOS as monitoring system Pre requisites #yum install httpd #yum install gcc #yum install glibc glibc-common #yum install gd gd-devel #wget nagios version no .tar.gz if need plugin download #tar -zxvf nagios-ver.tar.gz nagios plugins #tar -zxvf nagiosplugin-ver.tar.gz Compile and install. #./configure --with-nagios-user=nagios --with-nagios-group=nagios #make #make install default istallation dir in /usr/local #mkdir /usr/local/nagios #adduser nagios # groupadd nagios # usermod -G nagios apache 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. /usr/sbin/groupadd nagcmd /usr/sbin/usermod -G nagcmd nagios /usr/sbin/usermod -G nagcmd apache #./configure or Run the Nagios configure script, passing the name of the group you created earlier like so: ./configure --with-command-group=nagcmd #make all #make install This will install the Nagios core and the command files. At this moment Nagios doesn’t have any script files from where it can take information about hosts and services. You must, therefore, create the configuration files. The easiest way is to install the sample config files by running the following command from your nagios-ver directory #make install-config or #make install-webconf for configure web interface Create a nagiosadmin account for logging into the Nagios web interface. Remember the password you assign to this account - you'll need it later.
22
Embed
Using NAGIOS as monitoring system Pre requisites · PDF fileUsing NAGIOS as monitoring system Pre requisites #yum install httpd #yum install gcc #yum install glibc glibc-common #yum
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Using NAGIOS as monitoring system Pre requisites #yum install httpd #yum install gcc #yum install glibc glibc-common #yum install gd gd-devel #wget nagios version no .tar.gz if need plugin download #tar -zxvf nagios-ver.tar.gz nagios plugins #tar -zxvf nagiosplugin-ver.tar.gz Compile and install. #./configure --with-nagios-user=nagios --with-nagios-group=nagios #make #make install default istallation dir in /usr/local #mkdir /usr/local/nagios #adduser nagios # groupadd nagios # usermod -G nagios apache 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. /usr/sbin/groupadd nagcmd /usr/sbin/usermod -G nagcmd nagios /usr/sbin/usermod -G nagcmd apache #./configure or Run the Nagios configure script, passing the name of the group you created earlier like so: ./configure --with-command-group=nagcmd #make all #make install This will install the Nagios core and the command files. At this moment Nagios doesn’t have any script files from where it can take information about hosts and services. You must, therefore, create the configuration files. The easiest way is to install the sample config files by running the following command from your nagios-ver directory #make install-config or #make install-webconf for configure web interface Create a nagiosadmin account for logging into the Nagios web interface. Remember the password you assign to this account - you'll need it later.
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin Go to /usr/local/nagios/etc directory and you’ll find all the sample configuration files. Rename them by removing the –sample at the end of each as follows. #mv filename.cfg-sample filename.cfg. or keep a copy #cp filename.cfg-sample filename.cfg NOTE:IF THIS FILES NOT CREATE USE LOCALHOST ENTRY FILE ,ADD THE IFORMATION INTO IT Adding hosts open the hosts.cfg file from /usr/local/nagios/etc directory and add the following to it. hosts.cfg define host{ host_name machine alias Server1 address 10.x.x.x check_command check-host-alive max_check_attempts 10 notification_interval 480 notification_period 24x7 notification_options d,u,r } hostgroups.cfg define hostgroup{ hostgroup_ name servergroup alias test contact_groups linuxadmins members admin1,admin2 } contacts.cfg define contact{ contact_name nagios alias Nagios Admin service_notification_period 24x7 host_notification_period 24x7 service_notification_ AdminSaj 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 email [email protected] }
contactgroups.cfg define contactgroup{ contactgroup_ name admins alias TESTADMIN Administrators members nagios, root } Configure Web interface To do this, first create an alias for the CGIs. By default, the Nagios configuration script searches for it in http://yourmachine/nagios/ cgi-bin/ directory. So, just add the following lines in your httpd.conf file. ScriptAlias /nagios/cgi-bin/ /usr/local/nagios/sbin/ <Directory “/usr/local/nagios/sbin/”> AllowOverride AuthConfig Options ExecCGI Allow from all Order allow,deny </Directory> Next create an alias for the html files by adding the following lines. Alias /nagios/ /usr/local/nagios/share/ <Directory “/usr/local/nagios/share”> Options None AllowOverride AuthConfig Order allow,deny Allow from all </Directory> services.cfg, define service{ host_name name server service_description PING is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups pcq-admins notification_interval 120 notification_period 24x7 notification_options w,u,c,r check_command check_ping! 100.0,20%! 500. 0,60% }
Here host_name is the name of the host on which the service will run, service_description is the description of the service and check_command contains the comands located in the /usr/local/nagios/libexec directory Start monitoring To start Nagios. Just restart the Web server and run the following command from /usr/local/nagios/bin directory. #./nagios ../etc/nagios.cfg #/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg #service httpd start Open Web browser and type the following address. “http://machine or ip nagios server/nagios/index.html” Installed directories [root@nagios]# find -name nagios ./downloads/nagios-3.0a4/base/nagios [root@nagios]# cd /usr/local/nagios/ [root@nagios]# ls bin etc libexec sbin share var [root@nagios]# cd bin [root@bin]# ls nagios nagiostats [root@ bin]# cd ../etc [root@ etc]# ls cgi.cfg contacts.cfg htpasswd.users nagios.cfg services.cfg commands.cfg hostgroups.cfg linux.cfg printer.cfg switch.cfg contactgroups.cfg hosts.cfg localhost.cfg resource.cfg windows.cfg [root@etc]# cd ../libexec/ [root@libexec]# ls check_apt check_file_age check_log check_overcr check_tcp check_breeze check_flexlm check_mailq check_ping check_time check_by_ssh check_ftp check_mrtg check_pop check_udp check_clamd check_http check_mrtgtraf check_procs check_ups check_dhcp check_icmp check_nagios check_real check_users check_dig check_ifoperstatus check_nntp check_rpc check_wave check_disk check_ifstatus check_nt check_sensors negate check_disk_smb check_imap check_ntp check_smtp urlize check_dns check_ircd check_nwstat check_ssh utils.pm check_dummy check_load check_oracle check_swap utils.sh [root@domU-12-31-37-00-03-3F libexec]# cd ../sbin/ [root@sbin]# ls avail.cgi config.cgi history.cgi outages.cgi status.cgi statuswrl.cgi tac.cgi cmd.cgi extinfo.cgi notifications.cgi showlog.cgi statuswml.cgi summary.cgi [root@sbin]# cd ../share/
[root@share]# ls contexthelp docs images index.html locale main.html media robots.txt side.html ssi stylesheets [root@share]# cd ../var/ [root@var]# ls archives nagios.lock nagios.log objects.cache retention.dat rw spool status.dat [root@var]# vi /etc/htpasswd.users nagiosadmin:tFf5HDMnL.EKM Note:There was a problem when I start nagios as the user in nagios.cfg ,so I edited with root.And also give user “nagios” permissions to wite logfiles (nagios.lock, nagios.log, retention.dat)and libexec Edit Nagios.cfg # NAGIOS USER # This determines the effective user that Nagios should run as. # You can either supply a username or a UID. #nagios_user=nagios nagios_user=root # NAGIOS GROUP # This determines the effective group that Nagios should run as. # You can either supply a group name or a GID. #nagios_group=nagios nagios_group=root Need to give permissions cgi.cfg, when you creating users with .htpasswod Edit cgi.cfg # SYSTEM/PROCESS INFORMATION ACCESS # This option is a comma-delimited list of all usernames that # have access to viewing the Nagios process information as # provided by the Extended Information CGI (extinfo.cgi). By # default, *no one* has access to this unless you choose to # not use authorization. You may use an asterisk (*) to # authorize any user who has authenticated to the web server. authorized_for_system_information=nagiosadmin,user1 # CONFIGURATION INFORMATION ACCESS # This option is a comma-delimited list of all usernames that # can view ALL configuration information (hosts, commands, etc). # By default, users can only view configuration information # for the hosts and services they are contacts for. You may use # an asterisk (*) to authorize any user who has authenticated # to the web server. authorized_for_configuration_information=nagiosadmin # SYSTEM/PROCESS COMMAND ACCESS # This option is a comma-delimited list of all usernames that # can issue shutdown and restart commands to Nagios via the
# command CGI (cmd.cgi). Users in this list can also change # the program mode to active or standby. By default, *no one* # has access to this unless you choose to not use authorization. # You may use an asterisk (*) to authorize any user who has # authenticated to the web server. authorized_for_system_commands=nagiosadmin # GLOBAL HOST/SERVICE VIEW ACCESS # These two options are comma-delimited lists of all usernames that # can view information for all hosts and services that are being # monitored. By default, users can only view information # for hosts or services that they are contacts for (unless you # you choose to not use authorization). You may use an asterisk (*) # to authorize any user who has authenticated to the web server. authorized_for_all_services=nagiosadmin,user1 authorized_for_all_hosts=nagiosadmin,user1 # GLOBAL HOST/SERVICE COMMAND ACCESS # These two options are comma-delimited lists of all usernames that # can issue host or service related commands via the command # CGI (cmd.cgi) for all hosts and services that are being monitored. # By default, users can only issue commands for hosts or services # that they are contacts for (unless you you choose to not use # authorization). You may use an asterisk (*) to authorize any # user who has authenticated to the web server. authorized_for_all_service_commands=nagiosadmin authorized_for_all_host_commands=nagiosadmin In my nagios configuration I used ssh to collect data from other hosts. So my customizations are Hosts .cfg file #############################################################################
Nagios plugins in remote hosts Create a new nagios user account and give it a password /usr/sbin/useradd nagios passwd nagios
Install the Nagios Plugins Create a directory for storing the downloads. mkdir ~/downloads cd ~/downloads
Download the source code tarball of the Nagios plugins (visit http://www.nagios.org/download/ for links to
the versions 1.4.9). Extract the Nagios plugins source code tarball. tar xzf nagios-plugins-1.4.9.tar.gz cd nagios-plugins-1.4.9
Compile and install the plugins. ./configure make make install
The permissions on the plugin directory and the plugins will need to be fixed at this point, so run the following commands. chown nagios.nagios /usr/local/nagios chown -R nagios.nagios /usr/local/nagios/libexec copy the check_mem file and give permissions copy the check_mem file to /usr/local/nagios/libexec chown nagios:nagios check_mem chmod 755 check_mem 7. copy the check_cpu file and give permissions copy the check_cpu file to /usr/local/nagios/libexec chown nagios:nagios check_cpu chmod 755 check_cpu 8.After remove downloads folder from machine Rm –rf ~/downloads
Open Web browser and type the following address. http://Netmon server/nagios/index.html