Exemple #1
0
from sentry.controller import handler
from sentry.openstack.common import cfg
from sentry.openstack.common import log
from sentry.openstack.common import rpc
"""
    Sentry listenning on rabbitmq and receive notification
    from nova-compute, nova-service-monitor, nova-cloudwatch,
    nova-network, nova-billing, nova-api, nova-scheduler.
    When received a notification, it will filter the notification
    and send a alarm message to alarm system when the notification
    is alarm level.
"""

manager_configs = [
    cfg.StrOpt('queue_suffix', default='sentry', help='Name of queue suffix'),
    cfg.StrOpt('nova_sentry_mq_topic',
               default='notifications',
               help='Name of nova notifications topic'),
    cfg.StrOpt('glance_sentry_mq_topic',
               default='glance_notifications',
               help='Name of glance notifications topic'),
    cfg.ListOpt('nova_mq_level_list',
                default=[
                    'error',
                    'info',
                ],
                help='notifications levels for message queue of nova'),
    cfg.ListOpt('glance_mq_level_list',
                default=[
                    'error',
Exemple #2
0
from sentry.openstack.common import context
from sentry.openstack.common.gettextutils import _
from sentry.openstack.common import importutils
from sentry.openstack.common import jsonutils
from sentry.openstack.common import log as logging
from sentry.openstack.common import timeutils

LOG = logging.getLogger(__name__)

notifier_opts = [
    cfg.MultiStrOpt('notification_driver',
                    default=[],
                    deprecated_name='list_notifier_drivers',
                    help='Driver or drivers to handle sending notifications'),
    cfg.StrOpt('default_notification_level',
               default='INFO',
               help='Default notification level for outgoing notifications'),
    cfg.StrOpt('default_publisher_id',
               default='$host',
               help='Default publisher_id for outgoing notifications'),
]

CONF = cfg.CONF
CONF.register_opts(notifier_opts)

WARN = 'WARN'
INFO = 'INFO'
ERROR = 'ERROR'
CRITICAL = 'CRITICAL'
DEBUG = 'DEBUG'
Exemple #3
0
#
# Created on 2012-11-16
#
# @author: hzyangtk
#

import json

from sentry.filter.filter import Filter
from sentry.openstack.common import log
from sentry.openstack.common import cfg

CONF = cfg.CONF

owner_filter_configs = [
    cfg.StrOpt('owner_filter_config',
               default='/etc/sentry/filter/owner_filter.conf'),
]

CONF.register_opts(owner_filter_configs)

LOG = log.getLogger(__name__)


class OwnerFilter(Filter):
    """
    Filter for alarm owner
    """
    def __init__(self):
        """
        init filter rules
        """
Exemple #4
0
import eventlet.wsgi
import greenlet
from paste import deploy
import routes.middleware
import webob.dec
import webob.exc

from sentry.common import exception
from sentry.openstack.common import cfg
from sentry.openstack.common import log as logging

FLAGS = cfg.CONF

wsgi_configs = [
    cfg.StrOpt('api_paste_config',
               default="api-paste.ini",
               help='File name for the paste.deploy config for nova-api'),
]

FLAGS.register_opts(wsgi_configs)

LOG = logging.getLogger(__name__)


class Server(object):
    """Server class to manage a WSGI server, serving a WSGI application."""

    default_pool_size = 1000

    def __init__(self,
                 name,
Exemple #5
0
import eventlet
import greenlet
import qpid.messaging
import qpid.messaging.exceptions

from sentry.openstack.common import cfg
from sentry.openstack.common.gettextutils import _
from sentry.openstack.common import jsonutils
from sentry.openstack.common.rpc import amqp as rpc_amqp
from sentry.openstack.common.rpc import common as rpc_common

LOG = logging.getLogger(__name__)

qpid_opts = [
    cfg.StrOpt('qpid_hostname',
               default='localhost',
               help='Qpid broker hostname'),
    cfg.StrOpt('qpid_port', default='5672', help='Qpid broker port'),
    cfg.StrOpt('qpid_username',
               default='',
               help='Username for qpid connection'),
    cfg.StrOpt('qpid_password',
               default='',
               help='Password for qpid connection'),
    cfg.StrOpt('qpid_sasl_mechanisms',
               default='',
               help='Space separated list of SASL mechanisms to use for auth'),
    cfg.BoolOpt('qpid_reconnect', default=True,
                help='Automatically reconnect'),
    cfg.IntOpt('qpid_reconnect_timeout',
               default=0,
Exemple #6
0
import json

from sentry.common import client
from sentry.common import utils
from sentry.openstack.common import cfg
import sentry.openstack.common.log as logging

LOG = logging.getLogger(__name__)

NOVA_OPTS = [
    cfg.StrOpt("nova_host", default="0.0.0.0"),
    cfg.IntOpt("nova_port", default=8774),
    cfg.StrOpt("nova_version", default="/v2")
]

CONF = cfg.CONF
CONF.register_opts(NOVA_OPTS)


class BaseClient(client.BaseClient):
    """client base class for make request of other module"""

    def request(self, req):
        return self.send_request(req.method, req.path,
                                 params=req.params.mixed(),
                                 headers=req.headers, body=req.body)

    def send_request(self, method, action, params={}, headers={}, body=None):
        LOG.debug(_("%(method)s %(action)s %(params)s %(headers)s"),
                                locals())
        res = self.do_request(method, action, params=params, headers=headers,
Exemple #7
0
# Created on 2012-12-4
#
# @author: [email protected]
#

from sentry.common import exception
from sentry.openstack.common import cfg
from sentry.openstack.common import log as logging
from novaclient.v1_1.client import Client

LOG = logging.getLogger(__name__)
FLAGS = cfg.CONF

nova_client_configs = [
    cfg.StrOpt('novaclient_username',
               default='default',
               help='Nova Client Username'),
    cfg.StrOpt('novaclient_password',
               default='default',
               help='Nova Client Password'),
    cfg.StrOpt('novaclient_projectName',
               default='default',
               help='Nova Client Project Name'),
    cfg.StrOpt('novaclient_keystoneUrl',
               default='default',
               help='Nova Client Keystone Url'),
]

FLAGS.register_opts(nova_client_configs)

Exemple #8
0
The MatchMaker classes should except a Topic or Fanout exchange key and
return keys for direct exchanges, per (approximate) AMQP parlance.
"""

import contextlib
import itertools
import json
import logging

from sentry.openstack.common import cfg
from sentry.openstack.common.gettextutils import _

matchmaker_opts = [
    # Matchmaker ring file
    cfg.StrOpt('matchmaker_ringfile',
               default='/etc/sentry/matchmaker_ring.json',
               help='Matchmaker ring file (JSON)'),
]

CONF = cfg.CONF
CONF.register_opts(matchmaker_opts)
LOG = logging.getLogger(__name__)
contextmanager = contextlib.contextmanager


class MatchMakerException(Exception):
    """Signified a match could not be found."""
    message = _("Match not found by MatchMaker.")


class Exchange(object):
Exemple #9
0
#    Created on 2012-10-30
#
#    @author: [email protected]
#

import os

from sentry.common import exception
from sentry.common import utils
from sentry.openstack.common import cfg
from sentry.openstack.common import jsonutils


alarm_content_opts = [
    cfg.StrOpt('alarm_content_file',
               default='alarm_content.json',
               help='JSON file representing different type alarm contents'),
    ]


FLAGS = cfg.CONF
FLAGS.register_opts(alarm_content_opts)

_ALARM_CONTENT_PATH = None
_ALARM_CONTENT_CACHE = {}
_ALARM_CONTENT_DICT = {}


def reset():
    global _ALARM_CONTENT_PATH
    global _ALARM_CONTENT_CACHE
Exemple #10
0
#
#    Created on 2012-10-30
#
#    @author: [email protected]
#

import os

from sentry.common import exception
from sentry.common import utils
from sentry.openstack.common import cfg
from sentry.openstack.common import jsonutils

setting_list_opts = [
    cfg.StrOpt('setting_list_file',
               default='setting_list.json',
               help='JSON file representing setting list contents'),
]

FLAGS = cfg.CONF
FLAGS.register_opts(setting_list_opts)

_SETTING_LIST_PATH = None
_SETTING_LIST_CACHE = {}
_SETTING_LIST_DICT = {}


def reset():
    global _SETTING_LIST_PATH
    global _SETTING_LIST_CACHE
    _SETTING_LIST_PATH = None
Exemple #11
0
#

import hashlib
import hmac
import httplib
import time
import urllib

from sentry.openstack.common import cfg
from sentry.openstack.common import log

LOG = log.getLogger(__name__)
CONF = cfg.CONF

request_configs = [
    cfg.StrOpt('url_port', default=None, help='Alarm system url and port.'),
    cfg.StrOpt('platform_request_uri',
               default=None,
               help='Alarm system platform manager request uri.'),
    cfg.StrOpt('product_request_uri',
               default=None,
               help='Alarm system product manager request uri.'),
    cfg.StrOpt('access_key', default=None, help='Alarm system access key.'),
    cfg.StrOpt('access_secret',
               default=None,
               help='Alarm system access secret key.'),
]

CONF.register_opts(request_configs)

Exemple #12
0
import eventlet
from eventlet import greenpool

from sentry.api import wsgi
from sentry.openstack.common import log
from sentry.openstack.common import cfg
"""
    Sentry api for http request
"""

FLAGS = cfg.CONF

manager_configs = [
    cfg.StrOpt('sentry_api_listen',
               default="0.0.0.0",
               help='IP address for metadata api to listen'),
    cfg.IntOpt('sentry_api_listen_port',
               default=9901,
               help='port for metadata api to listen'),
    cfg.IntOpt('sentry_api_workers',
               default=None,
               help='Number of workers for metadata service'),
]

FLAGS.register_opts(manager_configs)

LOG = log.getLogger(__name__)


class Manager(object):
Exemple #13
0
import eventlet
import greenlet
import kombu
import kombu.connection
import kombu.entity
import kombu.messaging

from sentry.openstack.common import cfg
from sentry.openstack.common.gettextutils import _
from sentry.openstack.common.rpc import amqp as rpc_amqp
from sentry.openstack.common.rpc import common as rpc_common

kombu_opts = [
    cfg.StrOpt('kombu_ssl_version',
               default='',
               help='SSL version to use (valid only if SSL enabled)'),
    cfg.StrOpt('kombu_ssl_keyfile',
               default='',
               help='SSL key file (valid only if SSL enabled)'),
    cfg.StrOpt('kombu_ssl_certfile',
               default='',
               help='SSL cert file (valid only if SSL enabled)'),
    cfg.StrOpt('kombu_ssl_ca_certs',
               default='',
               help=('SSL certification authority file '
                     '(valid only if SSL enabled)')),
    cfg.StrOpt('rabbit_host', default='localhost', help='the RabbitMQ host'),
    cfg.IntOpt('rabbit_port', default=5672, help='the RabbitMQ port'),
    cfg.BoolOpt('rabbit_use_ssl',
                default=False,
Exemple #14
0
from sentry.openstack.common.gettextutils import _
from sentry.openstack.common import importutils
from sentry.openstack.common import jsonutils
from sentry.openstack.common.rpc import common as rpc_common

# for convenience, are not modified.
pformat = pprint.pformat
Timeout = eventlet.timeout.Timeout
LOG = rpc_common.LOG
RemoteError = rpc_common.RemoteError
RPCException = rpc_common.RPCException

zmq_opts = [
    cfg.StrOpt('rpc_zmq_bind_address',
               default='*',
               help='ZeroMQ bind address. Should be a wildcard (*), '
               'an ethernet interface, or IP. '
               'The "host" option should point or resolve to this '
               'address.'),

    # The module.Class to use for matchmaking.
    cfg.StrOpt(
        'rpc_zmq_matchmaker',
        default=('sentry.openstack.common.rpc.'
                 'matchmaker.MatchMakerLocalhost'),
        help='MatchMaker driver',
    ),

    # The following port is unassigned by IANA as of 2012-05-21
    cfg.IntOpt('rpc_zmq_port',
               default=9501,
               help='ZeroMQ receiver listening port'),
Exemple #15
0
# @author: [email protected]
#

from sentry.common import http_communication
from sentry.openstack.common import cfg
from sentry.openstack.common import log

LOG = log.getLogger(__name__)
CONF = cfg.CONF

notify_configs = [
    cfg.BoolOpt('enable_platform_stop_alarm',
                default=False,
                help='Enable notify platform when vm state change'),
    cfg.StrOpt('stop_alarm_url_port',
               default='$url_port',
               help='Stop alarm url and port'),
    cfg.StrOpt('stop_alarm_request_uri',
               default=None,
               help='Stop alarm request uri.'),
    cfg.BoolOpt('enable_platform_binding',
                default=False,
                help='Enable notify platform binding when vm create'),
    cfg.StrOpt('alarm_binding_url_port',
               default='$url_port',
               help='Binding alarm url and port'),
    cfg.StrOpt('alarm_binding_request_uri',
               default=None,
               help='Binding alarm request uri.'),
]
Exemple #16
0
#
# Created on 2012-12-4
#
# @author: [email protected]
#

from sentry.common import utils
from sentry.controller import helper as controller_helper
from sentry.openstack.common import cfg
from sentry.openstack.common import importutils
from sentry.openstack.common import log
from sentry.sender import manager as sender_manager

handler_configs = [
    cfg.StrOpt('alarm_level', default='ERROR', help='Alarm level'),
    cfg.ListOpt('filter_driver_list',
                default=[
                    'sentry.filter.alarm_filter.AlarmFilter',
                    'sentry.filter.owner_filter.OwnerFilter'
                ],
                help='Driver or drivers to filter alarm messages'),
]

CONF = cfg.CONF
CONF.register_opts(handler_configs)
LOG = log.getLogger(__name__)


class Handler(object):
    def __init__(self):
        LOG.debug("Controller handler init.")
Exemple #17
0
import logging.handlers
import os
import stat
import sys
import traceback

from sentry.openstack.common import cfg
from sentry.openstack.common.gettextutils import _
from sentry.openstack.common import jsonutils
from sentry.openstack.common import local
from sentry.openstack.common import notifier

log_opts = [
    cfg.StrOpt('logging_context_format_string',
               default='%(asctime)s %(levelname)s %(name)s [%(request_id)s '
               '%(user_id)s %(project_id)s] %(instance)s'
               '%(message)s',
               help='format string to use for log messages with context'),
    cfg.StrOpt('logging_default_format_string',
               default='%(asctime)s %(process)d %(levelname)s %(name)s [-]'
               ' %(instance)s%(message)s',
               help='format string to use for log messages without context'),
    cfg.StrOpt('logging_debug_format_suffix',
               default='%(funcName)s %(pathname)s:%(lineno)d',
               help='data to append to log format when level is DEBUG'),
    cfg.StrOpt('logging_exception_prefix',
               default='%(asctime)s %(process)d TRACE %(name)s %(instance)s',
               help='prefix each line of exception output with this format'),
    cfg.ListOpt('default_log_levels',
                default=[
                    'amqplib=WARN', 'sqlalchemy=WARN', 'boto=WARN',
Exemple #18
0
#
# Created on 2012-11-16
#
# @author: hzyangtk
#

import json

from sentry.filter.filter import Filter
from sentry.openstack.common import log
from sentry.openstack.common import cfg

CONF = cfg.CONF

alarm_filter_configs = [
    cfg.StrOpt('alarm_filter_config',
               default='/etc/sentry/filter/alarm_filter.conf'),
]

CONF.register_opts(alarm_filter_configs)

LOG = log.getLogger(__name__)


class AlarmFilter(Filter):
    '''
    Filter for alarm system
    '''
    def __init__(self):
        '''
        init filter rules
        '''