...
 
Commits (2)
......@@ -3,6 +3,10 @@
Cette documentation a pour but de décrire l'installation et la configuration du
connecteur shinkenenterprise2canopsis.
# Prérequis
Shinken Entreprise version 02.07.06 ou supérieure
# Installation
Installez Shinken Entreprise en suivant la documentation de l'éditeur.
......@@ -70,16 +74,6 @@ Personnalisez ensuite le contenu du fichier `/etc/shinken/modules/broker-exporte
queue_dump_frequency 300
```
NB : Sur la version `shinken-enterprise_V02.08.01-RC001_BUILD18-FR` et les précédentes certains fichiers doivent être modifiés.
- Fichier `/usr/lib/python2.7/site-packages/shinken/objects/host.py` ligne 100, ajoutez `'next_schedule'` pour obtenir le résultat suivant :
```
'realm' : StringProp(default=None, fill_brok=['full_status', 'check_result', 'next_schedule'], conf_send_preparation=get_obj_name),
```
- Fichier `/usr/lib/python2.7/site-packages/shinken/objects/service.py` ligne 230 réalisez la même modification :
```
'realm' : VirtualProp(default='', fill_brok=['full_status', 'check_result', 'next_schedule'], brok_transformation=get_service_realm),
```
Enfin redémarrez Shinken.
```
service shinken restart
......
......@@ -20,10 +20,17 @@ except ImportError:
from shinken.brokermodule import WorkerBasedBrokerModule
from shinken.brokermoduleworker import BrokerModuleWorker
from shinken.log import LoggerFactory
from shinken.message import Message
logger = LoggerFactory.get_logger('canopsis')
try:
from shinken.log import LoggerFactory
logger = LoggerFactory.get_logger('canopsis')
SHINKEN_VERSION = '2.8+'
except ImportError: # shinken 2.07.0X
from shinken.log import logger
SHINKEN_VERSION = '2.7'
properties = {
'daemons' : ['broker'],
......@@ -34,7 +41,8 @@ properties = {
# Called by the plugin manager to get a broker
def get_instance(mod_conf):
logger.set_display_name(mod_conf.get_name())
if SHINKEN_VERSION != '2.7': # this call is not available in old shinken version
logger.set_display_name(mod_conf.get_name())
logger.info("Get a canopsis data module for plugin %s" % mod_conf.get_name())
instance = Canopsis_broker(mod_conf)
return instance
......@@ -79,7 +87,7 @@ class CanopsisModuleWorker(BrokerModuleWorker):
def manage_initial_host_status_brok(self, b):
logger.info("[Canopsis] processing initial_host_status")
logger.debug("[Canopsis] processing initial_host_status")
if not hasattr(self, 'host_commands'):
self.host_commands = {}
......@@ -99,30 +107,23 @@ class CanopsisModuleWorker(BrokerModuleWorker):
# max_check_attempts does not appear in check results so build a dict of max_check_attempts
self.host_max_check_attempts[b.data['host_name']] = b.data['max_check_attempts']
logger.debug("[canopsis] initial host max attempts: %s " % str(self.host_max_check_attempts))
logger.debug("[canopsis] initial host commands: %s " % str(self.host_commands))
logger.debug("[canopsis] initial host addresses: %s " % str(self.host_addresses))
def manage_initial_service_status_brok(self, b):
logger.debug("[Canopsis] processing initial_service_status")
if not hasattr(self, 'service_commands'):
logger.debug("[Canopsis] creating empty dict in service_commands")
self.service_commands = {}
if not hasattr(self, 'service_max_check_attempts'):
logger.debug("[Canopsis] creating empty dict in service_max_check_attempts")
self.service_max_check_attempts = {}
if not b.data['host_name'] in self.service_commands:
logger.debug("[Canopsis] creating empty dict for host %s service_commands" % b.data['host_name'])
self.service_commands[b.data['host_name']] = {}
self.service_commands[b.data['host_name']][b.data['service_description']] = b.data['check_command'].call
if not b.data['host_name'] in self.service_max_check_attempts:
logger.debug("[Canopsis] creating empty dict for host %s service_max_check_attempts" % b.data['host_name'])
self.service_max_check_attempts[b.data['host_name']] = {}
self.service_max_check_attempts[b.data['host_name']][b.data['service_description']] = b.data['max_check_attempts']
......@@ -224,7 +225,7 @@ class CanopsisModuleWorker(BrokerModuleWorker):
'command_name' : self.host_commands[b.data['host_name']],
'max_check_attempts': self.host_max_check_attempts[b.data['host_name']]
}
logger.info('MESSAGE: %s %s' % (b.type, b.data))
commonmessage = {
'connector' : u'shinken',
'connector_name' : unicode(self.identifier),
......@@ -252,6 +253,11 @@ class CanopsisModuleWorker(BrokerModuleWorker):
self.canopsis.postmessage(message)
# Old version need a fix for method name
if SHINKEN_VERSION == '2.7':
CanopsisModuleWorker.init_worker = CanopsisModuleWorker.init_worker_before_main
# Class for the Canopsis Broker
# Get broks and send them to a Carbon instance of Canopsis
class Canopsis_broker(WorkerBasedBrokerModule):
......@@ -411,8 +417,6 @@ class event2amqp():
# publish message
if self.connected():
logger.debug("[Canopsis] using routing key %s" % key)
logger.debug("[Canopsis] sending %s" % str(message))
try:
self.producer.revive(self.channel)
self.producer.publish(body=message, compression=None, routing_key=key, exchange=self.exchange_name)
......