Basic operations for running Nagios 7.1. Verifying the correctness of the configuration file
Each time you modify your profile, you should run a detection program to verify the correctness of the configuration. This is important before running your Nagios program, otherwise it will cause the Nagios service to shut down due to misconfiguration.
To verify your configuration, run Nagios with command-line arguments-V, like this:
/usr/local/nagios/bin/nagios-v/usr/local/nagios/etc/nagios.cfg
If you do forget some important data or incorrectly configured, Nagios will give you an alarm or an error message, which will give you the wrong location. The error message usually prints out the line in the misconfigured file. In the case of an error, Nagios is usually back to the command line state by pre-checking out the source profile line that has the problem printing out the problem. This allows Nagios to not fall into an error and need to verify a configuration looping error that is nested due to an error. Alarm information can often be ignored because it is not necessary to be a general recommendation.
Once you have verified your profile and modified your error, you can go ahead and start or restart the Nagios service.
7.2. Start and stop Nagios
There are more than one way to start, stop, and restart Nagios, where there are more usual ways to do ...
Tips
650) this.width=650; "src=" Http://192.168.1.254/pub/images/tip.gif "alt=" Tip.gif "/>
Before you start or restart your Nagios program, you always have to make sure that you verify that your configuration file has passed.
7.2.1. Starting Nagios
-
Init script: The simplest way to start the Nagios daemon is to use an initialization script like this:
/etc/rc.d/init.d/nagios start
-
Manual mode: You can manually start the Nagios daemon, with the command parameter-D, like this:
/usr/local/nagios/bin/nagios-d/usr/local/nagios/etc/nagios.cfg
7.2.2. Restarting Nagios
When you modify the configuration file and want it to take effect, it is necessary to restart or reload the action.
-
Init script: The simplest way to restart the Nagios daemon is to use an initialization script like this:
/etc/rc.d/init.d/nagios Reload
-
Web interface mode: You can use the Web interface, click on the "Process Information" hyperlink page "Restart Nagios process" to restart Nagios, see figure
650) this.width=650; "src=" Http://192.168.1.254/pub/images/stoprestart.png "alt=" Stoprestart.png "/>
-
Manual way: You can manually send a sighup signal, like this:
Kill-hup <nagios_pid>
7.2.3. Stop Nagios
-
Init script: The easiest way to stop the Nagios daemon is by initializing the script, like so:
/etc/rc.d/init.d/nagios stop
-
Web interface mode: You can use the Web interface, by clicking on the "Process Information" Hyperlink page "Close Nagios process" to stop Nagios, see figure
650) this.width=650; "src=" Http://192.168.1.254/pub/images/stoprestart.png "alt=" Stoprestart.png "/>
-
Manual mode: You can manually send a sigterm signal, like this:
Kill <nagios_pid>
7.3. Quick Start Option 7.3.1. Introduced
Only a few things can reduce the total time that Nagios starts or restarts. Accelerated startup methods include removing some of the burden and speeding up the profile process.
These techniques are particularly effective when used in one or more of the following situations:
-
Large installation Configuration
-
Complex configuration (excessive use of template properties)
-
installation mode where frequent reboots are required
7.3.2. Background
Each time Nagios starts and restarts, the configuration file must be processed before it begins to perform the monitoring work. Configuration processing during startup consists of the following steps:
-
Read in configuration file
-
Parsing template Definitions
-
Heavy adhesions ("Recombobulating") objects (which I think should do all kinds of work)
-
Copying object definitions
-
Inheriting object properties
-
Object definition Ordering
-
Verifying the integrity of an object's association relationship
-
Verification Loop
-
and other ...
There are a few steps that are very time-consuming when there are large or complex configuration files to process. Is there any way to speed up these? Of course!
7.3.3. Evaluating Start-up times
Before doing something that makes the startup faster, you need to look at how likely it is and whether it's necessary to get involved. This is easier-just start nagios with the-s command-line switch to get timing and scheduling information.
Here is an example of the output (done with the refinement, just showing the relevant section), in this example, it is assumed that Nagios is configured to monitor 25 hosts and more than 10,000 services.
/usr/local/nagios/bin/nagios-s/usr/local/nagios/etc/nagios.cfgnagios 3.0-prealphacopyright (c) 1999-2007 Ethan Galstad (http://www.nagios.org) Last modified:01-27-2007license:gpltiming information on object configuration Processing is listedbelow. you can use this information to see if precaching yourobject configuration would is useful. Object config source:config files (uncached) object config processing times (* = potential for Precach E savings with-u option)----------------------------------Read: 0 .486780 secresolve: 0.004106 sec *recomb contactgroups:0.000077 sec *recomb hostgroups: 0.000172 sec *dup Services: 0.028801 sec * Recomb servicegroups:0.010358 sec *duplicate: 5.666932 sec *inherit: 0.003770 sec *recomb Contacts: 0.030085 sec *sort: &NBS P 2.648863 sec *register: 2.654628 secfree: &NBS P 0.021347 sec &NBS P ============total: 11.555925 sec * = 8.393170 sec (72.6 3%) Estimated savingstiming information on the configuration verification is listed below. CONFIG Verification times (* = potential for speedup with-x option)-------------------- --------------Object relationships:1.400807 seccircular Paths: 54.676622 sec *misc: &NB Sp 0.006924 sec &NBS P ============total: &NBSP; 56.084353 sec * = 54.676622 sec (97.5%) estimated savings
OK, see what's going on. Look at the summary information first, about 11.6 seconds to process the configuration file has 56 seconds to verify the configuration. This means that every time you start or restart Nagios with this configuration, it will take about 68 seconds to start up and not do anything to monitor! It is also not tolerated in the custom configuration Nagios process.
So what? Looking at the output, Nagios will be able to save about 8.4 seconds in the configuration read process and save 63 seconds in the validation process if the optimization option is used.
Wow! From 68 seconds to only 5 seconds?! Yes! See how the following is done.
7.3.4. Pre-Cached object configuration
Nagios can speed up the parsing of configuration files, especially when templates are used in configuration for inheritance. To reduce the processing time of Nagios parsing profiles, you can use the capabilities of Nagios to preprocess and pre-cache configuration files.
When you run Nagios with the-P command parameter, Nagios reads the configuration file and writes the configuration results to the pre-cache file (the file location specified by the Precached_object_file domain in the master configuration file). The pre-cache profile will contain pre-processing information that will make Nagios processing the configuration file easier and faster. You must use the-P parameter option with the-V or-s command parameter, as in the following example. Note Before you make the pre-cache configuration file, the configuration should be validated.
/usr/local/nagios/bin/nagios-pv/usr/local/nagios/etc/nagios.cfg
The pre-cache profile size is significantly larger than the original configuration file. This is normal and is determined by the design intent.
650) this.width=650; "src=" Http://192.168.1.254/pub/images/fast-startup1.png "alt=" Fast-startup1.png "/>
Once the pre-cache object profile is created, you can start nagios with the-u command-line option to let it use the pre-cached configuration file instead of the profile itself.
/usr/local/nagios/bin/nagios-ud/usr/local/nagios/etc/nagios.cfg
Important
650) this.width=650; "src=" Http://192.168.1.254/pub/images/important.gif "alt=" Important.gif "/>
If you change the configuration file, you must re-validate and rebuild the pre-cache configuration file before Nagios restarts. If you do not rebuild the pre-cached profile, Nagios will run with the old configuration because it is a pre-cached file generated by the old configuration, not with the new original configuration file.
650) this.width=650; "src=" Http://192.168.1.254/pub/images/fast-startup2.png "alt=" Fast-startup2.png "/>
7.3.5. Skip Loop detection
The second (and most time consuming) part is detecting the loops in the configuration. In the example above, this step took almost 1 minutes to verify the configuration validation.
What is the time of loop detection and why does it take so long? The Loop detection logic is designed to ensure that there are no looping paths between objects such as your host, host dependencies, services, and service dependencies. If there is a loop path in the configuration, Nagios will stop because of a deadlock. The longer time is due to the absence of more efficient algorithms. You are welcome to provide algorithms for more efficient discovery loops. Tip: This means that email to me will give me a chance to get some rebate code for the computer science graduate of Nagios's thesis. :-)
If you want to skip loop detection at Nagios for startup, you can add the-x parameter to the command line, like this:
/usr/local/nagios/bin/nagios-xd/usr/local/nagios/etc/nagios.cfg
Important
650) this.width=650; "src=" Http://192.168.1.254/pub/images/important.gif "alt=" Important.gif "/>
Verifying the correctness of the configuration file is very important when you want to skip loop detection before starting and restarting. Failure to do so would have the potential to cause a deadlock on the Nagios logic. You have been reminded of me!
7.3.6. Unite to use
Follow the steps below to use the pre-cache configuration file and skip loop detection to fully accelerate the boot.
1. Verify the configuration file and generate the pre-cache configuration file with the following command:
/usr/local/nagios/bin/nagios-vp/usr/local/nagios/etc/nagios.cfg
2. If Nagios is running, stop it;
3. Start Nagios to use the pre-cache configuration file and skip loop detection:
/usr/local/nagios/bin/nagios-uxd/usr/local/nagios/etc/nagios.cfg
4. When the original profile is changed, you need to restart Nagios and modify the existing content, and go back to step 1 to verify the configuration and refactor the pre-cache configuration file. Once done, you can restart Nagios via the Web interface or send a SIGHUP signal in the system, and if you do not refactor the pre-cache configuration file, Nagios will run with the old configuration because it will first read the cache configuration file instead of the source configuration file;
5, so much! Wish you can speed up the start-up process.
This article is from "Moonlight Blast" blog, please be sure to keep this source http://skykws8023.blog.51cto.com/4514277/1581633
Basic operations for running Nagios-Quick Launch options