Ejemplo n.º 1
0
#!/usr/bin/python

import sys

import Cobalt.Logging
from Cobalt.Proxy import ComponentProxy
from Cobalt.Exceptions import ComponentLookupError
from Cobalt.Util import print_tabular

if __name__ == '__main__':
    components = sys.argv[1:]
    to_print = [('Name', 'Min', 'Max', 'Mean')]
    for component in components:
        c = ComponentProxy(component, defer=False)
        data = c.get_statistics()
        for key, value in data.iteritems():
            to_print.append(("%s.%s" % (component, key), ) + tuple(value))
    print_tabular(to_print)

Ejemplo n.º 2
0
        level = 20
    Cobalt.Logging.setup_logging('cmd', to_syslog=False, level=level)
    
    try:
        slp = Cobalt.Proxy.ComponentProxy("service-location", defer=False)
    except ComponentLookupError:
        print >> sys.stderr, "unable to find service-location"
        sys.exit(1)
    try:
        services = slp.get_services([{'tag':'service', 'name':'*', 'stamp':'*', 'location':'*'}])
    except socket.error, e:
        print >> sys.stderr, "unable to connect to service-locator (%s)" % (e)
        sys.exit(1)
    except xmlrpclib.Fault, e:
        print >> sys.stderr, "RPC fault (%s)" % (e)
        sys.exit(1)
    
    if services:
        header = [('Name', 'Location', 'Update Time')]
        output = [
            (
                service['name'],
                service['location'],
                time.strftime("%c", time.localtime(service['stamp']))
            )
            for service in services
        ]
        print_tabular(header + [tuple(item) for item in output])
    else:
        print "no services registered"
Ejemplo n.º 3
0
        level = 20
    Cobalt.Logging.setup_logging('cmd', to_syslog=False, level=level)

    try:
        slp = Cobalt.Proxy.ComponentProxy("service-location", defer=False)
    except ComponentLookupError:
        print >> sys.stderr, "unable to find service-location"
        sys.exit(1)
    try:
        services = slp.get_services([{
            'tag': 'service',
            'name': '*',
            'stamp': '*',
            'location': '*'
        }])
    except socket.error, e:
        print >> sys.stderr, "unable to connect to service-locator (%s)" % (e)
        sys.exit(1)
    except xmlrpclib.Fault, e:
        print >> sys.stderr, "RPC fault (%s)" % (e)
        sys.exit(1)

    if services:
        header = [('Name', 'Location', 'Update Time')]
        output = [(service['name'], service['location'],
                   time.strftime("%c", time.localtime(service['stamp'])))
                  for service in services]
        print_tabular(header + [tuple(item) for item in output])
    else:
        print "no services registered"