File: stoprestart.html

package info (click to toggle)
nagios2 2.6-2%2Betch5
  • links: PTS
  • area: main
  • in suites: etch
  • size: 6,856 kB
  • ctags: 4,475
  • sloc: ansic: 64,870; sh: 4,676; makefile: 787; perl: 722
file content (131 lines) | stat: -rw-r--r-- 4,908 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<title>Stopping and Restarting Nagios</title>

<STYLE type="text/css">
<!--
        .Default { font-family: verdana,arial,serif; font-size: 8pt; }
        .PageTitle { font-family: verdana,arial,serif; font-size: 12pt; font-weight: bold; }
-->      
</STYLE>

</head>

<body bgcolor="#FFFFFF" text="black" class="Default">

<p>
<div align="center">
<h2 class="PageTitle">Stopping And Restarting Nagios</h2>
</div>
</p>
<hr>

<p>
Once you have Nagios up and running, you may need to stop the process or reload the configuration
data "on the fly".  This section describes how to do just that.
</p>

<p>
<font color="red"><strong>IMPORTANT:</strong></font>  Before you restart Nagios, make sure that you have <a href="verifyconfig.html">verified the configuration data</a> using the -v command line switch, <i>especially</i> if you have made any changes to your <a href="config.html">config files</a>.  If Nagios encounters problem with one of the config files when it restarts, it will log an error and terminate.
</p>

<p>
<strong><u>Stopping And Restarting With The Init Script</u></strong>
</p>

<p>
If you have installed the sample init script to your /etc/rc.d/init.d directory you can stop and restart Nagios easily.  If you haven't, skip this section and read how to do it manually below.  I'll assume that you named the init script <b>Nagios</b> in the examples below...
</p>

<p>
<table border="1" class="Default">
<tr>
<td bgcolor="#cbcbcb"><strong>Desired Action</strong></td>
<td bgcolor="#cbcbcb" nowrap><strong>Command</strong></td>
<td bgcolor="#cbcbcb"><strong>Description</strong></td>
</tr>
<tr>
<td>Stop Nagios</td>
<td nowrap><font color="red"><strong>/etc/rc.d/init.d/nagios stop</strong></font></td>
<td>This kills the Nagios process</td>
</tr>
<tr>
<td>Restart Nagios</td>
<td nowrap><font color="red"><strong>/etc/rc.d/init.d/nagios restart</strong></font></td>
<td>This kills the current Nagios process and then starts Nagios up again</td>
</tr>
<tr>
<td>Reload Configuration Data</td>
<td nowrap><font color="red"><strong>/etc/rc.d/init.d/nagios reload</strong></font></td>
<td>Sends a SIGHUP to the Nagios process, causing it to flush its current configuration data, reread the configuration files, and start monitoring again</td>
</tr>
</table>
</p>

<p>
Stopping, restarting, and reloading Nagios are fairly simple with an init script and I would highly recommend you use one if at all possible.
</p>

<p>
<strong><u>Stopping and Restarting Nagios Manually</u></strong>
</p>

<p>
If you aren't using an init script to start Nagios, you'll have to do things manually.  First you'll have to find the process ID that Nagios is running under and then you'll have to use the <i>kill</i> command to terminate the application or make it reload the configuration data by sending it the proper signal.  Directions for doing this are outlined below...
</p>

<p>
<strong><u>Finding The Nagios Process ID</u></strong>
</p>

<p>
First off, you will need to know the process id that Nagios is running as.  To do that, just type the 
following command at a shell prompt:
</p>
<p>
<strong><font color="red">ps axu | grep nagios</font></strong>
</p>
<p>
The output should look something like this:
<pre>
nagios  6808  0.0  0.7   840   352  p3 S    13:44   0:00 grep nagios
nagios 11149  0.2  1.0   868   488  ?  S   Feb 27   6:33 /usr/local/nagios/bin/nagios nagios.cfg
</pre>
From the program output, you will notice that Nagios was started by user <b>nagios</b> and is running as process id <b>11149</b>.
</p>

<p>
<strong><u>Manually Stopping Nagios</u></strong>
</p>

<p>
In order to stop Nagios, use the <i>kill</i> command as follows...
</p>
<p>
<strong><font color="red">kill 11149</font></strong>
</p>
<p>
You should replace <b>11149</b> with the actual process id that Nagios is running as on your machine.
</p>

<p>
<strong><u>Manually Restarting Nagios</u></strong>
</p>

<p>
If you have modified the configuration data, you will want to restart Nagios and have it re-read the new configuration.  If you have changed the source code and recompiled the main Nagios executable you should <i>not</i> use this method.  Instead, stop Nagios by killing it (as outlined above) and restart it manually.  Restarting Nagios using the method below does not actually reload Nagios - it just causes Nagios to flush its current configuration, re-read the new configuration, and start monitoring all over again.  To restart Nagios, you need to send the <b>SIGHUP</b> signal to Nagios.  Assuming that the process id for Nagios is <b>11149</b> (taken from the example above), use the following command:
</p>
<p>
<strong><font color="red">kill -HUP 11149</font></strong>
</p>
<p>
Remember, you will need to replace <b>11149</b> with the actual process id that Nagios is running as on your machine.
</p>


<hr>

</body>
</html>