Plugin swift-dispersion: migrate to Python3, format documentation

This commit is contained in:
Lars Kruse 2020-11-26 00:17:07 +01:00
parent bde90ba910
commit db7403f2d4
1 changed files with 36 additions and 24 deletions

View File

@ -1,25 +1,37 @@
#!/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/>.
#
#!/usr/bin/env python3
"""
=head1 NAME
swift-dispersion - Swift monitoring script for munin
=head1 COPYRIGHT
Copyright (C) 2012 eNovance <licensing@enovance.com>
Author: Julien Danjou <julien@danjou.info>
=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 <http://www.gnu.org/licenses/>.
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))