DaanHoogland commented on a change in pull request #3575: [WIP DO NOT MERGE]
Health check feature for virtual router
URL: https://github.com/apache/cloudstack/pull/3575#discussion_r358205508
##########
File path: systemvm/debian/opt/cloud/bin/cs/CsMonitor.py
##########
@@ -17,27 +17,55 @@
import logging
from cs.CsDatabag import CsDataBag
from CsFile import CsFile
+import json
MON_CONFIG = "/etc/monitor.conf"
+HC_CONFIG = "/root/health_checks_data.json"
class CsMonitor(CsDataBag):
""" Manage dhcp entries """
def process(self):
- if "config" not in self.dbag:
- return
- procs = [x.strip() for x in self.dbag['config'].split(',')]
- file = CsFile(MON_CONFIG)
- for proc in procs:
- bits = [x for x in proc.split(':')]
- if len(bits) < 5:
- continue
- for i in range(0, 4):
- file.add(bits[i], -1)
- file.commit()
+ if "config" in self.dbag:
+ procs = [x.strip() for x in self.dbag['config'].split(',')]
+ file = CsFile(MON_CONFIG)
+ for proc in procs:
+ bits = [x for x in proc.split(':')]
+ if len(bits) < 5:
+ continue
+ for i in range(0, 4):
+ file.add(bits[i], -1)
+ file.commit()
+
+ hc_data = {}
+
+ cron_rep_basic = self.dbag["health_checks_basic_run_interval"] if
"health_checks_basic_run_interval" in self.dbag else 3
+ cron_rep_advance = self.dbag["health_checks_advance_run_interval"] if
"health_checks_advance_run_interval" in self.dbag else 0
+ hc_data["health_checks_basic_run_interval"] = cron_rep_basic
+ hc_data["health_checks_advance_run_interval"] = cron_rep_advance
+
+ hc_data["health_checks_enabled"] = self.dbag["health_checks_enabled"]
if "health_checks_enabled" in self.dbag else False
+
+ if "excluded_health_checks" in self.dbag:
+ excluded_checks = self.dbag["excluded_health_checks"]
+ hc_data["excluded_health_checks"] = [ch.strip() for ch in
excluded_checks.split(",")] if len(excluded_checks) > 0 else []
+ else:
+ hc_data["excluded_health_checks"] = []
+ if "additional_data" in self.dbag:
+ hc_data["additional_data"] = self.dbag["additional_data"]
+ else:
+ hc_data["additional_data"] = {}
+
cron = CsFile("/etc/cron.d/process")
+ cron.deleteLine("root /usr/bin/python /root/monitorServices.py")
cron.add("SHELL=/bin/bash", 0)
cron.add("PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin", 1)
- cron.add("*/3 * * * * root /usr/bin/python /root/monitorServices.py",
-1)
+ if cron_rep_basic > 0:
+ cron.add("*/" + str(cron_rep_basic) + " * * * * root
/usr/bin/python /root/monitorServices.py basic", -1)
+ if cron_rep_advance > 0:
+ cron.add("*/" + str(cron_rep_advance) + " * * * * root
/usr/bin/python /root/monitorServices.py advance", -1)
cron.commit()
+
+ with open(HC_CONFIG, 'w') as f:
Review comment:
I think the extra code warants a method with a name.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services