diff options
Diffstat (limited to 'build/lib/Bcfg2/Server/Admin/Perf.py')
-rw-r--r-- | build/lib/Bcfg2/Server/Admin/Perf.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/build/lib/Bcfg2/Server/Admin/Perf.py b/build/lib/Bcfg2/Server/Admin/Perf.py new file mode 100644 index 000000000..6f1cb8dbb --- /dev/null +++ b/build/lib/Bcfg2/Server/Admin/Perf.py @@ -0,0 +1,37 @@ +import Bcfg2.Options +import Bcfg2.Proxy +import Bcfg2.Server.Admin + +import sys + +class Perf(Bcfg2.Server.Admin.Mode): + __shorthelp__ = ("Query server for performance data") + __longhelp__ = (__shorthelp__ + "\n\nbcfg2-admin perf") + __usage__ = ("bcfg2-admin perf") + + def __init__(self, configfile): + Bcfg2.Server.Admin.Mode.__init__(self, configfile) + + def __call__(self, args): + output = [('Name', 'Min', 'Max', 'Mean', 'Count')] + optinfo = { + 'ca': Bcfg2.Options.CLIENT_CA, + 'certificate': Bcfg2.Options.CLIENT_CERT, + 'key': Bcfg2.Options.SERVER_KEY, + 'password': Bcfg2.Options.SERVER_PASSWORD, + 'server': Bcfg2.Options.SERVER_LOCATION, + 'user': Bcfg2.Options.CLIENT_USER, + } + setup = Bcfg2.Options.OptionParser(optinfo) + setup.parse(sys.argv[2:]) + proxy = Bcfg2.Proxy.ComponentProxy(setup['server'], + setup['user'], + setup['password'], + key = setup['key'], + cert = setup['certificate'], + ca = setup['ca']) + data = proxy.get_statistics() + for key, value in data.iteritems(): + data = tuple(["%.06f" % (item) for item in value[:-1]] + [value[-1]]) + output.append((key, ) + data) + self.print_table(output) |