Plugin nova_floating_ips: migrate to Python3, format documentation
This commit is contained in:
parent
db7403f2d4
commit
d168d49ee4
|
@ -1,18 +1,36 @@
|
|||
#!/usr/bin/env python
|
||||
#
|
||||
# Plugin to monitor status of Floating IPs in Nova
|
||||
#
|
||||
# To monitor a floating ips, link floating_ips to this file.
|
||||
# E.g.
|
||||
# ln -s /usr/share/munin/plugins/nova_floating_ips /etc/munin/plugins/
|
||||
#
|
||||
# Needs following minimal configuration in plugin-conf.d/nova:
|
||||
# [nova_*]
|
||||
# user nova
|
||||
#
|
||||
# Magic markers
|
||||
#%# capabilities=autoconf
|
||||
#%# family=auto
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
|
||||
=head1 NAME
|
||||
|
||||
nova_floating_ips - monitor status of Floating IPs in Nova
|
||||
|
||||
|
||||
=head1 CONFIGURATION
|
||||
|
||||
To monitor a floating ips, link floating_ips to this file.
|
||||
E.g.
|
||||
|
||||
ln -s /usr/share/munin/plugins/nova_floating_ips /etc/munin/plugins/
|
||||
|
||||
Needs following minimal configuration in plugin-conf.d/nova:
|
||||
|
||||
[nova_*]
|
||||
user nova
|
||||
|
||||
|
||||
=head1 AUTHORS
|
||||
|
||||
Copyright 2012 Mehdi Abaakouk <sileht@sileht.net>
|
||||
|
||||
|
||||
=head1 MAGIC MARKERS
|
||||
|
||||
#%# capabilities=autoconf
|
||||
#%# family=auto
|
||||
|
||||
=cut
|
||||
"""
|
||||
|
||||
import sys
|
||||
|
||||
|
@ -27,21 +45,21 @@ else:
|
|||
successful_import = True
|
||||
|
||||
|
||||
|
||||
states = ['total', 'allocated', 'associated']
|
||||
|
||||
|
||||
def print_config():
|
||||
global states
|
||||
print 'graph_title Nova Floating IPs'
|
||||
print 'graph_vlabel IPs'
|
||||
print 'graph_args --base 1000 --lower-limit 0'
|
||||
print 'graph_category cloud'
|
||||
print 'graph_scale no'
|
||||
print 'graph_info This graph shows the number of Floating IPs in Nova and their status'
|
||||
print('graph_title Nova Floating IPs')
|
||||
print('graph_vlabel IPs')
|
||||
print('graph_args --base 1000 --lower-limit 0')
|
||||
print('graph_category cloud')
|
||||
print('graph_scale no')
|
||||
print('graph_info This graph shows the number of Floating IPs in Nova and their status')
|
||||
for state in states:
|
||||
print '%s.label %s' % (state, state)
|
||||
print '%s.draw LINE2' % state
|
||||
print '%s.info %s IPs' % (state, state)
|
||||
print('%s.label %s' % (state, state))
|
||||
print('%s.draw LINE2' % state)
|
||||
print('%s.info %s IPs' % (state, state))
|
||||
|
||||
|
||||
def get_status():
|
||||
|
@ -63,8 +81,8 @@ def get_status():
|
|||
|
||||
def print_values():
|
||||
status = get_status()
|
||||
for (state, value) in status.iteritems():
|
||||
print "%s.value %s" % (state, value)
|
||||
for (state, value) in status.items():
|
||||
print("%s.value %s" % (state, value))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -73,10 +91,10 @@ if __name__ == '__main__':
|
|||
print_config()
|
||||
elif sys.argv[1] == "autoconf":
|
||||
if not successful_import:
|
||||
print 'no (failed import nova module)'
|
||||
print('no (failed import nova module)')
|
||||
sys.exit(0)
|
||||
else:
|
||||
print 'yes'
|
||||
print('yes')
|
||||
elif successful_import:
|
||||
utils.default_flagfile()
|
||||
flags.FLAGS(sys.argv)
|
||||
|
|
|
@ -270,7 +270,6 @@ plugins/nginx/nginx-cache-multi_
|
|||
plugins/nginx/nginx_upstream
|
||||
plugins/nginx/nginx_vhost_traffic
|
||||
plugins/nginx/nginx_working_set
|
||||
plugins/nova/nova_floating_ips
|
||||
plugins/nova/nova_instance_
|
||||
plugins/nova/nova_instance_launched
|
||||
plugins/nova/nova_instance_timing
|
||||
|
|
Loading…
Reference in New Issue