From b0545531c7bd9b591ea8794133d408de2504c4df Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Tue, 3 Apr 2012 17:07:37 +0200 Subject: [PATCH] Add Swift plugins Signed-off-by: Julien Danjou --- plugins/swift/swift-async_ | 48 ++++++++++++++++++ plugins/swift/swift-dispersion | 72 +++++++++++++++++++++++++++ plugins/swift/swift-quarantined_ | 56 +++++++++++++++++++++ plugins/swift/swift-replication-time_ | 48 ++++++++++++++++++ 4 files changed, 224 insertions(+) create mode 100755 plugins/swift/swift-async_ create mode 100755 plugins/swift/swift-dispersion create mode 100755 plugins/swift/swift-quarantined_ create mode 100755 plugins/swift/swift-replication-time_ diff --git a/plugins/swift/swift-async_ b/plugins/swift/swift-async_ new file mode 100755 index 00000000..8fc19dee --- /dev/null +++ b/plugins/swift/swift-async_ @@ -0,0 +1,48 @@ +#!/usr/bin/env python +# -*- encoding: utf-8 -*- +# +# Swift monitoring script for munin +# +# Copyright © 2012 eNovance +# +# Author: Julien Danjou +# +# 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 . +# + +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 async pending %s" % swift_server + print "graph_category swift" + print "async_pending.type GAUGE" + print "async_pending.label Async pending" + print "async_pending.draw AREA" + sys.exit(0) +except IndexError: + pass + +async_r = requests.get("http://%s:%d/recon/async" \ + % (swift_server, os.getenv("SWIFT_OBJECT_PORT", 6000))) +print "async_pending.value %d" % json.loads(async_r.text)['async_pending'] diff --git a/plugins/swift/swift-dispersion b/plugins/swift/swift-dispersion new file mode 100755 index 00000000..e512656d --- /dev/null +++ b/plugins/swift/swift-dispersion @@ -0,0 +1,72 @@ +#!/usr/bin/env python +# -*- encoding: utf-8 -*- +# +# Swift monitoring script for munin +# +# Copyright © 2012 eNovance +# +# Author: Julien Danjou +# +# 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 . +# + +import os +import sys +import json + +try: + if sys.argv[1] == "config": + print 'graph_title Swift cluster dispersion' + print 'graph_category swift' + + print 'object_missing_two.type GAUGE' + print 'object_missing_two.label Objects missing two copies' + print 'object_retries.type GAUGE' + print 'object_retries.label Objects retries' + print 'object_copies_expected.type GAUGE' + print 'object_copies_expected.label Objects copies expected' + print 'object_missing_one.type GAUGE' + print 'object_missing_one.label Objects missing one copy' + print 'object_copies_found.type GAUGE' + print 'object_copies_found.label Objects copies found' + print 'object_missing_all.type GAUGE' + print 'object_missing_all.label Objects missing all copies' + print 'object_overlapping.type GAUGE' + print 'object_overlapping.label Objects overlapping partitions' + + print 'container_missing_two.type GAUGE' + print 'container_missing_two.label Containers missing two copies' + print 'container_retries.type GAUGE' + print 'container_retries.label Containers retries' + print 'container_copies_expected.type GAUGE' + print 'container_copies_expected.label Containers copies expected' + print 'container_missing_one.type GAUGE' + print 'container_missing_one.label Containers missing one copy' + print 'container_copies_found.type GAUGE' + print 'container_copies_found.label Containers copies found' + print 'container_missing_all.type GAUGE' + print 'container_missing_all.label Containers missing all copies' + print 'container_overlapping.type GAUGE' + print 'container_overlapping.label Containers overlapping paritions' + sys.exit(0) +except IndexError: + pass + +with os.popen("swift-dispersion-report -j %s" \ + % os.getenv("SWIFT_DISPERSION_CONFIG", "/etc/swift/swift.conf")) as report: + stats = json.load(report) + +for type_, values in stats.iteritems(): + for key, value in values.iteritems(): + print "%s_%s.value %d" % (type_, key, value) diff --git a/plugins/swift/swift-quarantined_ b/plugins/swift/swift-quarantined_ new file mode 100755 index 00000000..9029ba2a --- /dev/null +++ b/plugins/swift/swift-quarantined_ @@ -0,0 +1,56 @@ +#!/usr/bin/env python +# -*- encoding: utf-8 -*- +# +# Swift monitoring script for munin +# +# Copyright © 2012 eNovance +# +# Author: Julien Danjou +# +# 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 . +# + +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 objects quarantined %s" % swift_server + print "graph_category swift" + print "quarantined_objects.type GAUGE" + print "quarantined_objects.draw AREA" + print "quarantined_objects.label Quarantined objects" + print "quarantined_containers.type GAUGE" + print "quarantined_containers.area STACK" + print "quarantined_containers.label Quarantined containers" + print "quarantined_accounts.type GAUGE" + print "quarantined_accounts.draw STACK" + print "quarantined_accounts.label Quarantined accounts" + sys.exit(0) +except IndexError: + pass + +quarantined = json.loads(requests.get("http://%s:%d/recon/quarantined" \ + % (swift_server, os.getenv("SWIFT_OBJECT_PORT", 6000))).text) +print "quarantined_objects.value %d" % quarantined['objects'] +print "quarantined_containers.value %d" % quarantined['containers'] +print "quarantined_accounts.value %d" % quarantined['accounts'] diff --git a/plugins/swift/swift-replication-time_ b/plugins/swift/swift-replication-time_ new file mode 100755 index 00000000..eeeb3124 --- /dev/null +++ b/plugins/swift/swift-replication-time_ @@ -0,0 +1,48 @@ +#!/usr/bin/env python +# -*- encoding: utf-8 -*- +# +# Swift monitoring script for munin +# +# Copyright © 2012 eNovance +# +# Author: Julien Danjou +# +# 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 . +# + +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 + +replication_r = requests.get("http://%s:%d/recon/replication" \ + % (swift_server, os.getenv("SWIFT_OBJECT_PORT", 6000))) +print "object_replication_time.value %f" % json.loads(replication_r.text)['object_replication_time']