From db7403f2d4fbb2d05532015348a6a3391eb7df6a Mon Sep 17 00:00:00 2001 From: Lars Kruse Date: Thu, 26 Nov 2020 00:17:07 +0100 Subject: [PATCH] Plugin swift-dispersion: migrate to Python3, format documentation --- plugins/swift/swift-dispersion | 60 ++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/plugins/swift/swift-dispersion b/plugins/swift/swift-dispersion index 73f0d3c5..56ecd112 100755 --- a/plugins/swift/swift-dispersion +++ b/plugins/swift/swift-dispersion @@ -1,25 +1,37 @@ -#!/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 . -# +#!/usr/bin/env python3 +""" + +=head1 NAME + +swift-dispersion - Swift monitoring script for munin + + +=head1 COPYRIGHT + +Copyright (C) 2012 eNovance + +Author: Julien Danjou + + +=head1 LICENSE + +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 . + +SPDX-License-Identifier: GPL-3.0-or-later + +=cut +""" import os import sys @@ -67,6 +79,6 @@ with os.popen("swift-dispersion-report -j %s" % os.getenv("SWIFT_DISPERSION_CONFIG", "/etc/swift/dispersion.conf")) as report: stats = json.load(report) -for type_, values in stats.iteritems(): - for key, value in values.iteritems(): +for type_, values in stats.items(): + for key, value in values.items(): print("%s_%s.value %d" % (type_, key, value))