Example #1
0
def print_http_status(server, url):
    """Print status of HTTP-based server."""

    try:
        r = requests.get(url, verify=False)
        r.raise_for_status()
        print("{}: {}".format(server, highlight("RUNNING")))
    except Exception, e:
        print("{}: {}".format(server, blink(highlight("NOT RUNNING", 'red', True))))
        print(e)
Example #2
0
def print_es_status(host):
    """Print status of ES server."""

    try:
        es = elasticsearch.Elasticsearch([host], verify_certs=False)
        es.ping()
        print("ES: ", highlight("RUNNING"))
    except Exception, e:
        print("ES: ", blink(highlight("NOT RUNNING", 'red', True)))
        print(e)
Example #3
0
def print_redis_status(password, host):
    """Print status of redis server."""

    try:
        r = redis.StrictRedis(host, password=password)
        r.ping()
        print("Redis: ", highlight("RUNNING"))
    except Exception, e:
        print("Redis: ", blink(highlight("NOT RUNNING", 'red', True)))
        print(e)
Example #4
0
def print_service_status(service, ret, debug=False):
    """Print status of service based on systemctl status message."""

    stdout = ret[ret.keys()[0]]
    status_match = re.search(r'Active:\s+(.+?)\s+', stdout)
    if not status_match:
        raise RuntimeError("Failed to extract status of {} from stdout:\n{}".format(service, stdout))
    status = status_match.group(1)
    if status == 'active':
        print("{}: {}".format(service, highlight(status.upper())))
    else:
        print("{}: {}".format(service, blink(highlight(status.upper(), 'red'))))
    if debug: print(stdout)
Example #5
0
def print_rabbitmq_status(user, password, host):
    """Print status of RabbitMQ server."""

    amqp_url = "amqp://{user}:{password}@{host}:5672//".format(
        user=user, password=password, host=host)
    logger.debug("amqp_url: {}".format(amqp_url))
    try:
        conn = kombu.Connection(amqp_url)
        conn.ensure_connection(max_retries=3)
        print(("RabbitMQ: ", highlight("RUNNING")))
    except Exception as e:
        print(("RabbitMQ: ", blink(highlight("NOT RUNNING", 'red', True))))
        print(e)
Example #6
0
def ls(args):
    """List HySDS packages."""

    # get user's SDS conf settings
    conf = SettingsConf()

    # check which cloud platforms configured
    for importer, mod_name, ispkg in pkgutil.iter_modules(
            sdscli.cloud.__path__):
        mod = get_module('sdscli.cloud.{}.utils'.format(mod_name))
        print("{}: {}".format(
            mod_name,
            highlight("configured", 'green') if mod.is_configured() else
            highlight("unimplemented or not configured", 'red')))
Example #7
0
def status():
    role, hysds_dir, hostname = resolve_role()
    if exists('%s/run/supervisor.sock' % hysds_dir):
        with prefix('source %s/bin/activate' % hysds_dir):
            run('supervisorctl status')
    else:
        print(blink(highlight("Supervisord is not running on %s." % role, 'red')))