Remove shinken plugins
Was moved to https://github.com/savoirfairelinux/monitoring-tools, by this PR: https://github.com/savoirfairelinux/monitoring-tools/pull/34 Also adapted good Dockerfile and cleaned doc. Change-Id: If619fc35f9b95c3332eaf7538cb221aa7261044e
This commit is contained in:
parent
d47bf78593
commit
26efcedf6b
@ -10,7 +10,6 @@ Table of Contents:
|
||||
readme
|
||||
getting_started
|
||||
webapi/index
|
||||
shinken_plugins
|
||||
|
||||
Indices and tables
|
||||
==================
|
||||
|
@ -1,8 +0,0 @@
|
||||
Shinken plugins
|
||||
===============
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:glob:
|
||||
|
||||
shinken_tools/plugins/*/doc/*
|
@ -1 +0,0 @@
|
||||
../../shinken-tools
|
@ -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 <licensing@enovance.com>
|
||||
#
|
||||
# Author: Florian Lambert <florian.lambert@enovance.com>
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
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()
|
@ -1,4 +0,0 @@
|
||||
plugin-check-glance
|
||||
===================
|
||||
|
||||
Shinken plugin to monitor Glance
|
@ -1,3 +0,0 @@
|
||||
shinkenplugins
|
||||
python-keystoneclient
|
||||
python-glanceclient
|
@ -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 <licensing@enovance.com>
|
||||
#
|
||||
# Author: Julien Danjou <julien@danjou.info>
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
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()
|
@ -1,4 +0,0 @@
|
||||
plugin-check-keystone
|
||||
=====================
|
||||
|
||||
Shinken plugin to check Keystone
|
@ -1,2 +0,0 @@
|
||||
shinkenplugins
|
||||
python-keystoneclient
|
@ -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()
|
||||
|
@ -4,7 +4,7 @@ MAINTAINER Alexandre Viau <alexandre.viau@savoirfairelinux.com>
|
||||
|
||||
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user