Пример #1
0
def _check_cinder_api():
    cinder = utils.Cinder()
    cinder.add_argument('-w', dest='warning', type=int, default=5,
                        help='Warning timeout for cinder APIs calls')
    cinder.add_argument('-c', dest='critical', type=int, default=10,
                        help='Critical timeout for cinder APIs calls')
    options, args, client = cinder.setup()

    def quotas_list():
        return client.quotas.get(options.os_tenant_name)

    elapsed, quotas = utils.timeit(quotas_list)
    if not quotas:
        utils.critical("Unable to contact cinder API.")

    if elapsed > options.critical:
        utils.critical("Get quotas took more than %d seconds, "
                       "it's too long.|response_time=%d" %
                       (options.critical, elapsed))
    elif elapsed > options.warning:
        utils.warning("Get quotas took more than %d seconds, "
                      "it's too long.|response_time=%d" %
                      (options.warning, elapsed))
    else:
        utils.ok("Get quotas, cinder API is working: "
                 "list quota in %d seconds.|response_time=%d" %
                 (elapsed, elapsed))
Пример #2
0
def _check_neutron_api():
    neutron = utils.Neutron()
    neutron.add_argument('-w', dest='warning', type=int, default=5,
                         help='Warning timeout for neutron APIs calls')
    neutron.add_argument('-c', dest='critical', type=int, default=10,
                         help='Critical timeout for neutron APIs calls')
    options, args, client = neutron.setup()

    def network_list():
        try:
            return client.list_networks()
        except Exception as ex:
            utils.critical(str(ex))

    elapsed, networks = utils.timeit(network_list)
    if not networks or len(networks.get('networks', [])) <= 0:
        utils.critical("Unable to contact neutron API.")

    if elapsed > options.critical:
        utils.critical("Get networks took more than %d seconds, "
                       "it's too long.|response_time=%d" %
                       (options.critical, elapsed))
    elif elapsed > options.warning:
        utils.warning("Get networks took more than %d seconds, "
                      "it's too long.|response_time=%d" %
                      (options.warning, elapsed))
    else:
        utils.ok("Get networks, neutron API is working: "
                 "list %d networks in %d seconds.|response_time=%d" %
                 (len(networks['networks']), elapsed, elapsed))
Пример #3
0
def _check_cinder_api():
    cinder = utils.Cinder()
    cinder.add_argument('-w', dest='warning', type=int, default=5,
                        help='Warning timeout for cinder APIs calls')
    cinder.add_argument('-c', dest='critical', type=int, default=10,
                        help='Critical timeout for cinder APIs calls')
    options, args, client = cinder.setup()

    def quotas_list():
        try:
            return client.quotas.get(options.os_tenant_name)
        except Exception as ex:
            utils.critical(str(ex))

    elapsed, quotas = utils.timeit(quotas_list)
    if not quotas:
        utils.critical("Unable to contact cinder API.")

    if elapsed > options.critical:
        utils.critical("Get quotas took more than %d seconds, "
                       "it's too long.|response_time=%d" %
                       (options.critical, elapsed))
    elif elapsed > options.warning:
        utils.warning("Get quotas took more than %d seconds, "
                      "it's too long.|response_time=%d" %
                      (options.warning, elapsed))
    else:
        utils.ok("Get quotas, cinder API is working: "
                 "list quota in %d seconds.|response_time=%d" %
                 (elapsed, elapsed))
Пример #4
0
def _check_nova_api():
    nova = utils.Nova()
    nova.add_argument('-w', dest='warning', type=int, default=5,
                      help='Warning timeout for nova APIs calls')
    nova.add_argument('-c', dest='critical', type=int, default=10,
                      help='Critical timeout for nova APIs calls')
    options, args, client = nova.setup()

    def flavors_list():
        try:
            return list(client.flavors.list())
        except Exception as ex:
            utils.critical(str(ex))

    elapsed, flavors = utils.timeit(flavors_list)
    if not flavors:
        utils.critical("Unable to contact nova API.")

    if elapsed > options.critical:
        utils.critical("Get flavors took more than %d seconds, "
                       "it's too long.|response_time=%d" %
                       (options.critical, elapsed))
    elif elapsed > options.warning:
        utils.warning("Get flavors took more than %d seconds, "
                      "it's too long.|response_time=%d" %
                      (options.warning, elapsed))
    else:
        utils.ok("Get flavors, nova API is working: "
                 "list %d flavors in %d seconds.|response_time=%d" %
                 (len(flavors), elapsed, elapsed))
