This repository has been archived by the owner on Apr 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
check_couchbase_buckets.py
executable file
·683 lines (623 loc) · 26.4 KB
/
check_couchbase_buckets.py
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
#!/usr/bin/env python
# -*- coding: utf-8; -*-
"""
Copyright (C) 2013 - Ebru Akagündüz <[email protected]>
This file is part of nagios-couchbase-plugin.
nagios-couchbase-plugin is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
nagios-couchbase-plugin is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
"""
from optparse import OptionParser
import requests
import json
import sys
import subprocess
import re
nagios_codes = {
'OK': 0,
'WARNING': 1,
'CRITICAL': 2,
'UNKNOWN': 3,
'DEPENDENT': 4,
}
def option_none(option, opt, value, parser):
""" checks a parameter for taking value"""
if parser.rargs and not parser.rargs[0].startswith('-'):
print "Option arg error"
print opt, " option should be empty"
sys.exit(2)
setattr(parser.values, option.dest, True)
def get_status(required_status):
"""get specific status using cbstat"""
cbstats_cmd = ''.join([options.cbstats, ' ', options.ip, ':11210 ',
'-b ', options.bucket, ' all', '|grep ', required_status])
cmd = subprocess.Popen(cbstats_cmd, shell=True, stdout=subprocess.PIPE)
return_code = cmd.wait()
stdout = cmd.communicate()[0]
if return_code != 0:
print "WARNING - You have entered wrong value for parameters"
return sys.exit(1)
stdout_list = stdout.split('\n')
stdout_list.pop()
for status in stdout_list:
# parse cbstat name
splitter = re.compile(r'\d')
status_name = splitter.split(status).pop(0)
status_name = status_name.strip()
status_name = status_name[:-1]
if status_name == required_status:
# parse cbstat value
splitter = re.compile(r'\D')
status_value = int(splitter.split(status).pop(-1))
return status_value
def check_levels(message, status_value, divide):
"""status level critical, warning, ok"""
size_type = ""
status = status_value
if divide:
# convert to gb
if status_value >= 1000 ** 3:
status = status_value / (1000.0 ** 3)
size_type = "GB"
# convert to mb
elif status_value >= 1000.0 ** 2:
status = status_value / (1000.0 ** 2)
size_type = "MB"
# convert to kb
elif status_value >= 1000:
status = status_value / 1000.0
size_type = "KB"
if options.critical > options.warning:
if status_value >= options.critical:
print "CRITICAL - " + message, status, size_type
return sys.exit(nagios_codes['CRITICAL'])
elif status_value >= options.warning:
print "WARNING - " + message, status, size_type
return sys.exit(nagios_codes['WARNING'])
else:
print "OK - " + message, status, size_type
return sys.exit(nagios_codes['OK'])
else:
if status_value >= options.warning:
print "WARNING - " + message, status, size_type
return sys.exit(nagios_codes['WARNING'])
elif status_value >= options.critical:
print "CRITICAL - " + message, status, size_type
return sys.exit(nagios_codes['CRITICAL'])
else:
print "OK - " + message, status, size_type
return sys.exit(nagios_codes['OK'])
def check_disk_queues(stat_name, message, divide, result):
"""shows the activity on the backend disk storage used
for persistence within a data bucket """
if result is None:
stat_value = get_status(stat_name)
else:
op = result['op']
samples = op['samples']
stat_value = samples[stat_name].pop()
check_levels(message, stat_value, divide)
def check_vbucket(stat_name, message, divide, result):
"""provides detailed information on the vBucket resources across
the cluster, including the active, replica and pending operations."""
if result is None:
stat_value = get_status(stat_name)
else:
op = result['op']
samples = op['samples']
stat_value = samples[stat_name].pop()
check_levels(message, stat_value, divide)
def check_gets_per_sec(result):
"""number of gets operations per sec from specific bucket"""
if result is None:
status_value = get_status('cmd_get')
else:
op = result['op']
samples = op['samples']
status_value = samples['cmd_get'].pop()
check_levels('CB gets per sec', status_value, True)
def check_disk_write_queue(result):
"""size of the disk write queue from specific bucket"""
if result is None:
ep_queue_size = get_status('ep_queue_size')
ep_flusher_todo = get_status('ep_flusher_todo')
else:
op = result['op']
samples = op['samples']
ep_queue_size = samples['ep_queue_size'].pop()
ep_flusher_todo = samples['ep_flusher_todo'].pop()
status_value = ep_queue_size + ep_flusher_todo
check_levels('CB disk write queue', status_value, False)
def check_sets_per_sec(result):
"""number of set operations"""
if result is None:
status_value = get_status('cmd_set')
else:
op = result['op']
samples = op['samples']
status_value = samples['cmd_set'].pop()
check_levels('CB sets per sec', status_value, True)
def check_disk_updates_per_sec(result):
"""number of existing items updated in specific bucket"""
if result is None:
vb_active_ops_update = get_status('vb_active_ops_update')
vb_replica_ops_update = get_status('vb_replica_ops_update')
vb_pending_ops_update = get_status('vb_pending_ops_update')
else:
op = result['op']
samples = op['samples']
vb_active_ops_update = samples['vb_active_ops_update'].pop()
vb_replica_ops_update = samples['vb_replica_ops_update'].pop()
vb_pending_ops_update = samples['vb_pending_ops_update'].pop()
status_value = vb_active_ops_update + vb_replica_ops_update
status_value += vb_pending_ops_update
check_levels('CB disk updates per sec', status_value, True)
def check_disk_creates_per_sec(result):
"""number of new items created in specific bucket"""
if result is None:
vb_active_ops_create = get_status('vb_active_ops_create')
vb_replica_ops_create = get_status('vb_replica_ops_create')
vb_pending_ops_create = get_status('vb_pending_ops_create')
else:
op = result['op']
samples = op['samples']
vb_active_ops_create = samples['vb_active_ops_create'].pop()
vb_replica_ops_create = samples['vb_replica_ops_create'].pop()
vb_pending_ops_create = samples['vb_pending_ops_create'].pop()
status_value = vb_active_ops_create + vb_replica_ops_create
status_value += vb_pending_ops_create
check_levels("CB disk creates per sec: ", status_value, True)
def check_cache_miss_ratio():
"""percentage of reads per second to specific bucket which required a read
from disk rather than RAM."""
ep_bg_fetched = get_status('ep_bg_fetched')
cmd_get = get_status('cmd_get')
if cmd_get == 0:
check_levels('CB cache miss ratio', 0, False)
else:
status_value = ep_bg_fetched * 1.0 / cmd_get
check_levels('CB cache miss ratio', status_value, False)
def check_disk_reads_per_sec(result):
"""number of reads per second from disk for specific bucket"""
if result is None:
status_value = get_status('ep_bg_fetched')
else:
op = result['op']
samples = op['samples']
status_value = samples['ep_bg_fetched'].pop()
check_levels('CB disk read per sec', status_value, True)
def check_item_count(result):
"""item count for specific bucket"""
if result is None:
status_value = get_status('curr_items')
else:
op = result['op']
samples = op['samples']
status_value = samples['curr_items'].pop()
check_levels('CB item count', status_value, False)
def check_ops_per_second(result):
"""total operations per second"""
if result is None:
cmd_get = get_status('cmd_get')
cmd_set = get_status('cmd_set')
incr_misses = get_status('incr_misses')
incr_hits = get_status('incr_hits')
decr_misses = get_status('decr_misses')
decr_hits = get_status('decr_hits')
delete_misses = get_status('delete_misses')
delete_hits = get_status('delete_hits')
else:
op = result['op']
samples = op['samples']
cmd_get = samples['cmd_get'].pop()
cmd_set = samples['cmd_set'].pop()
incr_misses = samples['incr_misses'].pop()
incr_hits = samples['incr_hits'].pop()
decr_misses = samples['decr_misses'].pop()
decr_hits = samples['decr_hits'].pop()
delete_misses = samples['delete_misses'].pop()
delete_hits = samples['delete_hits'].pop()
status_value = cmd_get + cmd_set + incr_misses + incr_hits + decr_misses
status_value += decr_hits + delete_misses + delete_hits
check_levels('CB ops per sec', status_value, True)
def check_memory_used(result):
"""total amount of ram used by specific bucket"""
if result is None:
status_value = get_status('mem_used')
else:
op = result['op']
samples = op['samples']
status_value = samples['mem_used'].pop()
check_levels('CB memory used', status_value, True)
def check_percent_memory_used(result):
"""percentage of available ram used by specific bucket"""
if result is None:
mem_used = get_status('mem_used')
max_size = get_status('ep_max_size')
else:
op = result['op']
samples = op['samples']
mem_used = samples['mem_used'].pop()
max_size = samples['ep_max_size'].pop()
status_value = mem_used / max_size * 100
check_levels('CB percentage of memory used', status_value, False)
def check_cas_per_sec(result):
"""number of CAS operations per sec for data
that specific bucket contains"""
if result is None:
status_value = get_status('cas_hits')
else:
op = result['op']
samples = op['samples']
status_value = samples['cas_hits'].pop()
check_levels('CB cas per sec', status_value, True)
def check_deletes_per_sec(result):
"""number of delete operations per second for specific bucket"""
if result is None:
status_value = get_status('delete_hits')
else:
op = result['op']
samples = op['samples']
status_value = samples['delete_hits'].pop()
check_levels("CB delete per sec: ", status_value, True)
def check_low_watermark(result):
"""low water mark for memory usage"""
if result is None:
status_value = get_status('ep_mem_low_wat')
check_levels('CB low watermark', status_value, True)
else:
op = result['op']
samples = op['samples']
ep_mem_low_wat = samples['ep_mem_low_wat']
status_value = ep_mem_low_wat.pop()
check_levels('CB low watermark', status_value, True)
def check_high_watermark(result):
"""high water mark for memory usage"""
if result is None:
status_value = get_status('ep_mem_high_wat')
else:
op = result['op']
samples = op['samples']
status_value = samples['ep_mem_high_wat'].pop()
check_levels('CB high watermark', status_value, True)
def http_warnings(return_code):
""" returns http warnings codes"""
if r.status_code == requests.codes.created:
print "No HTTP response body returns - 201 error"
return sys.exit(2)
elif r.status_code == requests.codes.accepted:
print "Request proccessing is not complete - 202 error"
return sys.exit(2)
elif r.status_code == requests.codes.no_content:
print "No content - 204 error"
return sys.exit(2)
elif r.status_code == requests.codes.bad_request:
print "Bad request - 400 error"
return sys.exit(2)
elif r.status_code == requests.codes.unauthorized:
print "Unauthorized - 401 error"
return sys.exit(2)
elif r.status_code == requests.codes.forbidden:
print "Forbidden - 403 error"
return sys.exit(2)
elif r.status_code == requests.codes.not_found:
print "Not found - 404 error"
return sys.exit(2)
elif r.status_code == requests.codes.not_acceptable:
print "Not acceptable - error 406 error"
return sys.exit(2)
elif r.status_code == requests.codes.conflict:
print "Conflict error- 409 error"
return sys.exit(2)
elif r.status_code == requests.codes.internal_server_error:
print "Internal server error - 500 error"
return sys.exit(2)
elif r.status_code == requests.codes.not_implemented:
print "Not Implemented - 501 error"
return sys.exit(2)
elif r.status_code == requests.codes.service_unavailable:
print "Service error - 503 error"
return sys.exit(2)
def which_argument(result):
"""calls related option for the choosen option"""
if options.operations_per_second:
check_ops_per_second(result)
if options.cas:
check_cas_per_sec(result)
if options.high_watermark:
check_high_watermark(result)
if options.low_watermark:
check_low_watermark(result)
if options.deletes_per_sec:
check_deletes_per_sec(result)
if options.memory_used:
check_memory_used(result)
if options.percent_memory_used:
check_percent_memory_used(result)
if options.disk_reads_per_sec:
check_disk_reads_per_sec(result)
if options.item_count:
check_item_count(result)
if options.cache_miss_ratio:
check_cache_miss_ratio()
if options.disk_creates_per_sec:
check_disk_creates_per_sec(result)
if options.disk_updates_per_sec:
check_disk_updates_per_sec(result)
if options.sets_per_sec:
check_sets_per_sec(result)
if options.disk_write_queue:
check_disk_write_queue(result)
if options.gets_per_sec:
check_gets_per_sec(result)
if options.vbucket_count and options.vbucket:
if options.active:
check_vbucket('vb_active_num', 'CB active vBucket count',
False, result)
elif options.replica:
check_vbucket('vb_replica_num', 'CB replica vBucket count',
False, result)
elif options.pending:
check_vbucket('vb_pending_num', 'CB pending vBucket count',
False, result)
elif options.total:
check_vbucket('ep_vb_total', 'CB total vBucket count',
False, result)
else:
print "wrong options combination"
return sys.exit(2)
if options.vbucket_items and options.vbucket:
if options.active:
check_vbucket('curr_items', 'CB active vBucket items',
True, result)
elif options.replica:
check_vbucket('vb_replica_curr_items', 'CB replica vBucket items',
True, result)
elif options.pending:
check_vbucket('vb_pending_curr_items', 'CB pending vBucket items',
True, result)
elif options.total:
check_vbucket('curr_items_tot', 'CB total vBucket items',
True, result)
else:
print "wrong options combination"
return sys.exit(2)
if options.vbucket_new_items and options.vbucket:
if options.active:
check_vbucket('vb_active_ops_create', 'CB active vBucket new items',
True, result)
elif options.replica:
check_vbucket('vb_replica_ops_create', 'CB replica vBucket new items',
True, result)
elif options.pending:
check_vbucket('vb_pending_ops_create', 'CB pending vBucket new items',
True, result)
else:
print "wrong options combination"
return sys.exit(2)
if options.vbucket_ejections and options.vbucket:
if options.active:
check_vbucket('vb_active_eject', 'CB active vBucket ejections',
True, result)
elif options.replica:
check_vbucket('vb_replica_eject', 'CB replica vBucket ejections',
True, result)
elif options.pending:
check_vbucket('vb_pending_eject', 'CB pending vBucket ejections ',
True, result)
elif options.total:
check_vbucket('ep_num_value_ejects', 'CB total vBucket ejections',
True, result)
else:
print "wrong options combination"
return sys.exit(2)
if options.vbucket_user_data_ram and options.vbucket:
if options.active:
check_vbucket('vb_active_itm_memory', 'CB active vBucket user data',
True, result)
elif options.replica:
check_vbucket('vb_replica_itm_memory', 'CB replica vBucket user data',
True, result)
elif options.pending:
check_vbucket('vb_pending_itm_memory', 'CB pending vBucket user data',
True, result)
elif options.total:
check_vbucket('ep_kv_size', 'CB total vBucket user data',
True, result)
else:
print "wrong options combination"
sys.exit(2)
if options.vbucket_meta_data_ram and options.vbucket:
if options.active:
check_vbucket('vb_active_meta_data_memory', 'CB active vBucket meta data',
True, result)
elif options.replica:
check_vbucket('vb_replica_meta_data_memory', 'CB replica vBucket meta data',
True, result)
elif options.pending:
check_vbucket('vb_pending_meta_data_memory', 'CB pending vBucket meta data',
True, result)
else:
print "wrong options combination"
sys.exit(2)
if options.disk_queues_items and options.disk_queues:
if options.active:
check_disk_queues('vb_active_queue_size', 'CB active disk Queues items',
True, result)
elif options.replica:
check_disk_queues('vb_replica_queue_size', 'CB replica disk Queues items',
True, result)
elif options.pending:
check_disk_queues('vb_pending_queue_size', 'CB pending disk Queues items',
True, result)
elif options.total:
check_disk_queues('vb_total_queue_size', 'CB total disk Queues items',
True, result)
else:
print "wrong options combination"
return sys.exit(2)
if options.disk_queues_fill_rate and options.disk_queues:
if options.pending:
check_disk_queues('vb_pending_queue_fill', 'CB pending disk Queues fill rate',
True, result)
else:
print "wrong options combination"
sys.exit(2)
if options.disk_queues_drain_rate and options.disk_queues:
if options.pending:
check_disk_queues('vb_pending_queue_drain', 'CB pending disk Queues drain rate',
True, result)
else:
print "wrong options combination"
sys.exit(2)
else:
print "wrong options combination"
return sys.exit(2)
# option parse
parser = OptionParser()
parser.disable_interspersed_args()
arg = False
# option define
parser.add_option('-I', dest='ip', help='Ip adress')
parser.add_option('-u', dest='username',
help='User name for CouchBase')
parser.add_option('-p', dest='password',
help='password for CouchBase authorization')
parser.add_option('-P', '--port', dest='port',
help='Port for CouchBase')
parser.add_option('-b', '--bucket', dest='bucket',
help='A bucket name on CouchBase')
parser.add_option('-W', type='int', dest='warning',
help='Warning treshold for statistic on CouchBase')
parser.add_option('-C', type='int', dest='critical',
help='Critical threshold for statistic on CouchBase')
parser.add_option('--OPS', '--operations-per-sec', action='callback',
callback=option_none, dest='operations_per_second',
help='Operations per second for specific bucket on Couchbase')
parser.add_option('--memory-used', action='callback',
callback=option_none, dest='memory_used',
help='Memory used for specific bucket on Couchbase')
parser.add_option('--percent-memory-used', action='callback',
callback=option_none, dest='percent_memory_used',
help='Percentage of memory used for specific bucket on Couchbase')
parser.add_option('--disk-reads-per-sec', action='callback',
callback=option_none, dest='disk_reads_per_sec',
help='Disk reads per second for specific bucket on Couchbase')
parser.add_option('--item-count', action='callback',
callback=option_none, dest='item_count',
help='Item counts for specific bucket on Couchbase')
parser.add_option('--CAS', action='callback',
callback=option_none, dest='cas',
help='Check and set operations on CouchBase')
parser.add_option('--deletes-per-sec', action='callback',
callback=option_none, dest='deletes_per_sec',
help='Deletes per second for specific bucket on Couchbase')
parser.add_option('--low-watermark', action='callback',
callback=option_none, dest='low_watermark',
help='Low watermark for specific bucket on Couchbase')
parser.add_option('--high-watermark', action='callback',
callback=option_none, dest='high_watermark',
help='High watermark for specific bucket on Couchbase')
parser.add_option('--cbstats', default='/opt/couchbase/bin/cbstats',
dest='cbstats',
help='cbstats command full path for nagios plugin couchbase')
parser.add_option('--cache-miss-ratio', action='callback',
callback=option_none, dest='cache_miss_ratio',
help='Percentage of reads per second from specific bucket')
parser.add_option('--disk-creates-per-sec', action='callback',
callback=option_none, dest='disk_creates_per_sec',
help='Disk creates per second check for Couchbase statistic')
parser.add_option('--disk-updates-per-sec', action='callback',
callback=option_none, dest='disk_updates_per_sec',
help='Disk updates per second')
parser.add_option('--sets-per-sec', action='callback',
callback=option_none, dest='sets_per_sec',
help='Number of set/update operations per second for specific bucket')
parser.add_option('--gets-per-sec', action='callback',
callback=option_none, dest='gets_per_sec',
help='Number of get operations serviced by specific bucket')
parser.add_option('--disk-write-queue', action='callback',
callback=option_none, dest='disk_write_queue',
help='Size of the disk write queue for specific bucket')
parser.add_option('--vbucket-count', action='callback',
callback=option_none, dest='vbucket_count',
help='The number of vBuckets within the specified state')
parser.add_option('--vbucket', action='callback',
callback=option_none, dest='vbucket',
help='Any of vBuckets resources checks')
parser.add_option('--active', action='callback',
callback=option_none, dest='active',
help='active state for vBuckets')
parser.add_option('--replica', action='callback',
callback=option_none, dest='replica',
help='replica state for vBuckets')
parser.add_option('--pending', action='callback',
callback=option_none, dest='pending',
help='pending state for vBuckets')
parser.add_option('--total', action='callback',
callback=option_none, dest='total',
help='total state for vBuckets')
parser.add_option('--items', action='callback',
callback=option_none, dest='vbucket_items',
help='Number of items within the vBucket of the specified state')
parser.add_option('--resident', action='callback',
callback=option_none, dest='vbucket_resident',
help='Percentage of items within the vBuckets of the specified state \
that are resident (in RAM)')
parser.add_option('--new-items', action='callback',
callback=option_none, dest='vbucket_new_items',
help='Number of new items created in vBuckets')
parser.add_option('--ejections', action='callback',
callback=option_none, dest='vbucket_ejections',
help='Number of items ejected per second within \
the vBuckets of the specified state')
parser.add_option('--user-data-ram', action='callback',
callback=option_none, dest='vbucket_user_data_ram',
help='Size of user data within vBuckets of the specified state \
that are resident in RAM')
parser.add_option('--meta-data-ram', action='callback',
callback=option_none, dest='vbucket_meta_data_ram',
help='Size of item metadata within the vBuckets of the specified state \
that are resident in RAM')
parser.add_option('--disk-queues', action='callback',
callback=option_none, dest='disk_queues',
help='displays the information for data being placed into \
the disk queue')
parser.add_option('--disk-items', action='callback',
callback=option_none, dest='disk_queues_items',
help='The number of items waiting to be written to disk for \
this bucket for this state')
parser.add_option('--fill-rate', action='callback',
callback=option_none, dest='disk_queues_fill_rate',
help='The number of items per second being added to \
the disk queue for the corresponding state')
parser.add_option('--drain-rate', action='callback',
callback=option_none, dest='disk_queues_drain_rate',
help='Number of items actually written to disk from \
the disk queue for the corresponding state')
parser.add_option('--node', action='callback',
callback=option_none, dest='node',
help='get couchbase statistics at node level')
options, args = parser.parse_args()
try:
if options.node:
which_argument(None)
else:
url = ''.join(['http://', options.ip, ':', options.port,
'/pools/default/buckets/', options.bucket,
'/stats/'])
r = requests.get(url, auth=(options.username, options.password))
http_warnings(r.status_code)
result = r.json()
which_argument(result)
except Exception:
print "Invalid option combination"
print "Try '--help' for more information "
sys.exit(2)