Ejemplo n.º 1
0
def check_glance_api():
    utils.safe_run(_check_glance_api)
Ejemplo n.º 2
0
def check_glance_upload():
    utils.safe_run(_check_glance_upload)
Ejemplo n.º 3
0
def check_glance_image_exists():
    utils.safe_run(_check_glance_image_exists)
Ejemplo n.º 4
0
def check_cinder_volume():
    utils.safe_run(_check_cinder_volume)
Ejemplo n.º 5
0
def check_keystone_api():
    utils.safe_run(_check_keystone_api)
Ejemplo n.º 6
0
def main():
    utils.safe_run(check_amqp)
Ejemplo n.º 7
0
def check_neutron_floating_ip():
    utils.safe_run(_check_neutron_floating_ip)
Ejemplo n.º 8
0
def main():
    utils.safe_run(check_amqp)
Ejemplo n.º 9
0
def check_neutron_floating_ip():
    utils.safe_run(_check_neutron_floating_ip)
# under the License.

from oschecks import utils


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("OK - Glance image uploaded in %s seconds" % elapsed)

if __name__ == '__main__':
    utils.safe_run(check_glance_upload)
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

from oschecks import utils


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)


if __name__ == '__main__':
    utils.safe_run(check_keystone_api)
    if options.req_images:
        required_images = options.req_images
        for image in required_images:
            try:
                if len(client.get_images(**{"filters": {"name": image}})) == 1:
                    valid_image = valid_image + 1
            except:
                pass

    if options.req_count and count == 0:
        utils.critical("Failed - less than %d images found" % (required_count))

    if options.req_images and valid_image < len(required_images):
        utils.critical("Failed - '%s' %d/%d images found " %
                       (", ".join(required_images), valid_image,
                        len(required_images)))

    if options.req_images and options.req_count:
        utils.ok("image %s found and enough images >=%d" %
                 (", ".join(required_images), required_count))
    elif options.req_images:
        utils.ok("image %s found" % (", ".join(required_images)))
    elif options.req_count:
        utils.ok("more than %d images found" % (count))
    else:
        utils.ok("Connection glance established")


if __name__ == '__main__':
    utils.safe_run(check_glance)

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()

    elapsed, networks = utils.timeit(client.list_networks)
    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))


if __name__ == '__main__':
    utils.safe_run(check_neutron_api)
Ejemplo n.º 14
0
def check_ceilometer_api():
    utils.safe_run(_check_ceilometer_api)
Ejemplo n.º 15
0
def check_nova_floating_ip_count():
    utils.safe_run(_check_nova_floating_ip_count)
Ejemplo n.º 16
0
def check_neutron_api():
    utils.safe_run(_check_neutron_api)
Ejemplo n.º 17
0
def check_nova_api():
    utils.safe_run(_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))


if __name__ == '__main__':
    utils.safe_run(check_nova_api)
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)
        )


if __name__ == "__main__":
    utils.safe_run(check_ceilometer_api)
Ejemplo n.º 20
0
def check_keystone_api():
    utils.safe_run(_check_keystone_api)
Ejemplo n.º 21
0
def check_neutron_api():
    utils.safe_run(_check_neutron_api)
Ejemplo n.º 22
0
def check_ceilometer_api():
    utils.safe_run(_check_ceilometer_api)
Ejemplo n.º 23
0
def check_cinder_api():
    utils.safe_run(_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))


if __name__ == '__main__':
    utils.safe_run(check_cinder_api)
Ejemplo n.º 25
0
def check_glance_image_exists():
    utils.safe_run(_check_glance_image_exists)
Ejemplo n.º 26
0
def main():
    utils.safe_run(check_process)
Ejemplo n.º 27
0
def check_glance_api():
    utils.safe_run(_check_glance_api)
Ejemplo n.º 28
0
def check_nova_instance():
    utils.safe_run(_check_nova_instance)
Ejemplo n.º 29
0
def check_glance_upload():
    utils.safe_run(_check_glance_upload)
Ejemplo n.º 30
0
def check_nova_api():
    utils.safe_run(_check_nova_api)
Ejemplo n.º 31
0
def check_nova_instance_count():
    utils.safe_run(_check_nova_instance_count)
Ejemplo n.º 32
0
def check_cinder_volume():
    utils.safe_run(_check_cinder_volume)
Ejemplo n.º 33
0
def check_nova_instance():
    utils.safe_run(_check_nova_instance)
Ejemplo n.º 34
0
def check_cinder_api():
    utils.safe_run(_check_cinder_api)
Ejemplo n.º 35
0
def main():
    utils.safe_run(check_process)
    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():
        return list(client.images.list())

    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))


if __name__ == '__main__':
    utils.safe_run(check_glance_api)