Пример #5
0
def _check_cinder_api():
    cinder = utils.Cinder()
    cinder.add_argument('-w', dest='warning', type=int, default=5,
                        help='Warning timeout for cinder APIs calls')
    cinder.add_argument('-c', dest='critical', type=int, default=10,
                        help='Critical timeout for cinder APIs calls')
    options, args, client = cinder.setup()

    def limits_list():
        return client.limits.get()

    elapsed, limits = utils.timeit(limits_list)
    if not limits:
        utils.critical("Unable to contact cinder API.")

    if elapsed > options.critical:
        utils.critical("Get limits took more than %d seconds, "
                       "it's too long.|response_time=%d" %
                       (options.critical, elapsed))
    elif elapsed > options.warning:
        utils.warning("Get limits took more than %d seconds, "
                      "it's too long.|response_time=%d" %
                      (options.warning, elapsed))
    else:
        utils.ok("Get limits, cinder API is working: "
                 "list limits in %d seconds.|response_time=%d" %
                 (elapsed, elapsed))
Пример #6
0
def _check_glance_api():
    glance = utils.Glance()
    glance.add_argument('-w', dest='warning', type=int, default=5,
                        help='Warning timeout for Glance APIs calls')
    glance.add_argument('-c', dest='critical', type=int, default=10,
                        help='Critical timeout for Glance APIs calls')
    options, args, client = glance.setup()

    def images_list():
        try:
            return list(client.images.list())
        except Exception as ex:
            utils.critical(str(ex))

    elapsed, images = utils.timeit(images_list)
    if not images:
        utils.critical("Unable to contact Glance API.")

    if elapsed > options.critical:
        utils.critical("Get images took more than %d seconds, "
                       "it's too long.|response_time=%d" %
                       (options.critical, elapsed))
    elif elapsed > options.warning:
        utils.warning("Get images took more than %d seconds, "
                      "it's too long.|response_time=%d" %
                      (options.warning, elapsed))
    else:
        utils.ok("Get images, Glance API is working: "
                 "list %d images in %d seconds.|response_time=%d" %
                 (len(images), elapsed, elapsed))
def check_ceilometer_api():
    ceilometer = utils.Ceilometer()
    ceilometer.add_argument("-w", dest="warning", type=int, default=5, help="Warning timeout for Ceilometer APIs calls")
    ceilometer.add_argument(
        "-c", dest="critical", type=int, default=10, help="Critical timeout for Ceilometer APIs calls"
    )
    options, client = ceilometer.setup()

    elapsed, meters = utils.timeit(client.meters.list)
    if not meters:
        utils.critical("Unable to contact Ceilometer API.")

    if elapsed > options.critical:
        utils.critical(
            "Get meters took more than %d seconds, " "it's too long.|response_time=%d" % (options.critical, elapsed)
        )
    elif elapsed > options.warning:
        utils.warning(
            "Get meters took more than %d seconds, " "it's too long.|response_time=%d" % (options.warning, elapsed)
        )
    else:
        utils.ok(
            "Get meters, Ceilometer API is working: "
            "list %d meters in %d seconds.|response_time=%d" % (len(meters), elapsed, elapsed)
        )
Пример #8
0
def _check_neutron_api():
    neutron = utils.Neutron()
    neutron.add_argument('-w', dest='warning', type=int, default=5,
                         help='Warning timeout for neutron APIs calls')
    neutron.add_argument('-c', dest='critical', type=int, default=10,
                         help='Critical timeout for neutron APIs calls')
    options, args, client = neutron.setup()

    def network_list():
        try:
            return client.list_networks()
        except Exception as ex:
            utils.critical(str(ex))

    elapsed, networks = utils.timeit(network_list)
    if not networks or len(networks.get('networks', [])) <= 0:
        utils.critical("Unable to contact neutron API.")

    if elapsed > options.critical:
        utils.critical("Get networks took more than %d seconds, "
                       "it's too long.|response_time=%d" %
                       (options.critical, elapsed))
    elif elapsed > options.warning:
        utils.warning("Get networks took more than %d seconds, "
                      "it's too long.|response_time=%d" %
                      (options.warning, elapsed))
    else:
        utils.ok("Get networks, neutron API is working: "
                 "list %d networks in %d seconds.|response_time=%d" %
                 (len(networks['networks']), elapsed, elapsed))
Пример #9
0
def _check_nova_api():
    nova = utils.Nova()
    nova.add_argument('-w', dest='warning', type=int, default=5,
                      help='Warning timeout for nova APIs calls')
    nova.add_argument('-c', dest='critical', type=int, default=10,
                      help='Critical timeout for nova APIs calls')
    options, args, client = nova.setup()

    def flavors_list():
        return list(client.flavors.list())

    elapsed, flavors = utils.timeit(flavors_list)
    if not flavors:
        utils.critical("Unable to contact nova API.")

    if elapsed > options.critical:
        utils.critical("Get flavors took more than %d seconds, "
                       "it's too long.|response_time=%d" %
                       (options.critical, elapsed))
    elif elapsed > options.warning:
        utils.warning("Get flavors took more than %d seconds, "
                      "it's too long.|response_time=%d" %
                      (options.warning, elapsed))
    else:
        utils.ok("Get flavors, nova API is working: "
                 "list %d flavors in %d seconds.|response_time=%d" %
                 (len(flavors), elapsed, elapsed))
