root / plugins / swift / swift-dispersion @ 0ddf0181
Historique | Voir | Annoter | Télécharger (2,9 ko)
| 1 |
#!/usr/bin/env python |
|---|---|
| 2 |
# -*- encoding: utf-8 -*- |
| 3 |
# |
| 4 |
# Swift monitoring script for munin |
| 5 |
# |
| 6 |
# Copyright © 2012 eNovance <licensing@enovance.com> |
| 7 |
# |
| 8 |
# Author: Julien Danjou <julien@danjou.info> |
| 9 |
# |
| 10 |
# This program is free software: you can redistribute it and/or modify |
| 11 |
# it under the terms of the GNU General Public License as published by |
| 12 |
# the Free Software Foundation, either version 3 of the License, or |
| 13 |
# (at your option) any later version. |
| 14 |
# |
| 15 |
# This program is distributed in the hope that it will be useful, |
| 16 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 |
# GNU General Public License for more details. |
| 19 |
# |
| 20 |
# You should have received a copy of the GNU General Public License |
| 21 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 22 |
# |
| 23 |
|
| 24 |
import os |
| 25 |
import sys |
| 26 |
import json |
| 27 |
|
| 28 |
try: |
| 29 |
if sys.argv[1] == "config": |
| 30 |
print 'graph_title Swift cluster dispersion' |
| 31 |
print 'graph_category swift' |
| 32 |
|
| 33 |
print 'object_missing_two.type GAUGE' |
| 34 |
print 'object_missing_two.label Objects missing two copies' |
| 35 |
print 'object_retries.type GAUGE' |
| 36 |
print 'object_retries.label Objects retries' |
| 37 |
print 'object_copies_expected.type GAUGE' |
| 38 |
print 'object_copies_expected.label Objects copies expected' |
| 39 |
print 'object_missing_one.type GAUGE' |
| 40 |
print 'object_missing_one.label Objects missing one copy' |
| 41 |
print 'object_copies_found.type GAUGE' |
| 42 |
print 'object_copies_found.label Objects copies found' |
| 43 |
print 'object_missing_all.type GAUGE' |
| 44 |
print 'object_missing_all.label Objects missing all copies' |
| 45 |
print 'object_overlapping.type GAUGE' |
| 46 |
print 'object_overlapping.label Objects overlapping partitions' |
| 47 |
|
| 48 |
print 'container_missing_two.type GAUGE' |
| 49 |
print 'container_missing_two.label Containers missing two copies' |
| 50 |
print 'container_retries.type GAUGE' |
| 51 |
print 'container_retries.label Containers retries' |
| 52 |
print 'container_copies_expected.type GAUGE' |
| 53 |
print 'container_copies_expected.label Containers copies expected' |
| 54 |
print 'container_missing_one.type GAUGE' |
| 55 |
print 'container_missing_one.label Containers missing one copy' |
| 56 |
print 'container_copies_found.type GAUGE' |
| 57 |
print 'container_copies_found.label Containers copies found' |
| 58 |
print 'container_missing_all.type GAUGE' |
| 59 |
print 'container_missing_all.label Containers missing all copies' |
| 60 |
print 'container_overlapping.type GAUGE' |
| 61 |
print 'container_overlapping.label Containers overlapping paritions' |
| 62 |
sys.exit(0) |
| 63 |
except IndexError: |
| 64 |
pass |
| 65 |
|
| 66 |
with os.popen("swift-dispersion-report -j %s" \
|
| 67 |
% os.getenv("SWIFT_DISPERSION_CONFIG", "/etc/swift/swift.conf")) as report:
|
| 68 |
stats = json.load(report) |
| 69 |
|
| 70 |
for type_, values in stats.iteritems(): |
| 71 |
for key, value in values.iteritems(): |
| 72 |
print "%s_%s.value %d" % (type_, key, value) |
