Commit 0296b20a authored by Nicolas Wavrant's avatar Nicolas Wavrant

stack-monitor: rss feed remembers previous records

parent 8098add8
#!${dash-output:dash}
status=$${directory:monitor-result}/monitor.bool
RSS_DIR=$${directory:monitor-result}
STATUS=$${monitor-parameters:result-dir}
RSS_FILE=$${monitor-parameters:rss-path}
PYTHON=${buildout:directory}/bin/${extra-eggs:interpreter}
STATUS2RSS=${rss-bin:location}/${rss-bin:filename}
NAME=`basename $status`
cat $status | $PYTHON $STATUS2RSS "Backup status $NAME" "http://localhost/$NAME.rss" > $RSS_DIR/monitor.rss
\ No newline at end of file
NAME=`basename $STATUS`
cat $STATUS/* | $PYTHON $STATUS2RSS "Monitoring RSS feed" "http://[$${slap-parameters:ipv6-random}]/feed" > $RSS_FILE
\ No newline at end of file
......@@ -6,6 +6,14 @@ url = $${slap-connection:server-url}
key = $${slap-connection:key-file}
cert = $${slap-connection:cert-file}
[monitor-parameters]
monitor-dir = $${directory:monitor-result}
result-dir = $${:monitor-dir}/bool
json-filename = monitor.json
json-path = $${:monitor-dir}/$${:json-filename}
rss-path = $${directory:www}/monitor.html
executable = $${directory:bin}/monitor.py
[directory]
home = $${buildout:directory}
etc = $${:home}/etc
......@@ -20,6 +28,7 @@ cronstamps = $${:etc}/cronstamps
log = $${:var}/log
monitor = $${:etc}/monitor
monitor-result = $${:var}/monitor
monitor-result-bool = $${monitor-parameters:result-dir}
promise = $${:etc}/promise
run = $${:var}/run
service = $${:etc}/service/
......@@ -46,7 +55,7 @@ log = $${directory:log}/cron.log
recipe = slapos.cookbook:cron.d
name = launch-monitor
frequency = * * * * *
command = $${deploy-monitor-script:rendered} -a
command = $${monitor-parameters:executable} -a
[cron-entry-rss]
<= cron
......@@ -58,12 +67,12 @@ command = $${make-rss:output}
[deploy-monitor-script]
recipe = slapos.recipe.template:jinja2
template = ${monitor-bin:location}/${monitor-bin:filename}
rendered = $${directory:bin}/monitor.py
rendered = $${monitor-parameters:executable}
mode = 0744
context =
section directory directory
raw monitoring_file_json $${directory:monitor-result}/monitor.json
raw monitoring_file_bool $${directory:monitor-result}/monitor.bool
key monitoring_file_json monitor-parameters:json-path
key monitoring_folder_bool monitor-parameters:result-dir
[deploy-rss-script]
recipe = hexagonit.recipe.download
......@@ -136,6 +145,7 @@ nginx_conf = $${nginx-conf:rendered}
# Executables
bin_nginx = ${nginx:location}/sbin/nginx
bin_launcher = $${directory:bin}/nginx-launcher
rss_feed = $${monitor-parameters:rss-path}
www = $${directory:www}
[nginx-conf]
......
......@@ -13,8 +13,8 @@ monitor_dir = "{{ directory['monitor'] }}"
pid_dir = "{{ directory['run'] }}"
promise_dir = "{{ directory['promise'] }}"
monitoring_file_bool = "{{ monitoring_file_bool }}"
monitoring_file_json = "{{ monitoring_file_json }}"
monitoring_folder_bool = "{{ monitoring_folder_bool }}"
option_list = [
make_option("-a", "--all", action="store_true", dest="all",
......@@ -88,14 +88,16 @@ def runScripts(directory):
def writeFiles(monitors):
if len(monitors) == 0:
message = "SUCCESS : everything is ok"
message = "SUCCESS : everything is ok\n"
else:
message ="FAILURE : something went wrong"
message ="FAILURE : something went wrong\n"
date = datetime.datetime.now().ctime()
monitors['datetime'] = date
open(monitoring_file_bool, "w+").write(date + "," + message)
file_bool = os.path.join(monitoring_folder_bool, str(time.time()))
open(file_bool, "w+").write(date + "," + message)
open(monitoring_file_json, "w+").write(json.dumps(monitors))
if __name__ == "__main__":
parser = OptionParser(option_list=option_list)
monitors = {}
......
......@@ -45,5 +45,9 @@ http {
location / {
root {{ param_nginx['www'] }};
}
location /feed {
root {{ param_nginx['www'] }};
index {{ param_nginx['rss_feed'] }};
}
}
}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment