File: clusters.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 (179 lines) | stat: -rw-r--r-- 9,510 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<title>Monitoring Service and Host Clusters</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">Monitoring Service and Host Clusters</h2>
</div>
</p>

<hr>

<p>
<strong><u>Introduction</u></strong>
</p>

<p>
Several people have asked how to go about monitoring clusters of hosts or services, so I decided to write up a little documentation on how to do this.  Its fairly straightforward, so hopefully you find things easy to understand...
</p>

<p>
First off, we need to define what we mean by a "cluster".  The simplest way to understand this is with an example.  Let's say that your organization has five hosts which provide redundant DNS services to your organization.  If one of them fails, its not a major catastrophe because the remaining servers will continue to provide name resolution services.  If you're concerned with monitoring the availability of DNS service to your organization, you will want to monitor five DNS servers.  This is what I consider to be a <i>service</i> cluster.  The service cluster consists of five separate DNS services that you are monitoring.  Although you do want to monitor each individual service, your main concern is with the overall status of the DNS service cluster, rather than the availability of any one particular service.
</p>

<p>
If your organization has a group of hosts that provide a high-availability (clustering) solution, I would consider those to be a <i>host</i> cluster.  If one particular host fails, another will step in to take over all the duties of the failed server.  As a side note, check out the <a href="http://www.linux-ha.org">High-Availability Linux Project</a> for information on providing host and service redundancy with Linux.
</p>

<p>
<strong><u>Plan of Attack</u></strong>
</p>

<p>
There are several ways you could potentially monitor service or host clusters.  I'll describe the method that I believe to be the easiest.  Monitoring service or host clusters involves two things:
</p>

<p>
<ul>
<li>Monitoring individual cluster elements
<li>Monitoring the cluster as a collective entity
</ul>
</p>

