Debian Codegraph @

check_mongodb/README.md

raw
1 # Nagios-MongoDB
2
3 ## Overview
4
5 This is a simple Nagios check script to monitor your MongoDB server(s).
6
7 ## Authors
8
9 ### Main Author
10 Mike Zupan mike -(at)- zcentric.com
11 ### Contributers
12 - Frank Brandewiede <brande -(at)- travel-iq.com> <brande -(at)- bfiw.de> <brande -(at)- novolab.de>
13 - Sam Perman <sam -(at)- brightcove.com>
14 - Shlomo Priymak <shlomoid -(at)- gmail.com>
15 - @jhoff909 on github
16 - Dag Stockstad <dag.stockstad -(at)- gmail.com>
17
18 ## Installation
19
20 In your Nagios plugins directory run
21
22 <pre><code>git clone git://github.com/mzupan/nagios-plugin-mongodb.git</code></pre>
23
24 Then use pip to ensure you have all pre-requisites.
25
26 <pre><code>pip install requirements</code></pre>
27
28 ## Usage
29
30 ### Install in Nagios
31
32 Edit your commands.cfg and add the following
33
34 <pre><code>
35 define command {
36 command_name check_mongodb
37 command_line $USER1$/nagios-plugin-mongodb/check_mongodb.py -H $HOSTADDRESS$ -A $ARG1$ -P $ARG2$ -W $ARG3$ -C $ARG4$
38 }
39
40 define command {
41 command_name check_mongodb_database
42 command_line $USER1$/nagios-plugin-mongodb/check_mongodb.py -H $HOSTADDRESS$ -A $ARG1$ -P $ARG2$ -W $ARG3$ -C $ARG4$ -d $ARG5$
43 }
44
45 define command {
46 command_name check_mongodb_collection
47 command_line $USER1$/nagios-plugin-mongodb/check_mongodb.py -H $HOSTADDRESS$ -A $ARG1$ -P $ARG2$ -W $ARG3$ -C $ARG4$ -d $ARG5$ -c $ARG6$
48 }
49
50 define command {
51 command_name check_mongodb_replicaset
52 command_line $USER1$/nagios-plugin-mongodb/check_mongodb.py -H $HOSTADDRESS$ -A $ARG1$ -P $ARG2$ -W $ARG3$ -C $ARG4$ -r $ARG5$
53 }
54
55 define command {
56 command_name check_mongodb_query
57 command_line $USER1$/nagios-plugin-mongodb/check_mongodb.py -H $HOSTADDRESS$ -A $ARG1$ -P $ARG2$ -W $ARG3$ -C $ARG4$ -q $ARG5$
58 }
59 </code></pre>
60 (add -D to the command if you want to add perfdata to the output)
61 Then you can reference it like the following. This is is my services.cfg
62
63 #### Check Connection
64
65 This will check each host that is listed in the Mongo Servers group. It will issue a warning if the connection to the server takes 2 seconds and a critical error if it takes over 4 seconds
66
67 <pre><code>
68 define service {
69 use generic-service
70 hostgroup_name Mongo Servers
71 service_description Mongo Connect Check
72 check_command check_mongodb!connect!27017!2!4
73 }
74 </code></pre>
75
76 #### Check Percentage of Open Connections
77
78 This is a test that will check the percentage of free connections left on the Mongo server. In the following example it will send out an warning if the connection pool is 70% used and a critical error if it is 80% used.
79
80 <pre><code>
81 define service {
82 use generic-service
83 hostgroup_name Mongo Servers
84 service_description Mongo Free Connections
85 check_command check_mongodb!connections!27017!70!80
86 }
87 </code></pre>
88
89 #### Check Replication Lag
90
91 This is a test that will test the replication lag of Mongo servers. It will send out a warning if the lag is over 15 seconds and a critical error if its over 30 seconds. Please note that this check uses 'optime' from rs.status() which will be behind realtime as heartbeat requests between servers only occur every few seconds. Thus this check may show an apparent lag of < 10 seconds when there really isn't any. Use larger values for reliable monitoring.
92
93 <pre><code>
94 define service {
95 use generic-service
96 hostgroup_name Mongo Servers
97 service_description Mongo Replication Lag
98 check_command check_mongodb!replication_lag!27017!15!30
99 }
100 </code></pre>
101
102
103 #### Check Replication Lag Percentage
104
105 This is a test that will test the replication lag percentage of Mongo servers. It will send out a warning if the lag is over 50 percents and a critical error if its over 75 percents. Please note that this check gets oplog timeDiff from primary and compares it to replication lag. When this check reaches 100 percent full resync is needed.
106
107 <pre><code>
108 define service {
109 use generic-service
110 hostgroup_name Mongo Servers
111 service_description Mongo Replication Lag Percentage
112 check_command check_mongodb!replication_lag_percent!27017!50!75
113 }
114 </code></pre>
115
116
117 #### Check Memory Usage
118
119 This is a test that will test the memory usage of Mongo server. In my example my Mongo servers have 32 gigs of memory so I'll trigger a warning if Mongo uses over 20 gigs of ram and a error if Mongo uses over 28 gigs of memory.
120
121 <pre><code>
122 define service {
123 use generic-service
124 hostgroup_name Mongo Servers
125 service_description Mongo Memory Usage
126 check_command check_mongodb!memory!27017!20!28
127 }
128 </code></pre>
129
130 #### Check Mapped Memory Usage
131
132 This is a test that will check the mapped memory usage of Mongo server.
133
134 <pre><code>
135 define service {
136 use generic-service
137 hostgroup_name Mongo Servers
138 service_description Mongo Mapped Memory Usage
139 check_command check_mongodb!memory_mapped!27017!20!28
140 }
141 </code></pre>
142
143 #### Check Lock Time Percentage
144
145 This is a test that will test the lock time percentage of Mongo server. In my example my Mongo I want to be warned if the lock time is above 5% and get an error if it's above 10%. When you start to have lock time it generally means your db is now overloaded.
146
147 <pre><code>
148 define service {
149 use generic-service
150 hostgroup_name Mongo Servers
151 service_description Mongo Lock Percentage
152 check_command check_mongodb!lock!27017!5!10
153 }
154 </code></pre>
155
156 #### Check Average Flush Time
157
158 This is a test that will check the average flush time of Mongo server. In my example my Mongo I want to be warned if the average flush time is above 100ms and get an error if it's above 200ms. When you start to get a high average flush time it means your database is write bound.
159
160 <pre><code>
161 define service {
162 use generic-service
163 hostgroup_name Mongo Servers
164 service_description Mongo Flush Average
165 check_command check_mongodb!flushing!27017!100!200
166 }
167 </code></pre>
168
169 #### Check Last Flush Time
170
171 This is a test that will check the last flush time of Mongo server. In my example my Mongo I want to be warned if the last flush time is above 200ms and get an error if it's above 400ms. When you start to get a high flush time it means your server might be needing faster disk or its time to shard.
172
173 <pre><code>
174 define service {
175 use generic-service
176 hostgroup_name Mongo Servers
177 service_description Mongo Last Flush Time
178 check_command check_mongodb!last_flush_time!27017!200!400
179 }
180 </code></pre>
181
182 #### Check status of mongodb replicaset
183 This is a test that will check the status of nodes within a replicaset. Depending which status it is it sends a waring during status 0, 3 and 5, critical if the status is 4, 6 or 8 and a ok with status 1, 2 and 7.
184
185 Note the trailing 2 0's keep those 0's as the check doesn't compare to anything.. So those values need to be there for the check to work.
186
187 <pre><code>
188 define service {
189 use generic-service
190 hostgroup_name Mongo Servers
191 service_description MongoDB state
192 check_command check_mongodb!replset_state!27017!0!0
193 }
194 </code></pre>
195
196 #### Check status of index miss ratio
197 This is a test that will check the ratio of index hits to misses. If the ratio is high, you should consider adding indexes. I want to get a warning if the ratio is above .005 and get an error if it's above .01
198
199 <pre><code>
200 define service {
201 use generic-service
202 hostgroup_name Mongo Servers
203 service_description MongoDB Index Miss Ratio
204 check_command check_mongodb!index_miss_ratio!27017!.005!.01
205 }
206 </code></pre>
207
208 #### Check number of databases and number of collections
209 These tests will count the number of databases and the number of collections. It is usefull e.g. when your application "leaks" databases or collections. Set the warning, critical level to fit your application.
210
211 <pre><code>
212 define service {
213 use generic-service
214 hostgroup_name Mongo Servers
215 service_description MongoDB Number of databases
216 check_command check_mongodb!databases!27017!300!500
217 }
218
219 define service {
220 use generic-service
221 hostgroup_name Mongo Servers
222 service_description MongoDB Number of collections
223 check_command check_mongodb!collections!27017!300!500
224 }
225 </code></pre>
226
227
228
229 #### Check size of a database
230 This will check the size of a database. This is useful for keeping track of growth of a particular database.
231 Replace your-database with the name of your database
232 <pre><code>
233 define service {
234 use generic-service
235 hostgroup_name Mongo Servers
236 service_description MongoDB Database size your-database
237 check_command check_mongodb_database!database_size!27017!300!500!your-database
238 }
239 </code></pre>
240
241
242
243 #### Check index size of a database
244 This will check the index size of a database. Overlarge indexes eat up memory and indicate a need for compaction.
245 Replace your-database with the name of your database
246 <pre><code>
247 define service {
248 use generic-service
249 hostgroup_name Mongo Servers
250 service_description MongoDB Database index size your-database
251 check_command check_mongodb_database!database_indexes!27017!50!100!your-database
252 }
253 </code></pre>
254
255
256
257 #### Check index size of a collection
258 This will check the index size of a collection. Overlarge indexes eat up memory and indicate a need for compaction.
259 Replace your-database with the name of your database and your-collection with the name of your collection
260 <pre><code>
261 define service {
262 use generic-service
263 hostgroup_name Mongo Servers
264 service_description MongoDB Database index size your-database
265 check_command check_mongodb_collection!collection_indexes!27017!50!100!your-database!your-collection
266 }
267 </code></pre>
268
269
270
271 #### Check the primary server of replicaset
272 This will check the primary server of a replicaset. This is useful for catching unexpected stepdowns of the replica's primary server.
273 Replace your-replicaset with the name of your replicaset
274 <pre><code>
275 define service {
276 use generic-service
277 hostgroup_name Mongo Servers
278 service_description MongoDB Replicaset Master Monitor: your-replicaset
279 check_command check_mongodb_replicaset!replica_primary!27017!0!1!your-replicaset
280 }
281 </code></pre>
282
283
284 #### Check the number of queries per second
285 This will check the number of queries per second on a server. Since MongoDB gives us the number as a running counter, we store the last value in the local
286 database in the nagios_check collection. The following types are accepted: query|insert|update|delete|getmore|command
287
288 This command will check updates per second and alert if the count is over 200 and warn if over 150
289 <pre><code>
290 define service {
291 use generic-service
292 hostgroup_name Mongo Servers
293 service_description MongoDB Updates per Second
294 check_command check_mongodb_query!queries_per_second!27017!200!150!update
295 }
296 </code></pre>
297
298 #### Check Primary Connection
299
300 This will check each host that is listed in the Mongo Servers group. It will issue a warning if the connection to the primary server of current replicaset takes 2 seconds and a critical error if it takes over 4 seconds
301
302 <pre><code>
303 define service {
304 use generic-service
305 hostgroup_name Mongo Servers
306 service_description Mongo Connect Check
307 check_command check_mongodb!connect_primary!27017!2!4
308 }
309 </code></pre>
310
311
312 #### Check Collection State
313
314 This will check each host that is listed in the Mongo Servers group. It can be useful to check availability of a critical collection (locks, timeout, config server unavailable...). It will issue a critical error if find_one query failed
315
316 <pre><code>
317 define service {
318 use generic-service
319 hostgroup_name Mongo Servers
320 service_description Mongo Collection State
321 check_command check_mongodb!collection_state!27017!your-database!your-collection
322 }
323 </code></pre>
324
325