2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00

Merge pull request #78 from jd/master

Add Swift plugins
This commit is contained in:
Kenyon Ralph 2012-04-04 10:38:50 -07:00
commit aa2691a4c2
4 changed files with 224 additions and 0 deletions

48
plugins/swift/swift-async_ Executable file
View File

@ -0,0 +1,48 @@
#!/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 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']

72
plugins/swift/swift-dispersion Executable file
View File

@ -0,0 +1,72 @@
#!/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 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)

View File

@ -0,0 +1,56 @@
#!/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 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']

View File

@ -0,0 +1,48 @@
#!/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
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']