Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 我有个问题,我没有';t能否连接到我的主题卡夫卡消费者?_Python_Apache Kafka - Fatal编程技术网

Python 我有个问题,我没有';t能否连接到我的主题卡夫卡消费者?

Python 我有个问题,我没有';t能否连接到我的主题卡夫卡消费者?,python,apache-kafka,Python,Apache Kafka,我有问题,我无法连接到我的主题卡夫卡,我需要插件Nagios来检查卡夫卡主题中的事件ospf和bgp日志 你有解决这个问题的脚本吗?我从心底感谢你 from kafka import KafkaConsumer import sys username = "soufiane" password = "student" security_protocol = "SASL_SSL" bootstrap_servers = ['10.103

我有问题,我无法连接到我的主题卡夫卡,我需要插件Nagios来检查卡夫卡主题中的事件ospf和bgp日志

你有解决这个问题的脚本吗?我从心底感谢你

from kafka import KafkaConsumer
import sys

username = "soufiane"
password = "student"
security_protocol = "SASL_SSL"
bootstrap_servers = ['10.103.239.83:9092']
topicName = 'tcn-ospf'

consumer = KafkaConsumer(topicName, bootstrap_servers=bootstrap_servers,
                         auto_offset_reset='earliest', ssl_check_hostname=True, security_protocol=security_protocol,
                         sasl_plain_username=username,
                         sasl_plain_password=password)
try:
    for message in consumer:
        print("%s:%d:%d: key=%s value=%s" % (
            message.topic, message.partition, message.offset, message.key, message.value,))
except KeyboardInterrupt:
    print('UNKNOWN: failed to check topic kafka')
    sys.exit(3)