2012-04-03 17:07:37 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- encoding: utf-8 -*-
|
|
|
|
#
|
|
|
|
# Swift monitoring script for munin
|
|
|
|
#
|
|
|
|
# Copyright © 2012 eNovance <licensing@enovance.com>
|
|
|
|
#
|
|
|
|
# Author: Julien Danjou <julien@danjou.info>
|
|
|
|
#
|
|
|
|
# This program 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.
|
|
|
|
#
|
|
|
|
# This program 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/>.
|
|
|
|
#
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import json
|
|
|
|
import os
|
|
|
|
import requests
|
|
|
|
|
|
|
|
try:
|
|
|
|
swift_server = sys.argv[0].split("_", 1)[1]
|
|
|
|
except:
|
|
|
|
print "E: Cannot find server name using script name"
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
try:
|
|
|
|
if sys.argv[1] == 'config':
|
|
|
|
print "graph_title Swift object replication time %s" % swift_server
|
|
|
|
print "graph_category swift"
|
|
|
|
print "graph_vlabel Time"
|
|
|
|
print "object_replication_time.type GAUGE"
|
|
|
|
print "object_replication_time.label Replication time"
|
|
|
|
sys.exit(0)
|
|
|
|
except IndexError:
|
|
|
|
pass
|
|
|
|
|
2013-05-17 10:36:29 +02:00
|
|
|
replication_r = requests.get("http://%s:%s/recon/replication" \
|
|
|
|
% (swift_server, os.getenv("SWIFT_OBJECT_PORT", "6000")))
|
2012-04-03 17:07:37 +02:00
|
|
|
print "object_replication_time.value %f" % json.loads(replication_r.text)['object_replication_time']
|