Configuration
Configuration is the most complex part of nagios. It involves the configuration of multiple files. For the sake of easy description, configuration is carried out one by one here.
1. Apache configuration
We complete this configuration in two steps. The first step is to modify the apache configuration file, the file path here is /usr/local/apache/conf/ . Change the run user [1] and run group of apache into nagios, and append the following line to the end of the file:
#setting for nagios ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin |
After the configuration is completed, execute/usr/local/apache/bin/apachctl –tCheck whether there are syntax errors in the apache configuration file, and use it after correct/usr/local/apache/bin/apachctl start &Start apache, and then enter the access address of nagios from the browser of another machine (such as:http://ip/nagios), If it is normal, the login verification window in the figure below will appear waiting for user input:
Enter the username and password created with htpasswd to test it. If there is no problem, proceed to the next configuration operation.
2. Nagios configuration
The directory of the configuration file for nagios that has just been installed is /usr/local/nagios/etc. The following figure is the file of its etc directory:
First change the name of these files, such as -sample to , and use the command cp -sample... to copy the remaining several *.cfg-samples into *.cfg files. Starting from nagios version 2.6, you can run it directly without modifying the configuration file../bin/nagios –v Verify whether the program can run normally (the minimum running configuration file of nagios 2.5 and previous versions is, but you need to modify this file many times to verify it successfully). Of course, we cannot expect this smallest configuration file to meet actual needs. Therefore, it is necessary to modify the existing configuration file, followed by adding some custom configuration files. Here, we will proceed in two steps: first modify the configuration file and then add custom files.
1. Modify the configuration file
The main configuration file of Nagios is, let's start modifying it from this file. Edit with vi, comment the line #cfg_file=/usr/local/nagios/etc/[2], and then remove the comments from the following lines:
cfg_file=/usr/local/nagios/etc/ //Contact group configuration file pathcfg_file=/usr/local/nagios/etc/ //Contact profile pathcfg_file=/usr/local/nagios/etc/ //Host group configuration file pathcfg_file=/usr/local/nagios/etc/ //Host configuration file pathcfg_file=/usr/local/nagios/etc/ //Service configuration file pathcfg_file=/usr/local/nagios/etc/ //Monitoring time period configuration file path |
The second configuration file to be modified is that its function is to control the relevant CGI scripts. Make sure use_authentication=1 first. I have read a lot of articles, and they all recommend setting the value of use_authentication to "0" to cancel the verification, which is a very bad idea. Next, modify default_user_name=sery, and the subsequent modifications are listed in the following table:
authorized_for_system_information=nagiosadmin,sery authorized_for_configuration_information=nagiosadmin,sery authorized_for_system_commands=sery //Separate multiple users with commasauthorized_for_all_services=nagiosadmin,sery authorized_for_all_hosts=nagiosadmin,sery authorized_for_all_service_commands=nagiosadmin,sery authorized_for_all_host_commands=nagiosadmin,sery |
The third configuration file modified is that the main function of this file is to send alarm text messages and alarm emails. The modifications to them are as follows:
#host-notify-by-sms //Send SMS Alarmdefine command { command_name host-notify-by-sms command_line /usr/local/bin/sms_send "Host $HOSTSTATE$ |