diff --git a/stack/monitor/buildout.cfg b/stack/monitor/buildout.cfg index 80c466139f18b5cb53f5d99d9723e32e12b8033f..5542effb870e672e05603c01a3007644c16570c5 100644 --- a/stack/monitor/buildout.cfg +++ b/stack/monitor/buildout.cfg @@ -100,7 +100,7 @@ recipe = slapos.recipe.template:jinja2 filename = template-monitor.cfg template = ${:_profile_base_location_}/instance-monitor.cfg.jinja2.in rendered = ${buildout:directory}/template-monitor.cfg -md5sum = 354da434447697b8b4f503a62599cf32 +md5sum = 7ae453794e320d3b512ec037efc5fc1f context = key apache_location apache:location key gzip_location gzip:location @@ -131,7 +131,7 @@ depends = [monitor2-bin] <= monitor-template-script filename = monitor.py -md5sum = 3166f5d110fda63aade1ca486dfb7996 +md5sum = 280412f9024030c8cae343c2b07e5130 [run-promise-py] recipe = slapos.recipe.template:jinja2 diff --git a/stack/monitor/instance-monitor.cfg.jinja2.in b/stack/monitor/instance-monitor.cfg.jinja2.in index 0fd49f890f82f80ae52f74305c91ebbd4105e651..e75757751cedf886b5fe562a30970bbec3a2b407 100644 --- a/stack/monitor/instance-monitor.cfg.jinja2.in +++ b/stack/monitor/instance-monitor.cfg.jinja2.in @@ -364,8 +364,8 @@ mode = 0644 context = section parameter_dict monitor-password-promise-conf-parameter [publish] -<= monitor-base -monitor-base-url = ${monitor-conf-parameters:base-url} +# XXX depends on monitor-base section +monitor-base-url = ${monitor-base:base-url} monitor-url = ${:monitor-base-url}/public/feeds monitor-user = ${monitor-instance-parameter:username} monitor-password = ${monitor-instance-parameter:password} @@ -415,6 +415,7 @@ check-secure = 1 recipe = plone.recipe.command command = true update-command = +base-url = ${monitor-conf-parameters:base-url} depends = ${monitor-globalstate-cron-entry:name} ${monitor-configurator-cron-entry:name} diff --git a/stack/monitor/scripts/monitor.py b/stack/monitor/scripts/monitor.py index 4ab8141dd9820d665e7a79ad9384e4dbd248fadb..ea45f4f540c94f9e9de789cf5aecbb5e488c08ed 100644 --- a/stack/monitor/scripts/monitor.py +++ b/stack/monitor/scripts/monitor.py @@ -245,6 +245,28 @@ class Monitoring(object): print "Bad Json file at %s" % url return 'Unknown Instance' + def getReportInfoFromFilename(self, filename): + splited_filename = filename.split('_every_') + possible_time_list = ['hour', 'minute'] + if len(splited_filename) == 1: + return (filename, "* * * * *") + + run_time = splited_filename[1].split('_') + report_name = splited_filename[0] + if len(run_time) != 2 or not run_time[1] in possible_time_list: + return (report_name, "* * * * *") + + try: + value = int(run_time[0]) + except ValueError: + print "Warning: Bad report filename: %s" % filename + return (report_name, "* * * * *") + + if run_time[1] == 'hour': + return (report_name, "* */%s * * *" % value) + if run_time[1] == 'minute': + return (report_name, "*/%s * * * *" % value) + def configureFolders(self): # configure public and private folder self.createSymlinksFromConfig(self.webdav_folder, [self.public_folder]) @@ -387,8 +409,6 @@ class Monitoring(object): def generateReportCronEntries(self): cron_line_list = [] - # We should add the possibility to modify this parameter later from monitor interface - report_frequency = "*/20 * * * *" report_name_list = [name.replace('.report.json', '') for name in os.listdir(self.report_folder) if name.endswith('.report.json')] @@ -396,11 +416,12 @@ class Monitoring(object): for filename in os.listdir(self.report_script_folder): report_script = os.path.join(self.report_script_folder, filename) if os.path.isfile(report_script) and os.access(report_script, os.X_OK): - report_name = os.path.splitext(filename)[0] + report_name, frequency = self.getReportInfoFromFilename(filename) + # report_name = os.path.splitext(filename)[0] report_json_path = "%s.report.json" % report_name report_cmd_line = [ - report_frequency, + frequency, self.promise_runner, '--pid_path "%s"' % os.path.join(self.service_pid_folder, "%s.pid" % filename),