Commit 8a0a74e8 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

monitor: clean directory and parameter sections

monitor: continue cleaning section in monitor.cfg.in

monitor: continue fix and optimising monitor.cfg

monitor: Fix make RSS (introduced by clean sections)
parent 68636f8c
#!${dash-output:dash}
STATUS=$${monitor-parameters:result-dir}
RSS_FILE=$${monitor-parameters:rss-path}
STATUS={{ directory['monitor-result-bool'] }}
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 "Monitoring RSS feed" "https://[$${slap-parameters:ipv6-random}]:$${monitor-parameters:port}/$${deploy-index:filename}" > $RSS_FILE
cat $STATUS/* | $PYTHON $STATUS2RSS "Monitoring RSS feed" "{{ monitor_parameters['url'] }}/{{ monitor_parameters['index-filename'] }}" > $RSS_FILE
......@@ -7,23 +7,20 @@ key = $${slap-connection:key-file}
cert = $${slap-connection:cert-file}
[monitor-parameters]
monitor-dir = $${monitor-directory:var}/monitor
result-dir = $${:monitor-dir}/bool
json-filename = monitor.json
json-path = $${:monitor-dir}/$${:json-filename}
rss-path = $${:public-cgi}/$${:rss-filename}
json-path = $${monitor-directory:monitor-result}/$${:json-filename}
rss-filename = rssfeed.html
rss-path = $${monitor-directory:public-cgi}/$${:rss-filename}
executable = $${monitor-directory:bin}/monitor.py
cgi-bin = $${monitor-directory:cgi-bin}
monitoring-cgi = $${monitor-directory:monitoring-cgi}
knowledge0-cgi = $${monitor-directory:knowledge0-cgi}
public-cgi = $${monitor-directory:public-cgi}
port = 9685
private-directory = $${monitor-directory:monitor-private-directory}
htaccess-file = $${monitor-htaccess:htaccess-path}
htaccess-file = $${monitor-directory:etc}/.htaccess-monitor
url = https://[$${slap-parameters:ipv6-random}]:$${:port}
index-filename = index.cgi
index-path = $${monitor-directory:www}/$${:index-filename}
[monitor-directory]
recipe = slapos.cookbook:mkdirectory
# Standard directory needed by monitoring stack
home = $${buildout:directory}
etc = $${:home}/etc
bin = $${:home}/bin
......@@ -40,29 +37,22 @@ cron-entries = $${:etc}/cron.d
crontabs = $${:etc}/crontabs
cronstamps = $${:etc}/cronstamps
promises = $${:etc}/promise
ca-dir = $${:srv}/ssl
www = $${:var}/www
cgi-bin = $${:var}/cgi-bin
monitoring-cgi = $${:cgi-bin}/monitoring
knowledge0-cgi = $${:cgi-bin}/zero-knowledge
cron-entries = $${:etc}/cron.d
crontabs = $${:etc}/crontabs
cronstamps = $${:etc}/cronstamps
log = $${:var}/log
monitor = $${:etc}/monitor
monitor-result = $${:var}/monitor
monitor-result-bool = $${:var}/monitor
promise = $${:etc}/promise
public-cgi = $${:cgi-bin}/public
run = $${:var}/run
service = $${:etc}/service/
tmp = $${:home}/tmp
www = $${:var}/www
monitor-private-directory = $${:srv}/monitor-private
monitor-custom-scripts = $${:etc}/monitor
monitor-result = $${:var}/monitor
monitor-result-bool = $${:monitor-result}/bool
private-directory = $${:srv}/monitor-private
[public-symlink]
recipe = cns.recipe.symlink
symlink = $${monitor-parameters:public-cgi} = $${monitor-directory:www}/public
symlink = $${monitor-directory:public-cgi} = $${monitor-directory:www}/public
autocreate = true
[cron]
......@@ -85,14 +75,14 @@ log = $${monitor-directory:log}/cron.log
recipe = slapos.cookbook:cron.d
name = launch-monitor
frequency = */5 * * * *
command = $${monitor-parameters:executable} -a
command = $${deploy-monitor-script:rendered} -a
[cron-entry-rss]
<= cron
recipe = slapos.cookbook:cron.d
name = build-rss
frequency = */5 * * * *
command = $${make-rss:output}
command = $${make-rss:rendered}
[setup-static-files]
recipe = hexagonit.recipe.download
......@@ -105,11 +95,10 @@ mode = 0644
[deploy-index]
recipe = slapos.recipe.template:jinja2
template = ${index:location}/${index:filename}
rendered = $${monitor-directory:www}/$${:filename}
filename = index.cgi
rendered = $${monitor-parameters:index-path}
mode = 0744
context =
key cgi_directory monitor-parameters:cgi-bin
key cgi_directory monitor-directory:cgi-bin
raw index_template $${deploy-index-template:location}/$${deploy-index-template:filename}
key password zero-parameters:monitor-password
raw extra_eggs_interpreter ${buildout:directory}/bin/${extra-eggs:interpreter}
......@@ -126,7 +115,7 @@ mode = 0644
[deploy-status-cgi]
recipe = slapos.recipe.template:jinja2
template = ${status-cgi:location}/${status-cgi:filename}
rendered = $${monitor-parameters:monitoring-cgi}/$${:filename}
rendered = $${monitor-directory:monitoring-cgi}/$${:filename}
filename = status.cgi
mode = 0744
context =
......@@ -136,14 +125,14 @@ context =
[deploy-settings-cgi]
recipe = slapos.recipe.template:jinja2
template = ${settings-cgi:location}/${settings-cgi:filename}
rendered = $${monitor-parameters:knowledge0-cgi}/$${:filename}
rendered = $${monitor-directory:knowledge0-cgi}/$${:filename}
filename = settings.cgi
mode = 0744
context =
raw config_cfg $${buildout:directory}/knowledge0.cfg
raw timestamp $${buildout:directory}/.timestamp
raw python_executable ${buildout:executable}
key pwd monitor-parameters:knowledge0-cgi
key pwd monitor-directory:knowledge0-cgi
key this_file :filename
[deploy-monitor-script]
......@@ -154,32 +143,26 @@ mode = 0744
context =
section directory monitor-directory
key monitoring_file_json monitor-parameters:json-path
key monitoring_folder_bool monitor-parameters:result-dir
raw python_executable ${buildout:executable}
[deploy-rss-script]
recipe = hexagonit.recipe.download
url = ${rss-bin:destination}/${rss-bin:filename}
destination = $${monitor-directory:bin}
filename = ${rss-bin:filename}
mode = 0744
download-only = true
[make-rss]
recipe = slapos.recipe.template
url = ${make-rss-script:output}
output = $${monitor-directory:bin}/make-rss.sh
recipe = slapos.recipe.template:jinja2
template = ${make-rss-script:output}
rendered = $${monitor-directory:bin}/make-rss.sh
mode = 0744
context =
section directory monitor-directory
section monitor_parameters monitor-parameters
[monitor-htaccess]
recipe = plone.recipe.command
stop-on-error = true
htaccess-path = $${monitor-directory:monitor}/.htaccess
htaccess-path = $${monitor-parameters:htaccess-file}
command = ${apache:location}/bin/htpasswd -cb $${:htaccess-path} admin $${zero-parameters:monitor-password}
[monitor-directory-access]
recipe = plone.recipe.command
command = ln -s $${:source} $${monitor-directory:monitor-private-directory}
command = ln -s $${:source} $${monitor-directory:private-directory}
source =
[cadirectory]
......@@ -273,10 +256,10 @@ input = inline:
# XXX: security????
Options +ExecCGI
AddHandler cgi-script .cgi
DirectoryIndex $${deploy-index:filename}
DirectoryIndex $${monitor-parameters:index-filename}
</Directory>
Alias /private/ $${monitor-parameters:private-directory}/
<Directory $${monitor-parameters:private-directory}>
Alias /private/ $${monitor-directory:private-directory}/
<Directory $${monitor-directory:private-directory}>
Order Deny,Allow
Deny from env=AUTHREQUIRED
<Files ".??*">
......@@ -285,7 +268,7 @@ input = inline:
</Files>
AuthType Basic
AuthName "Private access"
AuthUserFile "$${monitor-parameters:htaccess-file}"
AuthUserFile "$${monitor-htaccess:htaccess-path}"
Require valid-user
Options Indexes FollowSymLinks
Satisfy all
......@@ -312,8 +295,8 @@ wrapper-path = $${monitor-directory:etc-run}/cgi-httpd-graceful
[monitor-promise]
recipe = slapos.cookbook:check_url_available
path = $${monitor-directory:promises}/monitor
url = https://[$${cgi-httpd-configuration-file:listening-ip}]:$${monitor-parameters:port}/$${deploy-index:filename}
path = $${monitor-directory:promise}/monitor
url = $${monitor-parameters:url}/$${monitor-parameters:index-filename}
check-secure = 1
dash_path = ${dash:location}/bin/dash
curl_path = ${curl:location}/bin/curl
......
......@@ -9,12 +9,12 @@ import time
from optparse import OptionParser, make_option
instance_path = "{{ directory['home'] }}"
monitor_dir = "{{ directory['monitor'] }}"
monitor_dir = "{{ directory['monitor-custom-scripts'] }}"
pid_dir = "{{ directory['run'] }}"
promise_dir = "{{ directory['promise'] }}"
monitoring_file_json = "{{ monitoring_file_json }}"
monitoring_folder_bool = "{{ monitoring_folder_bool }}"
monitoring_folder_bool = "{{ directory['monitor-result-bool'] }}"
option_list = [
make_option("-a", "--all", action="store_true", dest="all",
......@@ -31,15 +31,21 @@ option_list = [
def getListOfScripts(directory):
"""
Get the list of script inside of a directory (not recursive)
"""
scripts = []
if os.path.exists(directory) and os.path.isdir(directory):
for file in os.listdir(directory):
scripts.append(os.path.join(directory, file))
for file_name in os.listdir(directory):
file = os.path.join(directory, file_name)
if os.access(file, os.X_OK) and not os.path.isdir(file):
scripts.append(file)
else:
exit("There is a problem in your directories" \
"of monitoring. Please check them")
return scripts
def runServices(directory):
services = getListOfScripts(directory)
result = {}
......
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