diff --git a/doc/source/index.rst b/doc/source/index.rst index 5dbc12b..38dc1d4 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -10,7 +10,6 @@ Table of Contents: readme getting_started webapi/index - shinken_plugins Indices and tables ================== diff --git a/doc/source/shinken_plugins.rst b/doc/source/shinken_plugins.rst deleted file mode 100644 index b4a9aff..0000000 --- a/doc/source/shinken_plugins.rst +++ /dev/null @@ -1,8 +0,0 @@ -Shinken plugins -=============== - -.. toctree:: - :maxdepth: 2 - :glob: - - shinken_tools/plugins/*/doc/* diff --git a/doc/source/shinken_tools b/doc/source/shinken_tools deleted file mode 120000 index 5dedf4e..0000000 --- a/doc/source/shinken_tools +++ /dev/null @@ -1 +0,0 @@ -../../shinken-tools \ No newline at end of file diff --git a/shinken-tools/plugins/plugin-check-glance/check_glance b/shinken-tools/plugins/plugin-check-glance/check_glance deleted file mode 100755 index 62d1a47..0000000 --- a/shinken-tools/plugins/plugin-check-glance/check_glance +++ /dev/null @@ -1,165 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- -# -# Keystone monitoring script for Nagios -# -# Copyright (C) 2014 Savoir-faire Linux Inc. -# Copyright © 2012 eNovance -# -# Author: Florian Lambert -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# - -from shinkenplugins import BasePlugin, PerfData, STATES - -from keystoneclient.v2_0 import client as keystone_client -from glanceclient import client as glance_client - -import datetime - - -class Plugin(BasePlugin): - NAME = 'check-keystone' - VERSION = '0.1' - DESCRIPTION = 'check keystone' - AUTHOR = 'Alexandre Viau' - EMAIL = 'alexandre.viau@savoirfairelinux.com' - - ARGS = [ - # Can't touch this: - ('h', 'help', 'display plugin help', False), - ('v', 'version', 'display plugin version number', False), - # Add your plugin arguments here: - # ('short', 'long', 'description', 'does it expect a value?') - - # OpenStack Auth - ('U', 'auth_url', 'Keystone URL', True), - ('u', 'username', 'username to use for authentication', True), - ('p', 'password', 'password to use for authentication', True), - ('t', 'tenant', 'tenant name to use for authentication', True), - ('e', 'endpoint', 'the glance endpoint', True), - ('H', 'host', 'the glance host', True), - - # Options - ('c', 'req_count', "minimum number of images in glance", True), - - ('c', 'req_images', - "comma separated name of images that must be available", True), - ] - - def check_args(self, args): - # You can do your various arguments check here. - # If you don't need to check things, you can safely remove the method. - - if not args.get('help') and not args.get('version'): - for arg in [ - 'auth_url', - 'username', - 'password', - 'tenant', - 'endpoint', - ]: - if arg not in args.keys(): - return False, 'the argument %s must be present' % arg - - # Turn req_images into a list - if args.get('req_images'): - args['req_images'] = args['req_images'].split(',') - - # Turn req_count into an int - if args.get('req_count'): - args['req_count'] = int(args['req_count']) - - return True, None - - def run(self, args): - # Here is the core of the plugin. - # After doing your verifications, escape by doing: - # self.exit(return_code, 'return_message', *performance_data) - perfdata = [] - - try: - # Get a keystone token - keystone = keystone_client.Client( - username=args['username'], - tenant_name=args['tenant'], - password=args['password'], - auth_url=args['auth_url'], - ) - - # Auth with glance - start_time = datetime.datetime.now() - client = glance_client.Client( - auth_url=args['auth_url'], - username=args['username'], - tenant=args['tenant'], - endpoint=args['endpoint'], - host=args.get('host'), - token=keystone.auth_token, - ) - end_time = datetime.datetime.now() - perfdata.append( - PerfData( - 'auth_time', - ((end_time - start_time).total_seconds()/1000), - min_='0', - unit='ms' - ) - ) - except Exception as e: - self.exit(STATES.UNKNOWN, str(e)) - - # Get the images - images = [image for image in client.images.list()] - - # Get the image count - image_count = len(images) - perfdata.append( - PerfData( - 'image_count', - image_count, - min_=(args.get('req_count')) - ) - ) - - # Check the count of images - if args.get('req_count') and image_count < args.get('req_count'): - self.exit( - STATES.CRITICAL, - 'Not enough images (%s < %s)' % (image_count, args.get('req_count')), - *perfdata - ) - - # Check the required images - missing_images = [] - if args.get('req_images'): - for image in args.get('req_images'): - if not next(client.images.list(**{"filters": {"name": image}}), None): - missing_images.append(image) - if len(missing_images) > 0: - self.exit( - STATES.CRITICAL, - 'Images: %s are missing' % ' '.join(missing_images), - *perfdata - ) - - self.exit( - STATES.OK, - 'OK - %s images found' % image_count, - *perfdata - ) - -if __name__ == '__main__': - Plugin() diff --git a/shinken-tools/plugins/plugin-check-glance/doc/plugin-check-glance.rst b/shinken-tools/plugins/plugin-check-glance/doc/plugin-check-glance.rst deleted file mode 100644 index 5d24832..0000000 --- a/shinken-tools/plugins/plugin-check-glance/doc/plugin-check-glance.rst +++ /dev/null @@ -1,4 +0,0 @@ -plugin-check-glance -=================== - -Shinken plugin to monitor Glance diff --git a/shinken-tools/plugins/plugin-check-glance/requirements.txt b/shinken-tools/plugins/plugin-check-glance/requirements.txt deleted file mode 100644 index 55742ba..0000000 --- a/shinken-tools/plugins/plugin-check-glance/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -shinkenplugins -python-keystoneclient -python-glanceclient diff --git a/shinken-tools/plugins/plugin-check-keystone/check_keystone b/shinken-tools/plugins/plugin-check-keystone/check_keystone deleted file mode 100755 index 7ae006e..0000000 --- a/shinken-tools/plugins/plugin-check-keystone/check_keystone +++ /dev/null @@ -1,132 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- -# -# Keystone monitoring script for Nagios -# -# Copyright (C) 2014 Savoir-faire Linux Inc. -# Copyright © 2012 eNovance -# -# Author: Julien Danjou -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# - -import datetime - -from shinkenplugins import BasePlugin, PerfData, STATES -from keystoneclient.v2_0 import client - - -class Plugin(BasePlugin): - NAME = 'check-keystone' - VERSION = '0.1' - DESCRIPTION = 'check keystone' - AUTHOR = 'Alexandre Viau' - EMAIL = 'alexandre.viau@savoirfairelinux.com' - - ARGS = [ - # Can't touch this: - ('h', 'help', 'display plugin help', False), - ('v', 'version', 'display plugin version number', False), - # Add your plugin arguments here: - # ('short', 'long', 'description', 'does it expect a value?') - - # OpenStack Auth - ('U', 'auth_url', 'Keystone URL', True), - ('u', 'username', 'username to use for authentication', True), - ('p', 'password', 'password to use for authentication', True), - ('t', 'tenant', 'tenant name to use for authentication', True), - - # Options - ('s', 'services', "comma-separated services to check for", True), - ] - - def check_args(self, args): - # You can do your various arguments check here. - # If you don't need to check things, you can safely remove the method. - - if not args.get('help') and not args.get('version'): - for arg in [ - 'auth_url', - 'username', - 'password', - 'tenant', - 'services', - ]: - if arg not in args.keys(): - return False, 'the argument %s must be present' % arg - args['services'] = args['services'].split(',') - return True, None - - def run(self, args): - # Here is the core of the plugin. - # After doing your verifications, escape by doing: - # self.exit(return_code, 'return_message', *performance_data) - perfdata = [] - - try: - start_time = datetime.datetime.now() - c = client.Client( - username=args['username'], - tenant_name=args['tenant'], - password=args['password'], - auth_url=args['auth_url'], - ) - if not c.authenticate(): - self.exit(STATES.UNKNOWN, 'Authentication failed') - end_time = datetime.datetime.now() - perfdata.append( - PerfData( - 'auth_time', - ((end_time - start_time).total_seconds()/1000), - min_='0', - unit='ms' - ) - ) - except Exception as e: - self.exit(STATES.UNKNOWN, str(e)) - - endpoints = c.service_catalog.get_endpoints() - services = args['services'] or endpoints.keys() - - msgs = [] - for service in services: - if not service in endpoints.keys(): - msgs.append("`%s' service is missing" % service) - continue - - if not len(endpoints[service]): - msgs.append("`%s' service is empty" % service) - continue - - if not any(["publicURL" in endpoint.keys() for endpoint in endpoints[service]]): - msgs.append("`%s' service has no publicURL" % service) - - perfdata.append(PerfData('service_count', len(endpoints), min_='0')) - - if len(msgs) > 0: - self.exit( - STATES.CRITICAL, - ' '.join(msgs), - *perfdata - ) - else: - self.exit( - STATES.OK, - "Got token %s for user %s and tenant %s" % (c.auth_token, c.auth_user_id, c.auth_tenant_id), - *perfdata - ) - -if __name__ == "__main__": - Plugin() diff --git a/shinken-tools/plugins/plugin-check-keystone/doc/plugin-check-keystone.rst b/shinken-tools/plugins/plugin-check-keystone/doc/plugin-check-keystone.rst deleted file mode 100644 index cd3325f..0000000 --- a/shinken-tools/plugins/plugin-check-keystone/doc/plugin-check-keystone.rst +++ /dev/null @@ -1,4 +0,0 @@ -plugin-check-keystone -===================== - -Shinken plugin to check Keystone diff --git a/shinken-tools/plugins/plugin-check-keystone/requirements.txt b/shinken-tools/plugins/plugin-check-keystone/requirements.txt deleted file mode 100644 index 6b5f747..0000000 --- a/shinken-tools/plugins/plugin-check-keystone/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -shinkenplugins -python-keystoneclient diff --git a/surveil/cmd/init.py b/surveil/cmd/init.py index f15963d..32bc4a6 100644 --- a/surveil/cmd/init.py +++ b/surveil/cmd/init.py @@ -75,6 +75,19 @@ def main(): "service_description": "check-ws-arbiter"} ) + mongo_hosts.insert( + { + 'host_name': 'test_keystone', + 'use': 'linux-keystone', + 'address': '127.0.0.1', + "_OS_AUTH_URL": "bla", + "_OS_USERNAME": "bli", + "_OS_PASSWORD": "blo", + "_OS_TENANT": "blu", + "_KS_SERVICES": "bly", + } + ) + # Reload the surveil config cli_surveil = sc.Client('http://localhost:8080/v1') cli_surveil.reload_config() diff --git a/tools/docker/shinken_container/Dockerfile b/tools/docker/shinken_container/Dockerfile index af74db0..51f4ef2 100644 --- a/tools/docker/shinken_container/Dockerfile +++ b/tools/docker/shinken_container/Dockerfile @@ -4,7 +4,7 @@ MAINTAINER Alexandre Viau RUN apt-get update -RUN apt-get install -y vim supervisor python-dev libffi-dev libssl-dev +RUN apt-get update && apt-get install -y vim supervisor python-dev libffi-dev libssl-dev # libffi-devand libssl-dev are for python-cryptography ### Shinken @@ -29,16 +29,16 @@ RUN chmod u+s /bin/ping6 # Download plugins RUN apt-get install -y subversion && \ - svn checkout https://github.com/stackforge/surveil/trunk/shinken-tools/plugins/plugin-check-glance /plugins/check_glance && \ - svn checkout https://github.com/stackforge/surveil/trunk/shinken-tools/plugins/plugin-check-keystone /plugins/check_keystone && \ + svn checkout https://github.com/savoirfairelinux/monitoring-tools/trunk/plugins/check-glance /plugins/check_glance && \ + svn checkout https://github.com/savoirfairelinux/monitoring-tools/trunk/plugins/check-keystone /plugins/check_keystone && \ apt-get remove -y subversion ## Install plugins dependencies RUN pip install shinkenplugins python-keystoneclient python-glanceclient ## Install Plugins -RUN mkdir -p /usr/lib/shinken/plugins && \ - cp /plugins/*/check_* /usr/lib/shinken/plugins/ +RUN cd /plugins/check_glance && sudo pip install --upgrade . +RUN cd /plugins/check_keystone && sudo pip install --upgrade . ## configuration RUN rm -rf /etc/shinken