root / plugins / swift / swift-replication-time_ @ 8af08143
Historique | Voir | Annoter | Télécharger (1,57 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 sys |
| 25 |
import json |
| 26 |
import os |
| 27 |
import requests |
| 28 |
|
| 29 |
try: |
| 30 |
swift_server = sys.argv[0].split("_", 1)[1]
|
| 31 |
except: |
| 32 |
print "E: Cannot find server name using script name" |
| 33 |
sys.exit(1) |
| 34 |
|
| 35 |
try: |
| 36 |
if sys.argv[1] == 'config': |
| 37 |
print "graph_title Swift object replication time %s" % swift_server |
| 38 |
print "graph_category swift" |
| 39 |
print "graph_vlabel Time" |
| 40 |
print "object_replication_time.type GAUGE" |
| 41 |
print "object_replication_time.label Replication time" |
| 42 |
sys.exit(0) |
| 43 |
except IndexError: |
| 44 |
pass |
| 45 |
|
| 46 |
replication_r = requests.get("http://%s:%s/recon/replication" \
|
| 47 |
% (swift_server, os.getenv("SWIFT_OBJECT_PORT", "6000")))
|
| 48 |
print "object_replication_time.value %f" % json.loads(replication_r.text)['object_replication_time'] |
