~ubuntu-branches/ubuntu/trusty/nagios3/trusty

« back to all changes in this revision

Viewing changes to html/docs/faststartup.html

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Wirt
  • Date: 2009-08-16 14:14:23 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20090816141423-efjzq1r3jekwd7l7
Tags: 3.2.0-1
* New upstream release (Closes: #542957)
  - Timeperiods should work as expected now (Closes: #539882)
  - Recovery notifications fixed (Closes: #543657)
* Update standards version 
  - Add README.source
* Manpage errors fixed (Closes: #540554)
* Split up the webfrontend into its own package (Closes: #479338, #485466)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2
 
 
3
 
<html>
4
 
<head>
5
 
<title>Fast Startup Options</title>
6
 
 
7
 
<STYLE type="text/css">
8
 
<!--
9
 
        .Default { font-family: verdana,arial,serif; font-size: 8pt; }
10
 
        .PageTitle { font-family: verdana,arial,serif; font-size: 16pt; font-weight: bold; }
11
 
-->      
12
 
</STYLE>
13
 
 
14
 
</head>
15
 
 
16
 
<body bgcolor="#FFFFFF" text="black" class="Default">
17
 
 
18
 
<div align="center">
19
 
<img src="images/nagios.jpg" border="0" alt="Nagios" title="Nagios">
20
 
<h1 class="PageTitle">Fast Startup Options</h1>
21
 
</div>
22
 
 
23
 
<hr>
24
 
 
25
 
<p>
26
 
<img src="images/upto.gif" border="0" align="middle" alt="Up To" title="Up To">Up To: <a href="toc.html">Contents</a><br>
27
 
<img src="images/seealso.gif" border="0" align="middle" alt="See Also" title="See Also"> See Also: <a href="tuning.html">Performance Tuning</a>, <a href="largeinstalltweaks.html">Large Installation Tweaks</a>
28
 
</p>
29
 
 
30
 
<p>
31
 
<strong><u>Introduction</u></strong>
32
 
</p>
33
 
 
34
 
<p>
35
 
There are a few things you can do that can decrease the amount of time it take Nagios to startup (or restart).  These speedups involve easing some of the burden involved in processing your configuration files.
36
 
</p>
37
 
 
38
 
<p>
39
 
Using these techniques is particularly useful when you have one or more of the following:
40
 
</p>
41
 
 
42
 
<ul>
43
 
<li>Large configurations</li>
44
 
<li>Complex configurations (heavy use of template features)</li>
45
 
<li>Installations where frequest restarts are necessary</li>
46
 
</ul>
47
 
 
48
 
<p>
49
 
<strong><u>Background</u></strong>
50
 
</p>
51
 
 
52
 
<p>
53
 
Whenever Nagios starts/restarts it has to process your configuration files before it can get down to the business of monitoring.  This configuration startup process involves a number of steps:
54
 
</p>
55
 
 
56
 
<ul>
57
 
<li>Reading the config files</li>
58
 
<li>Resolving template definitions</li>
59
 
<li>"Recombobulating" your objects (my term for the various types of work that occurs)</li>
60
 
<li>Duplicating object definitions</li>
61
 
<li>Inheriting object properties</li>
62
 
<li>Sorting your object definitions</li>
63
 
<li>Verifying object relationship integrity</li>
64
 
<li>Checking for circular paths</li>
65
 
<li>and more...</li>
66
 
</ul>
67
 
 
68
 
<p>
69
 
Some of these steps can be quite time-consuming when you have large or complex configurations.  Is there a way to speed any of these steps up?  Yes!
70
 
</p>
71
 
 
72
 
<p>
73
 
<strong><u>Evaluating Startup Times</u></strong>
74
 
</p>
75
 
 
76
 
<p>
77
 
Before we get on to making things faster, we need to see what's possible and whether or not we should even bother with the whole thing.  This is easy to do - simply start nagios with the <b>-s</b> command line switch to get timing and scheduling information.
78
 
</p>
79
 
 
80
 
<p>
81
 
An example of the output (abbreviated to only show relevant portions) is shown below. For this example, I'm using a Nagios config that has 25 hosts defined and just over 10,000 services.
82
 
</p>
83
 
 
84
 
<pre style="padding: 0 0 0 50px;">
85
 
/usr/local/nagios/bin/nagios -s /usr/local/nagios/etc/nagios.cfg
86
 
 
87
 
Nagios 3.0-prealpha
88
 
Copyright (c) 1999-2007 Ethan Galstad (http://www.nagios.org)
89
 
Last Modified: 01-27-2007
90
 
License: GPL
91
 
 
92
 
Timing information on object configuration processing is listed
93
 
below.  You can use this information to see if precaching your
94
 
object configuration would be useful.
95
 
 
96
 
Object Config Source: Config files (uncached)
97
 
 
98
 
OBJECT CONFIG PROCESSING TIMES      (* = Potential for precache savings with -u option)
99
 
----------------------------------
100
 
Read:                 0.486780 sec
101
 
Resolve:              0.004106 sec  *
102
 
Recomb Contactgroups: 0.000077 sec  *
103
 
Recomb Hostgroups:    0.000172 sec  *
104
 
Dup Services:         0.028801 sec  *
105
 
Recomb Servicegroups: 0.010358 sec  *
106
 
Duplicate:            5.666932 sec  *
107
 
Inherit:              0.003770 sec  *
108
 
Recomb Contacts:      0.030085 sec  *
109
 
Sort:                 2.648863 sec  *
110
 
Register:             2.654628 sec
111
 
Free:                 0.021347 sec
112
 
                      ============
113
 
TOTAL:                11.555925 sec  * = 8.393170 sec (72.63%) estimated savings
114
 
 
115
 
 
116
 
Timing information on configuration verification is listed below.
117
 
 
118
 
CONFIG VERIFICATION TIMES          (* = Potential for speedup with -x option)
119
 
----------------------------------
120
 
Object Relationships: 1.400807 sec
121
 
Circular Paths:       54.676622 sec  *
122
 
Misc:                 0.006924 sec
123
 
                      ============
124
 
TOTAL:                56.084353 sec  * = 54.676622 sec (97.5%) estimated savings
125
 
</pre>
126
 
 
127
 
<p>
128
 
Okay, lets see what happened.  Looking at the totals, it took roughly <b>11.6</b> seconds to process the configuration files and another <b>56</b> seconds to verify the config.  That means that every time I start or restart Nagios with this configuration, it will take nearly <b>68 seconds</b> of startup work before it can monitor anything!  That's not acceptable if I have to restart Nagios on a semi-regular basis.
129
 
</p>
130
 
 
131
 
<p>
132
 
What can I do about this?  Take another look at the output and you'll see that Nagios estimates that I could save about <b>8.4</b> seconds off the configuration processing time and another <b>54.7</b> off the verification times.  In total, Nagios thinks I could save <b>63 seconds</b> of the normal startup time if some optimizations were taken.
133
 
</p>
134
 
 
135
 
<p>
136
 
Whoa!  From <b>68 seconds</b> to just <b>5 seconds</b>?  Yep, read on for how to do it.
137
 
</p>
138
 
 
139
 
 
140
 
 
141
 
<p>
142
 
<strong><u>Pre-Caching Object Configuration</u></strong>
143
 
</p>
144
 
 
145
 
<p>
146
 
Nagios can spend quite a bit of time parsing your config files, especially if you make use of the template features such as inheritance, etc.  In order to reduce the time it takes to parse your config, you can have Nagios pre-process and pre-cache your config files for future use.  
147
 
</p>
148
 
 
149
 
<table border="0" class="Default">
150
 
<tr>
151
 
<td valign="top">
152
 
<p>
153
 
When you run nagios with the <b>-p</b> command line option, Nagios will read your config files in, process them, and save them to a pre-cached object config file (specified by the <a href="configmain.html#precached_object_file">precached_object_file</a> directive).  This pre-cached config file will contain pre-processed configuration entries that are easier/faster for Nagios to process in the future.
154
 
</p>
155
 
 
156
 
<p>
157
 
You must use the <b>-p</b> command line option along with either the <b>-v</b> or <b>-s</b> command line options, as shown below.  This ensures that your configuration is verified before the precached file is created.
158
 
</p>
159
 
 
160
 
<pre style="padding: 0 0 0 50px;">
161
 
/usr/local/nagios/bin/nagios -pv /usr/local/nagios/etc/nagios.cfg
162
 
</pre>
163
 
 
164
 
<p>
165
 
The size of your precached config file will most likely be significantly larger than the sum of the sizes of your object config files.  This is normal and by design.
166
 
</p>
167
 
</td>
168
 
<td valign="top">
169
 
<div style="float: right; clear: right; padding: 0 0 25px 25px;">
170
 
<img src="images/fast-startup1.png" alt="Pre-Caching Object Config Files" title="Pre-Caching Object Config Files" border="0">
171
 
</div>
172
 
</td>
173
 
</tr>
174
 
 
175
 
<tr>
176
 
<td valign="top">
177
 
<p>
178
 
Once the precached object configuration file have been created, you can start Nagios and tell it to use the precached config file instead of your object config file(s) by using the <b>-u</b> command line option.
179
 
</p>
180
 
 
181
 
<pre style="padding: 0 0 0 50px;">
182
 
/usr/local/nagios/bin/nagios -ud /usr/local/nagios/etc/nagios.cfg
183
 
</pre>
184
 
 
185
 
<p><img src="images/important.gif" border="0" align="bottom" alt="Important" title="Important"> If you modify your configuration files, you will need to re-verify and re-cache your configuration files before restarting Nagios.  If you don't re-generate the precached object file, Nagios will continue to use your old configuration because it is now reading from the precached file, rather than your source configuration files.
186
 
</p>
187
 
 
188
 
</td>
189
 
<td valign="top">
190
 
<div style="float: right; padding: 0 0 0 25px;">
191
 
<img src="images/fast-startup2.png" alt="Pre-Caching Object Config Files" title="Pre-Caching Object Config Files" border="0">
192
 
</div>
193
 
</td>
194
 
</tr>
195
 
</table>
196
 
 
197
 
<p>
198
 
<strong><u>Skipping Circular Path Tests</u></strong>
199
 
</p>
200
 
 
201
 
<p>
202
 
The second (and most time-intensive) portion of the configuration startup phase is the circular path check.  In the example above, it took nearly a minute to perform this step of the configuration verification.
203
 
</p>
204
 
 
205
 
<p>
206
 
What is the circular path check and why does it take so long?  The circular patch check is designed to ensure that you don't define any circular paths in your host, host dependency, or service dependency definitions.  If a circular path existed in your config files, Nagios could end up in a deadlock situation.  The most likely reason for the check taking so long is that I'm not using an efficient algorithm.  A much more efficient algorithm for detecting circular paths would be most welcomed.  Hint:  That means all you CompSci graduate students who have been emailing me about doing your thesis on Nagios can contribute some code back. :-)
207
 
</p>
208
 
 
209
 
<p>
210
 
If you want to skip the circular path check when Nagios starts, you can add the -x command line option like this:
211
 
</p>
212
 
 
213
 
<pre style="padding: 0 0 0 50px;">
214
 
/usr/local/nagios/bin/nagios -xd /usr/local/nagios/etc/nagios.cfg
215
 
</pre>
216
 
 
217
 
<p><img src="images/important.gif" border="0" align="bottom" alt="Important" title="Important"> It is of utmost importance that you verify your configuration before starting/restarting Nagios when skipping circular path checks.  Failure to do so could lead to deadlocks in the Nagios logic.  You have been warned.
218
 
</p>
219
 
 
220
 
<p>
221
 
<strong><u>Putting It All Together</u></strong>
222
 
</p>
223
 
 
224
 
<p>
225
 
Follow these steps if you want to make use of potential speedups from pre-caching your configuration and skipping circular path checks.
226
 
</p>
227
 
 
228
 
<p>
229
 
1. Verify your configuration and create the precache file with the following command:
230
 
</p>
231
 
 
232
 
<pre style="padding: 0 0 0 50px;">
233
 
/usr/local/nagios/bin/nagios -vp /usr/local/nagios/etc/nagios.cfg
234
 
</pre>
235
 
 
236
 
<p>
237
 
2. Stop Nagios if it is currently running.
238
 
</p>
239
 
 
240
 
<p>
241
 
3. Start Nagios like so to use the precached config file and skip circular path checks:
242
 
</p>
243
 
 
244
 
<pre style="padding: 0 0 0 50px;">
245
 
/usr/local/nagios/bin/nagios -uxd /usr/local/nagios/etc/nagios.cfg
246
 
</pre>
247
 
 
248
 
 
249
 
<p>
250
 
4. When you modify your original configuration files in the future and need to restart Nagios to make those changes take place, repeat step 1 to re-verify your config and regenerate your cached config file.  Once that is done you can restart Nagios through the web interface or by sending a SIGHUP signal.  If you don't re-generate the precached object file, Nagios will continue to use your old confguration because it is now reading from the precached file, rather than your source configuration files.
251
 
</p>
252
 
 
253
 
<p>
254
 
5. That's it!  Enjoy the increased startup speed.
255
 
</p>
256
 
 
257
 
 
258
 
<hr>
259
 
 
260
 
</body>
261
 
</html>
 
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
 
2
 
 
3
 
 
4
 
 
5
<html>
 
6
 
 
7
<head>
 
8
 
 
9
<title>Fast Startup Options</title>
 
10
 
 
11
 
 
12
 
 
13
<STYLE type="text/css">
 
14
 
 
15
<!--
 
16
 
 
17
        .Default { font-family: verdana,arial,serif; font-size: 8pt; }
 
18
 
 
19
        .PageTitle { font-family: verdana,arial,serif; font-size: 16pt; font-weight: bold; }
 
20
 
 
21
-->      
 
22
 
 
23
</STYLE>
 
24
 
 
25
 
 
26
 
 
27
</head>
 
28
 
 
29
 
 
30
 
 
31
<body bgcolor="#FFFFFF" text="black" class="Default">
 
32
 
 
33
 
 
34
 
 
35
<div align="center">
 
36
 
 
37
<img src="images/nagios.jpg" border="0" alt="Nagios" title="Nagios">
 
38
 
 
39
<h1 class="PageTitle">Fast Startup Options</h1>
 
40
 
 
41
</div>
 
42
 
 
43
 
 
44
 
 
45
<hr>
 
46
 
 
47
 
 
48
 
 
49
<p>
 
50
 
 
51
<img src="images/upto.gif" border="0" align="middle" alt="Up To" title="Up To">Up To: <a href="toc.html">Contents</a><br>
 
52
 
 
53
<img src="images/seealso.gif" border="0" align="middle" alt="See Also" title="See Also"> See Also: <a href="tuning.html">Performance Tuning</a>, <a href="largeinstalltweaks.html">Large Installation Tweaks</a>
 
54
 
 
55
</p>
 
56
 
 
57
 
 
58
 
 
59
<p>
 
60
 
 
61
<strong><u>Introduction</u></strong>
 
62
 
 
63
</p>
 
64
 
 
65
 
 
66
 
 
67
<p>
 
68
 
 
69
There are a few things you can do that can decrease the amount of time it take Nagios to startup (or restart).  These speedups involve easing some of the burden involved in processing your configuration files.
 
70
 
 
71
</p>
 
72
 
 
73
 
 
74
 
 
75
<p>
 
76
 
 
77
Using these techniques is particularly useful when you have one or more of the following:
 
78
 
 
79
</p>
 
80
 
 
81
 
 
82
 
 
83
<ul>
 
84
 
 
85
<li>Large configurations</li>
 
86
 
 
87
<li>Complex configurations (heavy use of template features)</li>
 
88
 
 
89
<li>Installations where frequest restarts are necessary</li>
 
90
 
 
91
</ul>
 
92
 
 
93
 
 
94
 
 
95
<p>
 
96
 
 
97
<strong><u>Background</u></strong>
 
98
 
 
99
</p>
 
100
 
 
101
 
 
102
 
 
103
<p>
 
104
 
 
105
Whenever Nagios starts/restarts it has to process your configuration files before it can get down to the business of monitoring.  This configuration startup process involves a number of steps:
 
106
 
 
107
</p>
 
108
 
 
109
 
 
110
 
 
111
<ul>
 
112
 
 
113
<li>Reading the config files</li>
 
114
 
 
115
<li>Resolving template definitions</li>
 
116
 
 
117
<li>"Recombobulating" your objects (my term for the various types of work that occurs)</li>
 
118
 
 
119
<li>Duplicating object definitions</li>
 
120
 
 
121
<li>Inheriting object properties</li>
 
122
 
 
123
<li>Sorting your object definitions</li>
 
124
 
 
125
<li>Verifying object relationship integrity</li>
 
126
 
 
127
<li>Checking for circular paths</li>
 
128
 
 
129
<li>and more...</li>
 
130
 
 
131
</ul>
 
132
 
 
133
 
 
134
 
 
135
<p>
 
136
 
 
137
Some of these steps can be quite time-consuming when you have large or complex configurations.  Is there a way to speed any of these steps up?  Yes!
 
138
 
 
139
</p>
 
140
 
 
141
 
 
142
 
 
143
<p>
 
144
 
 
145
<strong><u>Evaluating Startup Times</u></strong>
 
146
 
 
147
</p>
 
148
 
 
149
 
 
150
 
 
151
<p>
 
152
 
 
153
Before we get on to making things faster, we need to see what's possible and whether or not we should even bother with the whole thing.  This is easy to do - simply start nagios with the <b>-s</b> command line switch to get timing and scheduling information.
 
154
 
 
155
</p>
 
156
 
 
157
 
 
158
 
 
159
<p>
 
160
 
 
161
An example of the output (abbreviated to only show relevant portions) is shown below. For this example, I'm using a Nagios config that has 25 hosts defined and just over 10,000 services.
 
162
 
 
163
</p>
 
164
 
 
165
 
 
166
 
 
167
<pre style="padding: 0 0 0 50px;">
 
168
 
 
169
/usr/local/nagios/bin/nagios -s /usr/local/nagios/etc/nagios.cfg
 
170
 
 
171
 
 
172
 
 
173
Nagios 3.0-prealpha
 
174
 
 
175
Copyright (c) 1999-2007 Ethan Galstad (http://www.nagios.org)
 
176
 
 
177
Last Modified: 01-27-2007
 
178
 
 
179
License: GPL
 
180
 
 
181
 
 
182
 
 
183
Timing information on object configuration processing is listed
 
184
 
 
185
below.  You can use this information to see if precaching your
 
186
 
 
187
object configuration would be useful.
 
188
 
 
189
 
 
190
 
 
191
Object Config Source: Config files (uncached)
 
192
 
 
193
 
 
194
 
 
195
OBJECT CONFIG PROCESSING TIMES      (* = Potential for precache savings with -u option)
 
196
 
 
197
----------------------------------
 
198
 
 
199
Read:                 0.486780 sec
 
200
 
 
201
Resolve:              0.004106 sec  *
 
202
 
 
203
Recomb Contactgroups: 0.000077 sec  *
 
204
 
 
205
Recomb Hostgroups:    0.000172 sec  *
 
206
 
 
207
Dup Services:         0.028801 sec  *
 
208
 
 
209
Recomb Servicegroups: 0.010358 sec  *
 
210
 
 
211
Duplicate:            5.666932 sec  *
 
212
 
 
213
Inherit:              0.003770 sec  *
 
214
 
 
215
Recomb Contacts:      0.030085 sec  *
 
216
 
 
217
Sort:                 2.648863 sec  *
 
218
 
 
219
Register:             2.654628 sec
 
220
 
 
221
Free:                 0.021347 sec
 
222
 
 
223
                      ============
 
224
 
 
225
TOTAL:                11.555925 sec  * = 8.393170 sec (72.63%) estimated savings
 
226
 
 
227
 
 
228
 
 
229
 
 
230
 
 
231
Timing information on configuration verification is listed below.
 
232
 
 
233
 
 
234
 
 
235
CONFIG VERIFICATION TIMES          (* = Potential for speedup with -x option)
 
236
 
 
237
----------------------------------
 
238
 
 
239
Object Relationships: 1.400807 sec
 
240
 
 
241
Circular Paths:       54.676622 sec  *
 
242
 
 
243
Misc:                 0.006924 sec
 
244
 
 
245
                      ============
 
246
 
 
247
TOTAL:                56.084353 sec  * = 54.676622 sec (97.5%) estimated savings
 
248
 
 
249
</pre>
 
250
 
 
251
 
 
252
 
 
253
<p>
 
254
 
 
255
Okay, lets see what happened.  Looking at the totals, it took roughly <b>11.6</b> seconds to process the configuration files and another <b>56</b> seconds to verify the config.  That means that every time I start or restart Nagios with this configuration, it will take nearly <b>68 seconds</b> of startup work before it can monitor anything!  That's not acceptable if I have to restart Nagios on a semi-regular basis.
 
256
 
 
257
</p>
 
258
 
 
259
 
 
260
 
 
261
<p>
 
262
 
 
263
What can I do about this?  Take another look at the output and you'll see that Nagios estimates that I could save about <b>8.4</b> seconds off the configuration processing time and another <b>54.7</b> off the verification times.  In total, Nagios thinks I could save <b>63 seconds</b> of the normal startup time if some optimizations were taken.
 
264
 
 
265
</p>
 
266
 
 
267
 
 
268
 
 
269
<p>
 
270
 
 
271
Whoa!  From <b>68 seconds</b> to just <b>5 seconds</b>?  Yep, read on for how to do it.
 
272
 
 
273
</p>
 
274
 
 
275
 
 
276
 
 
277
 
 
278
 
 
279
 
 
280
 
 
281
<p>
 
282
 
 
283
<strong><u>Pre-Caching Object Configuration</u></strong>
 
284
 
 
285
</p>
 
286
 
 
287
 
 
288
 
 
289
<p>
 
290
 
 
291
Nagios can spend quite a bit of time parsing your config files, especially if you make use of the template features such as inheritance, etc.  In order to reduce the time it takes to parse your config, you can have Nagios pre-process and pre-cache your config files for future use.  
 
292
 
 
293
</p>
 
294
 
 
295
 
 
296
 
 
297
<table border="0" class="Default">
 
298
 
 
299
<tr>
 
300
 
 
301
<td valign="top">
 
302
 
 
303
<p>
 
304
 
 
305
When you run nagios with the <b>-p</b> command line option, Nagios will read your config files in, process them, and save them to a pre-cached object config file (specified by the <a href="configmain.html#precached_object_file">precached_object_file</a> directive).  This pre-cached config file will contain pre-processed configuration entries that are easier/faster for Nagios to process in the future.
 
306
 
 
307
</p>
 
308
 
 
309
 
 
310
 
 
311
<p>
 
312
 
 
313
You must use the <b>-p</b> command line option along with either the <b>-v</b> or <b>-s</b> command line options, as shown below.  This ensures that your configuration is verified before the precached file is created.
 
314
 
 
315
</p>
 
316
 
 
317
 
 
318
 
 
319
<pre style="padding: 0 0 0 50px;">
 
320
 
 
321
/usr/local/nagios/bin/nagios -pv /usr/local/nagios/etc/nagios.cfg
 
322
 
 
323
</pre>
 
324
 
 
325
 
 
326
 
 
327
<p>
 
328
 
 
329
The size of your precached config file will most likely be significantly larger than the sum of the sizes of your object config files.  This is normal and by design.
 
330
 
 
331
</p>
 
332
 
 
333
</td>
 
334
 
 
335
<td valign="top">
 
336
 
 
337
<div style="float: right; clear: right; padding: 0 0 25px 25px;">
 
338
 
 
339
<img src="images/fast-startup1.png" alt="Pre-Caching Object Config Files" title="Pre-Caching Object Config Files" border="0">
 
340
 
 
341
</div>
 
342
 
 
343
</td>
 
344
 
 
345
</tr>
 
346
 
 
347
 
 
348
 
 
349
<tr>
 
350
 
 
351
<td valign="top">
 
352
 
 
353
<p>
 
354
 
 
355
Once the precached object configuration file have been created, you can start Nagios and tell it to use the precached config file instead of your object config file(s) by using the <b>-u</b> command line option.
 
356
 
 
357
</p>
 
358
 
 
359
 
 
360
 
 
361
<pre style="padding: 0 0 0 50px;">
 
362
 
 
363
/usr/local/nagios/bin/nagios -ud /usr/local/nagios/etc/nagios.cfg
 
364
 
 
365
</pre>
 
366
 
 
367
 
 
368
 
 
369
<p><img src="images/important.gif" border="0" align="bottom" alt="Important" title="Important"> If you modify your configuration files, you will need to re-verify and re-cache your configuration files before restarting Nagios.  If you don't re-generate the precached object file, Nagios will continue to use your old configuration because it is now reading from the precached file, rather than your source configuration files.
 
370
 
 
371
</p>
 
372
 
 
373
 
 
374
 
 
375
</td>
 
376
 
 
377
<td valign="top">
 
378
 
 
379
<div style="float: right; padding: 0 0 0 25px;">
 
380
 
 
381
<img src="images/fast-startup2.png" alt="Pre-Caching Object Config Files" title="Pre-Caching Object Config Files" border="0">
 
382
 
 
383
</div>
 
384
 
 
385
</td>
 
386
 
 
387
</tr>
 
388
 
 
389
</table>
 
390
 
 
391
 
 
392
 
 
393
<p>
 
394
 
 
395
<strong><u>Skipping Circular Path Tests</u></strong>
 
396
 
 
397
</p>
 
398
 
 
399
 
 
400
 
 
401
<p>
 
402
 
 
403
The second (and most time-intensive) portion of the configuration startup phase is the circular path check.  In the example above, it took nearly a minute to perform this step of the configuration verification.
 
404
 
 
405
</p>
 
406
 
 
407
 
 
408
 
 
409
<p>
 
410
 
 
411
What is the circular path check and why does it take so long?  The circular patch check is designed to ensure that you don't define any circular paths in your host, host dependency, or service dependency definitions.  If a circular path existed in your config files, Nagios could end up in a deadlock situation.  The most likely reason for the check taking so long is that I'm not using an efficient algorithm.  A much more efficient algorithm for detecting circular paths would be most welcomed.  Hint:  That means all you CompSci graduate students who have been emailing me about doing your thesis on Nagios can contribute some code back. :-)
 
412
 
 
413
</p>
 
414
 
 
415
 
 
416
 
 
417
<p>
 
418
 
 
419
If you want to skip the circular path check when Nagios starts, you can add the -x command line option like this:
 
420
 
 
421
</p>
 
422
 
 
423
 
 
424
 
 
425
<pre style="padding: 0 0 0 50px;">
 
426
 
 
427
/usr/local/nagios/bin/nagios -xd /usr/local/nagios/etc/nagios.cfg
 
428
 
 
429
</pre>
 
430
 
 
431
 
 
432
 
 
433
<p><img src="images/important.gif" border="0" align="bottom" alt="Important" title="Important"> It is of utmost importance that you verify your configuration before starting/restarting Nagios when skipping circular path checks.  Failure to do so could lead to deadlocks in the Nagios logic.  You have been warned.
 
434
 
 
435
</p>
 
436
 
 
437
 
 
438
 
 
439
<p>
 
440
 
 
441
<strong><u>Putting It All Together</u></strong>
 
442
 
 
443
</p>
 
444
 
 
445
 
 
446
 
 
447
<p>
 
448
 
 
449
Follow these steps if you want to make use of potential speedups from pre-caching your configuration and skipping circular path checks.
 
450
 
 
451
</p>
 
452
 
 
453
 
 
454
 
 
455
<p>
 
456
 
 
457
1. Verify your configuration and create the precache file with the following command:
 
458
 
 
459
</p>
 
460
 
 
461
 
 
462
 
 
463
<pre style="padding: 0 0 0 50px;">
 
464
 
 
465
/usr/local/nagios/bin/nagios -vp /usr/local/nagios/etc/nagios.cfg
 
466
 
 
467
</pre>
 
468
 
 
469
 
 
470
 
 
471
<p>
 
472
 
 
473
2. Stop Nagios if it is currently running.
 
474
 
 
475
</p>
 
476
 
 
477
 
 
478
 
 
479
<p>
 
480
 
 
481
3. Start Nagios like so to use the precached config file and skip circular path checks:
 
482
 
 
483
</p>
 
484
 
 
485
 
 
486
 
 
487
<pre style="padding: 0 0 0 50px;">
 
488
 
 
489
/usr/local/nagios/bin/nagios -uxd /usr/local/nagios/etc/nagios.cfg
 
490
 
 
491
</pre>
 
492
 
 
493
 
 
494
 
 
495
 
 
496
 
 
497
<p>
 
498
 
 
499
4. When you modify your original configuration files in the future and need to restart Nagios to make those changes take place, repeat step 1 to re-verify your config and regenerate your cached config file.  Once that is done you can restart Nagios through the web interface or by sending a SIGHUP signal.  If you don't re-generate the precached object file, Nagios will continue to use your old confguration because it is now reading from the precached file, rather than your source configuration files.
 
500
 
 
501
</p>
 
502
 
 
503
 
 
504
 
 
505
<p>
 
506
 
 
507
5. That's it!  Enjoy the increased startup speed.
 
508
 
 
509
</p>
 
510
 
 
511
 
 
512
 
 
513
 
 
514
 
 
515
<hr>
 
516
 
 
517
 
 
518
 
 
519
</body>
 
520
 
 
521
</html>
 
522