Nagios Installation and Configuration Introduction Goals • Install and configure Nagios Notes • Commands preceded with “$” imply that you should execute the command as a general user - not as root. • Commands preceded with “#” imply that you should be working as root. • Commands with more specific command lines (e.g. “rtrX>” or “mysql>”) imply that you are executing commands on remote equipment, or within another program. ###Exercises### PART I 1.Click on the “Hosts” link on the left of the initial Nagios page to see what has already been configured. 2. Adding Remote Linux Host to Nagios Monitoring Server We will create two files;hosts.cfg and services.cfg To add a remote host you need to create a two new files “hosts.cfg” and “services.cfg” under “/usr/local/nagios/etc/” location. # cd /usr/local/nagios/etc/ # touch hosts.cfg # touch services.cfg Now add these two files to main Nagios configuration file. Open nagios.cfg file with any editor. # vi /usr/local/nagios/etc/nagios.cfg Now add the two newly created files as shown below. # You can specify individual object config files as shown below: cfg_file=/usr/local/nagios/etc/hosts.cfg cfg_file=/usr/local/nagios/etc/services.cfg Now open hosts.cfg file and add the default host template name and define remote hosts as shown below. Make sure to replace host_name, alias and address with your remote host server details. # vi /usr/local/nagios/etc/hosts.cfg ## Default Linux Host Template ## define host{ name linux-server ; Name of this template use generic-host ; Inherit default values hostgroups ssh-servers check_period 24x7 check_interval 5 retry_interval 1 max_check_attempts 10 check_command check-host-alive notification_period 24x7 notification_interval 30 notification_options d,r contact_groups admins register 0 ; DONT REGISTER THIS - ITS A TEMPLATE } ## Default define host{ use linux-server ; Inherit default values from a template host_name hostX.ws.nsrc.org ; The name we're giving to this server alias HostX ; A longer name for the server address 10.10.10.X ; IP address of Remote Linux host } Save the file and exit 3. Define hostgroup define hostgroup { hostgroup_name ssh-servers alias SSH servers members localhost,hostX.ws.nsrc.org } 4. Define services Next open services.cfg file add the following services to be monitored. >ssh, http, snmp # vi /usr/local/nagios/etc/services.cfg define service { hostgroup_name ssh-servers service_description SSH check_command check_ssh use generic-service notification_interval 0 ; set > 0 if you want to be renotified } define service{ use generic-service host_name hostX.ws.nsrc.org service_description Total Processes check_command check_total_procs } define service{ use generic-service host_name hostX.ws.nsrc.org service_description SNMP check_command check_snmp } define service{ use generic-service host_name hostX.nsrc.org service_description HTTP Monitoring check_command check_http } ............................ Optional: Now NRPE command definition needs to be created in commands.cfg file. [root@host24]# vi /usr/local/nagios/etc/objects/commands.cfg Add the following NRPE command definition at the bottom of the file. ############################################################################### # NRPE CHECK COMMAND # # Command to use NRPE to check remote host systems ############################################################################### define command{ command_name check_nrpe command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ } ....................... 5.Finally, verify Nagios Configuration files for any errors. [root@host24]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg Total Warnings: 0 Total Errors: 0 Restart Nagios: [root@host24]# service nagios restart That’s it. Now go to Nagios Monitoring Web interface at “http://hostX.ws.nsrc.org/nagios” and provide the username “nagiosadmin” and password “nagiospassword”. Check that the Remote Linux Host was added and is being monitored and the services are up as well. Success!!!