projects
/
osm
/
MON.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Adds support for custom project and user domain names defined in vim config
[osm/MON.git]
/
osm_mon
/
cmd
/
mon_healthcheck.py
diff --git
a/osm_mon/cmd/mon_healthcheck.py
b/osm_mon/cmd/mon_healthcheck.py
index
412410b
..
cc6fd8f
100644
(file)
--- a/
osm_mon/cmd/mon_healthcheck.py
+++ b/
osm_mon/cmd/mon_healthcheck.py
@@
-19,24
+19,29
@@
# For those usages not covered by the Apache License, Version 2.0 please
# contact: bdiaz@whitestack.com or glavado@whitestack.com
##
# For those usages not covered by the Apache License, Version 2.0 please
# contact: bdiaz@whitestack.com or glavado@whitestack.com
##
-
+import argparse
+import asyncio
import logging
import subprocess
import sys
import logging
import subprocess
import sys
-import uuid
import requests
import requests
+from aiokafka import AIOKafkaConsumer
-from osm_mon.core.
message_bus.consumer import Consumer
+from osm_mon.core.
config import Config
log = logging.getLogger(__name__)
def main():
log = logging.getLogger(__name__)
def main():
- # Check Kafka
+ parser = argparse.ArgumentParser(prog='osm-mon-healthcheck')
+ parser.add_argument('--config-file', nargs='?', help='MON configuration file')
+ args = parser.parse_args()
+ cfg = Config(args.config_file)
+
if not _processes_running():
sys.exit(1)
if not _processes_running():
sys.exit(1)
- if not _is_kafka_ok():
+ if not _is_kafka_ok(
cfg.get('message', 'host'), cfg.get('message', 'port')
):
sys.exit(1)
if not _is_prometheus_exporter_ok():
sys.exit(1)
sys.exit(1)
if not _is_prometheus_exporter_ok():
sys.exit(1)
@@
-49,9
+54,10
@@
def _processes_running():
if process_name in row:
return True
return False
if process_name in row:
return True
return False
+
processes_to_check = ['osm-mon-collector', 'osm-mon-evaluator', 'osm-mon-server']
ps = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE).communicate()[0]
processes_to_check = ['osm-mon-collector', 'osm-mon-evaluator', 'osm-mon-server']
ps = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE).communicate()[0]
- processes_running = ps.split('\n')
+ processes_running = ps.
decode().
split('\n')
for p in processes_to_check:
if not _contains_process(processes_running, p):
return False
for p in processes_to_check:
if not _contains_process(processes_running, p):
return False
@@
-68,13
+74,17
@@
def _is_prometheus_exporter_ok():
return False
return False
-def _is_kafka_ok():
+def _is_kafka_ok(host, port):
+ async def _test_kafka(loop):
+ consumer = AIOKafkaConsumer(
+ 'healthcheck',
+ loop=loop, bootstrap_servers='{}:{}'.format(host, port))
+ await consumer.start()
+ await consumer.stop()
+
try:
try:
- common_consumer = Consumer("mon-healthcheck-" + str(uuid.uuid4()))
- topics = ['alarm_request', 'vim_account']
- common_consumer.subscribe(topics)
- common_consumer.poll()
- common_consumer.close(autocommit=False)
+ loop = asyncio.get_event_loop()
+ loop.run_until_complete(_test_kafka(loop))
return True
except Exception:
log.exception("MON can not connect to Kafka")
return True
except Exception:
log.exception("MON can not connect to Kafka")