diff --git a/broadview_collector/broadview_collector.py b/broadview_collector/broadview_collector.py index 9b988a0..eb1b166 100644 --- a/broadview_collector/broadview_collector.py +++ b/broadview_collector/broadview_collector.py @@ -28,19 +28,31 @@ import os import sys from importlib import import_module import ast -from oslo_log import log as logging -from oslo_config import cfg + +try: + from oslo_log import log as logging +except: + import logging + +osloConfig = True + +try: + from oslo_config import cfg +except: + osloConfig = False LOG = logging.getLogger(__name__) class BroadViewCollector(object): def __init__(self): - logging.register_options(cfg.CONF) - logging.set_defaults() - cfg.CONF(args=[], - project="broadview_collector", - default_config_files=["/etc/broadviewcollector.conf"]) - logging.setup(cfg.CONF, 'broadview_collector') + if osloConfig: + logging.register_options(cfg.CONF) + logging.set_defaults() + cfg.CONF(args=[], + project="broadview_collector", + default_config_files=["/etc/broadviewcollector.conf"]) + logging.setup(cfg.CONF, 'broadview_collector') + self._publishers = [] self._handlers = [] diff --git a/broadview_collector/plugins/kafkapublisher.py b/broadview_collector/plugins/kafkapublisher.py index a064d51..6d0168e 100644 --- a/broadview_collector/plugins/kafkapublisher.py +++ b/broadview_collector/plugins/kafkapublisher.py @@ -13,12 +13,16 @@ # limitations under the License. from broadviewpublisherbase import BroadViewPublisherBase -from kafka import KafkaProducer +import kafka from broadview_collector.serializers.bst_to_monasca import BSTToMonasca import json import ConfigParser +import sys -from oslo_log import log +try: + from oslo_log import log +except: + import logging as log LOG = log.getLogger(__name__) @@ -35,7 +39,7 @@ class BroadViewPublisher(BroadViewPublisherBase): def getKafkaProducer(self): try: - self._producer = KafkaProducer(bootstrap_servers=['{}:{}'.format(self._ip_address, self._port)]) + self._producer = kafka.KafkaProducer(bootstrap_servers=['{}:{}'.format(self._ip_address, self._port)]) except kafka.errors.NoBrokersAvailable as e: LOG.error("BroadViewPublisher: NoBrokersAvailable {}".format(e)) except: @@ -49,7 +53,6 @@ class BroadViewPublisher(BroadViewPublisherBase): self._producer = None def publish(self, host, data): - LOG.info('kafka publish enter') code = 500 # get a producer if needed if not self._producer: @@ -66,7 +69,6 @@ class BroadViewPublisher(BroadViewPublisherBase): LOG.info('unable to send to kafka topic {}: {}'.format(self._topic, sys.exc_info()[0])) else: code = 500 - LOG.info('kafka publish code {}'.format(code)) return code def __repr__(self): diff --git a/broadview_collector/plugins/logpublisher.py b/broadview_collector/plugins/logpublisher.py index c508efc..69ba40e 100644 --- a/broadview_collector/plugins/logpublisher.py +++ b/broadview_collector/plugins/logpublisher.py @@ -19,7 +19,11 @@ from broadviewpublisherbase import BroadViewPublisherBase from broadview_collector.serializers.bst_to_monasca import BSTToMonasca import json -from oslo_log import log +try: + from oslo_log import log +except: + import logging as log + import ConfigParser LOG = log.getLogger(__name__) diff --git a/broadview_collector/plugins/monascapublisher.py b/broadview_collector/plugins/monascapublisher.py index c41bca4..0251a29 100644 --- a/broadview_collector/plugins/monascapublisher.py +++ b/broadview_collector/plugins/monascapublisher.py @@ -19,7 +19,10 @@ from broadview_collector.serializers.bst_to_monasca import BSTToMonasca import json import ConfigParser -from oslo_log import log +try: + from oslo_log import log +except: + import logging as log LOG = log.getLogger(__name__) diff --git a/broadview_collector/plugins/stacklight.py b/broadview_collector/plugins/stacklight.py index c513bd2..dbdb93b 100644 --- a/broadview_collector/plugins/stacklight.py +++ b/broadview_collector/plugins/stacklight.py @@ -18,7 +18,10 @@ import json import ConfigParser import requests -from oslo_log import log +try: + from oslo_log import log +except: + import logging as log LOG = log.getLogger(__name__) diff --git a/broadview_collector/tools/bst_burst.py b/broadview_collector/tools/bst_burst.py index 6f3e9f9..ef9d3a2 100644 --- a/broadview_collector/tools/bst_burst.py +++ b/broadview_collector/tools/bst_burst.py @@ -19,7 +19,7 @@ import time # Change these to the host and port the collector is listening on -host = "172.16.170.184" +host = "10.14.244.106" port = 8082 ''' diff --git a/doc/kafka.md b/doc/kafka.md index b3f040d..9c56454 100644 --- a/doc/kafka.md +++ b/doc/kafka.md @@ -27,7 +27,7 @@ and topic and will override the default settings of the plugin: # ip address, port, and topic for kafka ip_address: 192.168.0.120 - port: 8088 + port: 9092 topic: broadview-bst You'll also need to enable the kafka plugin in /etc/broadviewcollector.conf. @@ -45,6 +45,8 @@ To test out, or experiment with, the kafka publisher plugin, consider doing the following: * Install broadview-collector. See the instructions in the main README.md +* Install the Python kafka module: + $ sudo easy_install kafka * Configure the collector for kafka as described above. * Install kafka. There are tutorials on the web for this. One that is known to work for Ubuntu 14.04 can be found at DigitalOcean's website: @@ -59,9 +61,9 @@ are using the DigitalOcean kafka tutorial: * In a separate terminal window, run the following to view the data that is being written to the kafka queue by BroadView Collector: - $ ~/kafka/bin/kafka-console-consumer --zookeeper 127.0.0.1:2181 --topic broadview.bst + $ ~/kafka/bin/kafka-console-consumer --zookeeper 127.0.0.1:2181 --topic broadview-bst -Note in the above, the path to kafka-console-consumber may be different based +Note in the above, the path to kafka-console-consumer may be different based on how you installed kafka. The IP address and port should work if you installed everything on a single host, and zookeeper is configured to use the default listen port of 2181. On Ubuntu 14.04, the settings can be found in