Minor changes to support running outside of OpenStack environment, plus some bug fixes
Change-Id: I4b274f8bfab592322088aff7b0f4761ace6312ff
This commit is contained in:
parent
5f3fdd5248
commit
9fd350b18d
@ -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):
|
||||
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 = []
|
||||
|
||||
|
@ -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):
|
||||
|
@ -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__)
|
||||
|
@ -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__)
|
||||
|
||||
|
@ -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__)
|
||||
|
||||
|
@ -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
|
||||
|
||||
'''
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user