aboutsummaryrefslogtreecommitdiff
path: root/libvirt-cputime
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2020-03-30 10:08:06 +0200
committerGuido Günther <agx@sigxcpu.org>2020-03-30 10:11:47 +0200
commit1c4a4fb84bf470709541067665dbc232e2c12dd3 (patch)
tree32f9832b73be1f06b48af515d853b259dd28e075 /libvirt-cputime
parent35be326f61d8cedbd506ed78463fb182a245bc25 (diff)
flake8 cleanups
Diffstat (limited to 'libvirt-cputime')
-rw-r--r--libvirt-cputime10
1 files changed, 7 insertions, 3 deletions
diff --git a/libvirt-cputime b/libvirt-cputime
index d9f9e1b..e49d20e 100644
--- a/libvirt-cputime
+++ b/libvirt-cputime
@@ -17,9 +17,11 @@ from __future__ import print_function
import re, sys, os
import libvirt
+
def canon(name):
return re.sub(r"[^a-zA-Z0-9_]", "_", name)
+
def print_config(uri, stack):
"""print the plugin config, determine the domains"""
@@ -37,7 +39,7 @@ total_pc.info cputime used by all virtual machines
total_pc.warning 90
total_pc.critical 95""")
- draw = [ "LINE1", "AREA"][stack]
+ draw = ["LINE1", "AREA"][stack]
conn = libvirt.openReadOnly(uri)
ids = conn.listDomainsID()
for id in ids:
@@ -57,6 +59,7 @@ total_pc.critical 95""")
if draw == "AREA":
draw = "STACK"
+
def fetch_values(uri):
conn = libvirt.openReadOnly(uri)
ids = conn.listDomainsID()
@@ -81,10 +84,10 @@ def fetch_values(uri):
def main(sys):
uri = os.getenv("uri", "qemu:///system")
- stack = [ False, True ][os.getenv("stack") == "1"]
+ stack = [False, True][os.getenv("stack") == "1"]
if len(sys) > 1:
- if sys[1] in [ 'autoconf', 'detect' ]:
+ if sys[1] in ['autoconf', 'detect']:
if libvirt.openReadOnly(uri):
print("yes")
return 0
@@ -97,6 +100,7 @@ def main(sys):
fetch_values(uri)
return 0
+
if __name__ == "__main__":
sys.exit(main(sys.argv))