<p>
Monitoring individual host or service cluster elements is easier than you think.  In fact, you're probably already doing it.  For service clusters, just make sure that you are monitoring each service element of the cluster.  If you've got a cluster of five DNS servers, make sure you have five separate service definitions (probably using the <i>check_dns</i> plugin).  For host clusters, make sure you have configured appropriate host definitions for each member of the cluster (you'll also have to define at least one service to be monitored for each of the hosts).  <b>Important:</b>  You're going to want to disable notifications for the individual cluster elements (host or service definitions).  Even though no notifications will be sent about the individual elements, you'll still get a visual display of the individual host or service status in the <a href="cgis.html#status_cgi">status CGI</a>.  This will be useful for pinpointing the source of problems within the cluster in the future.
</p>

<p>
Monitoring the overall cluster can be done by using the previously cached results of cluster elements.  Although you could re-check all elements of the cluster to determine the cluster's status, why waste bandwidth and resources when you already have the results cached?  Where are the results cached?  Cached results for cluster elements can be found in the <a href="configmain.html#status_file">status file</a> (assuming you are monitoring each element).  The <i>check_cluster2</i> plugin is designed specifically for checking cached host and service states in the status file.  <b>Important:</b> Although you didn't enable notifications for individual elements of the cluster, you will want them enabled for the overall cluster status check.
</p>

<p>
<strong><u>Using the <i>check_cluster2</i> Plugin</u></strong>
</p>

<p>
The check_cluster2 plugin is designed to report the overall status of a host or service cluster by checking the status information of each individual host or service cluster elements.
</p>

<p>
More to come...  The <i>check_cluster2</i> plugin can be found in the contrib directory of the Nagios Plugins release at <a 
href="http://sourceforge.net/projects/nagiosplug/">http://sourceforge.net/projects/nagiosplug/</a>.

</p>

<p>
<strong><u>Monitoring Service Clusters</u></strong>
</p>

<p>
Let's say you have three DNS servers that provide redundant services on your network.  First off, you need to be monitoring each of these DNS servers seperately before you can monitor them as a cluster.  I'll assume that you already have three seperate services (all called "DNS Service") associated with your DNS hosts (called "host1", "host2" and "host3").
</p>

<p>
In order to monitor the services as a cluster, you'll need to create a new "cluster" service.  However, before you do that, make sure you have a service cluster check command configured.  Let's assume that you have a command called <i>check_service_cluster</i> defined as follows:
</p>

<p>
<font color="red">
<strong>
<pre>
define command{
	command_name	check_service_cluster
	command_line	/usr/local/nagios/libexec/check_cluster2 --service -l $ARG1$ -w $ARG2$ -c $ARG3$ -d $ARG4$ 
	}
</pre>

</strong>
</font>
</p>

<p>
Now you'll need to create the "cluster" service and use the <i>check_service_cluster</i> command you just created as the cluster's check command.  The example below gives an example of how to do this.  The example below will generate a CRITICAL alert if 2 or more services in the cluster are in a non-OK state, and a WARNING alert if only 1 of the services is in a non-OK state.  If all the individual service members of the cluster are OK, the cluster check will return an OK state as well.
</p>

<pre>
<font color="red">
<strong>
define service{
	...
	check_command	check_service_cluster!"DNS Cluster"!1!2!$SERVICESTATEID:host1:DNS Service$,$SERVICESTATEID:host2:DNS Service$,$SERVICESTATEID:host3:DNS Service$
	...
	}
</strong>
</font>
</pre>

<p>
It is important to notice that we are passing a comma-delimited list of <i>on-demand</i> service state <a href="macros.html">macros</a> to the $ARG4$ macro in the cluster check command.  That's important!  Nagios will fill those on-demand macros in with the current service state IDs (numerical values, rather than text strings) of the individual members of the cluster.
</p>



<p>
<strong><u>Monitoring Host Clusters</u></strong>
</p>

<p>
Monitoring host clusters is very similiar to monitoring service clusters.  Obviously, the main difference is that the cluster members are hosts and not services.  In order to monitor the status of a host cluster, you must define a service that uses the <i>check_cluster2</i> plugin.  The service should <i>not</i> be associated with any of the hosts in the cluster, as this will cause problems with notifications for the cluster if that host goes down.  A good idea might be to associate the service with the host that Nagios is running on.  After all, if the host that Nagios is running on goes down, then Nagios isn't running anymore, so there isn't anything you can do as far as monitoring (unless you've setup <a href="redundancy.html">redundant monitoring hosts</a>)...
</p>

<p>
Anyway, let's assume that you have a <i>check_host_cluster</i> command defined as follows:
</p>

<p>
<font color="red">
<strong>
<pre>
define command{
	command_name	check_host_cluster
	command_line	/usr/local/nagios/libexec/check_cluster2 --host -l $ARG1$ -w $ARG2$ -c $ARG3$ -d $ARG4$ 
	}
</pre>
</strong>
</font>
</p>

<p>
Let's say you have three hosts (named "host1", "host2" and "host3") in the host cluster.  If you want Nagios to generate a warning alert if one host in the cluster is not UP or a critical alert if two or more hosts are not UP, the the service you define to monitor the host cluster might look something like this:
</p>

<pre>
<font color="red">
<strong>
define service{
	...
	check_command	check_host_cluster!"Super Host Cluster"!1!2!$HOSTSTATEID:host1$,$HOSTSTATEID:host2$,$HOSTSTATEID:host3$
	...
	}
</strong>
</font>
</pre>

<p>
It is important to notice that we are passing a comma-delimited list of <i>on-demand</i> host state <a href="macros.html">macros</a> to the $ARG4$ macro in the cluster check command.  That's important!  Nagios will fill those on-demand macros in with the current host state IDs (numerical values, rather than text strings) of the individual members of the cluster.
</p>

<p>
That's it!  Nagios will periodically check the status of the host cluster and send notifications to you when its status is degraded (assuming you've enabled notification for the service).  Note that for thehost definitions of each cluster member, you will most likely want to disable notifications when the host goes down .  Remeber that you don't care as much about the status of any individual host as you do the overall status of the cluster.  Depending on your network layout and what you're trying to accomplish, you may wish to leave notifications for unreachable states enabled for the host definitions.
</p>

<hr>

</body>
</html>