Commit 7de120ef authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

resilient-stack: include feed monitoring on pbs server

resilient: improve feed monitoring to provide feed access directly in monitor
parent c0553925
......@@ -64,3 +64,14 @@ url = $${monitor-frontend:config-url}/$${deploy-index-template:filename}
# Extends publish section with resilient parameters
[publish-connection-informations]
<= resilient-publish-connection-parameter
[monitor-check-resilient-feed-file]
recipe = slapos.recipe.template:jinja2
template = ${template-monitor-check-resilient-feed:location}/${template-monitor-check-resilient-feed:filename}
rendered = $${monitor-directory:monitor-custom-scripts}/check-create-resilient-feed-files.py
mode = 700
context =
key input_feed_directory directory:notifier-feeds
key monitor_feed_directory monitor-directory:public-cgi
raw base_url http://[$${notifier:host}]:$${notifier:port}/get/
raw python_executable ${buildout:executable}
......@@ -104,6 +104,18 @@ output = ${buildout:directory}/template-wrapper.cfg
mode = 0644
md5sum = 8cde04bfd0c0e9bd56744b988275cfd8
##################
# Monitor element
#
[template-monitor-check-resilient-feed]
recipe = hexagonit.recipe.download
url = ${:_profile_base_location_}/templates/monitor-check-resilient-feed.in
download-only = true
#md5sum = 7c0608eafb5c6998846851744a70b3de
filename = monitor-check-resilient-feed.in
mode = 0644
[versions]
# Pin Jinja2 to 2.6, as 2.7 breaks current code
Jinja2 = 2.6
......
......@@ -27,6 +27,7 @@ parts =
## Monitor for pbs
monitor-current-log-access
monitor-backup-log-access
monitor-check-resilient-feed-file
extends = ${monitor-template:output}
eggs-directory = ${buildout:eggs-directory}
......@@ -258,3 +259,14 @@ source = $${directory:logrotate-backup}
[monitor-current-log-access]
< = monitor-directory-access
source = $${basedirectory:log}
[monitor-check-resilient-feed-file]
recipe = slapos.recipe.template:jinja2
template = ${template-monitor-check-resilient-feed:location}/${template-monitor-check-resilient-feed:filename}
rendered = $${monitor-directory:monitor-custom-scripts}/check-create-resilient-feed-files.py
mode = 700
context =
key input_feed_directory directory:notifier-feeds
key monitor_feed_directory monitor-directory:public-cgi
key base_url publish-connection-informations:feeds-url
raw python_executable ${buildout:executable}
#!{{ python_executable }}
import os
import urllib2
import sys
input_feed_directory = '{{ input_feed_directory }}'
monitor_feed_directory = '{{ monitor_feed_directory }}'
base_url = "{{ base_url }}"
feed_file_list = os.listdir(input_feed_directory)
rss_ok = True
for feed_file_name in feed_file_list:
print "Getting %s" % feed_file_name
url = base_url + feed_file_name
try:
feed = urllib2.urlopen(url)
body = feed.read()
open(os.path.join(monitor_feed_directory, feed_file_name + '.rss'), 'w').write(body)
print "FEED is ok"
except urllib2.HTTPError as e:
sys.exit("%s is unvailable: %s" % (feed_file_name, e))
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