Пример #10
0
def _check_ceilometer_api():
    ceilometer = utils.Ceilometer()
    ceilometer.add_argument('-w', dest='warning', type=int, default=5,
                            help='Warning timeout for Ceilometer APIs calls')
    ceilometer.add_argument('-c', dest='critical', type=int, default=10,
                            help='Critical timeout for Ceilometer APIs calls')
    options, client = ceilometer.setup()

    def meters_list():
        try:
            return client.meters.list()
        except exceptions.Gone as ex:
            msg = json.loads(ex.response.content)
            utils.warning(re.sub(r'\s\s*', ' ', msg['error_message']))
        except Exception as ex:
            utils.critical(str(ex))

    elapsed, meters = utils.timeit(meters_list)
    if not meters:
        utils.critical("Unable to contact Ceilometer API.")

    if elapsed > options.critical:
        utils.critical("Get meters took more than %d seconds, "
                       "it's too long.|response_time=%d" %
                       (options.critical, elapsed))
    elif elapsed > options.warning:
        utils.warning("Get meters took more than %d seconds, "
                      "it's too long.|response_time=%d" %
                      (options.warning, elapsed))
    else:
        utils.ok("Get meters, Ceilometer API is working: "
                 "list %d meters in %d seconds.|response_time=%d" %
                 (len(meters), elapsed, elapsed))
Пример #11
0
def _check_keystone_api():
    keystone = utils.Keystone()

    def check_token():
        return keystone.run().strip()

    elapsed, token = utils.timeit(check_token)
    if not token:
        utils.critical("Unable to get a token")

    if elapsed > 10:
        utils.warning("Got a token after 10 seconds, it's too long."
                      "|response_time=%s" % elapsed)
    else:
        utils.ok("Got a token, Keystone API is working."
                 "|response_time=%s" % elapsed)
Пример #12
0
def _check_keystone_api():
    keystone = utils.Keystone()

    def check_token():
        return keystone.run()

    elapsed, result = utils.timeit(check_token)
    rc, out = result
    if rc:
        utils.critical("Unable to get a token:\n{0}".format(out))

    if elapsed > 10:
        utils.warning("Got a token after 10 seconds, it's too long."
                      "|response_time=%s" % elapsed)
    else:
        utils.ok("Got a token, Keystone API is working."
                 "|response_time=%s" % elapsed)
Пример #13
0
def _check_keystone_api():
    keystone = utils.Keystone()

    def check_token():
        options, args, client = keystone.setup()
        return client.service_catalog.get_token()

    elapsed, token = utils.timeit(check_token)
    if not token:
        utils.critical("Unable to get a token")

    if elapsed > 10:
        utils.warning("Got a token after 10 seconds, it's too long."
                      "|response_time=%s" % elapsed)
    else:
        utils.ok("Got a token, Keystone API is working."
                 "|response_time=%s" % elapsed)
def check_keystone_api():
    keystone = utils.Keystone()

    def check_token():
        options, args, client = keystone.setup()
        return client.service_catalog.get_token()

    elapsed, token = utils.timeit(check_token)
    if not token:
        utils.critical("Unable to get a token")

    if elapsed > 10:
        utils.warning("Got a token after 10 seconds, it's too long."
                      "|response_time=%s" % elapsed)
    else:
        utils.ok("Got a token, Keystone API is working."
                 "|response_time=%s" % elapsed)
Пример #15
0
def _check_keystone_api():
    keystone = utils.Keystone()

    def check_token():
        return keystone.run()

    elapsed, result = utils.timeit(check_token)
    rc, out = result
    if rc:
        utils.critical("Unable to get a token:\n{0}".format(out))

    if elapsed > 10:
        utils.warning("Got a token after 10 seconds, it's too long."
                      "|response_time=%s" % elapsed)
    else:
        utils.ok("Got a token, Keystone API is working."
                 "|response_time=%s" % elapsed)
Пример #16
0
def _check_glance_upload():
    glance = utils.Glance()
    glance.add_argument('--monitoring-image', dest='image_name', type=str,
                        default="openstack-monitoring-test-image",
                        help='Name of the monitoring image')
    options, args, client = glance.setup()

    elapsed, iid = utils.timeit(_upload_image,
                                client=client,
                                name=options.image_name)
    try:
        res = client.images.get(iid)
        if res.status != 'active':
            utils.critical("Unable to upload image in Glance")
    finally:
        client.images.delete(res.id)

    if elapsed > 20:
        utils.warning("Upload image in 20 seconds, it's too long")
    else:
        utils.ok("Glance image uploaded in %s seconds" % elapsed)
Пример #17
0
def _check_glance_upload():
    glance = utils.Glance()
    glance.add_argument('--monitoring-image', dest='image_name', type=str,
                        default="openstack-monitoring-test-image",
                        help='Name of the monitoring image')
    options, args, client = glance.setup()

    data_raw = "X" * 1024 * 1024
    elapsed, res = utils.timeit(client.images.create,
                                data=data_raw,
                                disk_format='raw',
                                container_format='bare',
                                name=options.image_name)
    if not res or not res.id or res.status != 'active':
        utils.critical("Unable to upload image in Glance")

    res.delete()

    if elapsed > 20:
        utils.warning("Upload image in 20 seconds, it's too long")
    else:
        utils.ok("Glance image uploaded in %s seconds" % elapsed)
Пример #18
0
def _check_ceilometer_api():
    ceilometer = utils.Ceilometer()
    ceilometer.add_argument('-w',
                            dest='warning',
                            type=int,
                            default=5,
                            help='Warning timeout for Ceilometer APIs calls')
    ceilometer.add_argument('-c',
                            dest='critical',
                            type=int,
                            default=10,
                            help='Critical timeout for Ceilometer APIs calls')
    options, client = ceilometer.setup()

    def meters_list():
        try:
            return client.meters.list()
        except exc.HTTPNotFound as ex:
            utils.warning('Did not find Ceilometer API running '
                          'on given endpoint')
        except Exception as ex:
            utils.critical(str(ex))

    elapsed, meters = utils.timeit(meters_list)
    if not meters:
        utils.critical("Unable to contact Ceilometer API.")

    if elapsed > options.critical:
        utils.critical("Get meters took more than %d seconds, "
                       "it's too long.|response_time=%d" %
                       (options.critical, elapsed))
    elif elapsed > options.warning:
        utils.warning("Get meters took more than %d seconds, "
                      "it's too long.|response_time=%d" %
                      (options.warning, elapsed))
    else:
        utils.ok("Get meters, Ceilometer API is working: "
                 "list %d meters in %d seconds.|response_time=%d" %
                 (len(meters), elapsed, elapsed))
def _check_ceilometer_api():
    ceilometer = utils.Ceilometer()
    ceilometer.add_argument('-w',
                            dest='warning',
                            type=int,
                            default=5,
                            help='Warning timeout for Ceilometer APIs calls')
    ceilometer.add_argument('-c',
                            dest='critical',
                            type=int,
                            default=10,
                            help='Critical timeout for Ceilometer APIs calls')
    options, client = ceilometer.setup()

    def meters_list():
        try:
            return client.meters.list()
        except exceptions.Gone as ex:
            msg = json.loads(ex.response.content)
            utils.warning(re.sub(r'\s\s*', ' ', msg['error_message']))
        except Exception as ex:
            utils.critical(str(ex))

    elapsed, meters = utils.timeit(meters_list)
    if not meters:
        utils.critical("Unable to contact Ceilometer API.")

    if elapsed > options.critical:
        utils.critical("Get meters took more than %d seconds, "
                       "it's too long.|response_time=%d" %
                       (options.critical, elapsed))
    elif elapsed > options.warning:
        utils.warning("Get meters took more than %d seconds, "
                      "it's too long.|response_time=%d" %
                      (options.warning, elapsed))
    else:
        utils.ok("Get meters, Ceilometer API is working: "
                 "list %d meters in %d seconds.|response_time=%d" %
                 (len(meters), elapsed, elapsed))
def _check_ceilometer_api():
    ceilometer = utils.Ceilometer()
    ceilometer.add_argument('-w', dest='warning', type=int, default=5,
                            help='Warning timeout for Ceilometer APIs calls')
    ceilometer.add_argument('-c', dest='critical', type=int, default=10,
                            help='Critical timeout for Ceilometer APIs calls')
    options, client = ceilometer.setup()

    elapsed, meters = utils.timeit(client.meters.list)
    if not meters:
        utils.critical("Unable to contact Ceilometer API.")

    if elapsed > options.critical:
        utils.critical("Get meters took more than %d seconds, "
                       "it's too long.|response_time=%d" %
                       (options.critical, elapsed))
    elif elapsed > options.warning:
        utils.warning("Get meters took more than %d seconds, "
                      "it's too long.|response_time=%d" %
                      (options.warning, elapsed))
    else:
        utils.ok("Get meters, Ceilometer API is working: "
                 "list %d meters in %d seconds.|response_time=%d" %
                 (len(meters), elapsed, elapsed))