Commit 82d2d645 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

Merge remote-tracking branch 'origin/master' into erp5-component

parents 252a5425 5b2b751e
...@@ -9,8 +9,8 @@ extends = ...@@ -9,8 +9,8 @@ extends =
[squid] [squid]
recipe = hexagonit.recipe.cmmi recipe = hexagonit.recipe.cmmi
url = http://www.squid-cache.org/Versions/v3/3.2/squid-3.2.1.tar.gz url = http://www1.at.squid-cache.org/Versions/v3/3.4/squid-3.4.4.tar.gz
md5sum = 3fb81acc6b70a432e3f0d8a0491056dc md5sum = b36ab3696485a86b43d9194ac9b6b7fe
configure-options = configure-options =
--disable-dependency-tracking --disable-dependency-tracking
--disable-translation --disable-translation
......
...@@ -4,6 +4,7 @@ extends = ...@@ -4,6 +4,7 @@ extends =
../../component/git/buildout.cfg ../../component/git/buildout.cfg
../../stack/slapos.cfg ../../stack/slapos.cfg
../../component/dash/buildout.cfg
../../component/binutils/buildout.cfg ../../component/binutils/buildout.cfg
../../component/lxml-python/buildout.cfg ../../component/lxml-python/buildout.cfg
../../component/apache/buildout.cfg ../../component/apache/buildout.cfg
...@@ -13,10 +14,13 @@ extends = ...@@ -13,10 +14,13 @@ extends =
../../component/logrotate/buildout.cfg ../../component/logrotate/buildout.cfg
../../component/rdiff-backup/buildout.cfg ../../component/rdiff-backup/buildout.cfg
../../component/squid/buildout.cfg ../../component/squid/buildout.cfg
# Monitoring stack
../../stack/monitor/buildout.cfg
parts += parts +=
slapos-cookbook slapos-cookbook
slapos-toolbox slapos-toolbox
eggs
template template
template-apache-frontend template-apache-frontend
template-apache-replicate template-apache-replicate
...@@ -36,12 +40,16 @@ recipe = zc.recipe.egg ...@@ -36,12 +40,16 @@ recipe = zc.recipe.egg
eggs = eggs =
${lxml-python:egg} ${lxml-python:egg}
slapos.toolbox slapos.toolbox
plone.recipe.command
scripts = scripts =
killpidfromfile killpidfromfile
onetimedownload onetimedownload
[eggs]
recipe = zc.recipe.egg
eggs =
plone.recipe.command
[check-recipe] [check-recipe]
recipe = plone.recipe.command recipe = plone.recipe.command
stop-on-error = true stop-on-error = true
...@@ -59,20 +67,20 @@ mode = 0644 ...@@ -59,20 +67,20 @@ mode = 0644
[template-apache-frontend] [template-apache-frontend]
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-apache-frontend.cfg url = ${:_profile_base_location_}/instance-apache-frontend.cfg
md5sum = f0a507fed2b1dcab5530c892adce8327 md5sum = f5ec3d3b29d20ccdb00e3b64aa588fa5
output = ${buildout:directory}/template-apache-frontend.cfg output = ${buildout:directory}/template-apache-frontend.cfg
mode = 0644 mode = 0644
[template-apache-replicate] [template-apache-replicate]
recipe = slapos.recipe.build:download recipe = slapos.recipe.build:download
url = ${:_profile_base_location_}/instance-apache-replicate.cfg.in url = ${:_profile_base_location_}/instance-apache-replicate.cfg.in
md5sum = 02658d39fa429fef7faba9658e4f1474 md5sum = 82c88a4b4856bfffec3d7ef24e372f38
mode = 0644 mode = 0644
[template-slave-list] [template-slave-list]
recipe = slapos.recipe.build:download recipe = slapos.recipe.build:download
url = ${:_profile_base_location_}/templates/apache-custom-slave-list.cfg.in url = ${:_profile_base_location_}/templates/apache-custom-slave-list.cfg.in
md5sum = f002a8fc8fc5d18adbd8ac1ee054e852 md5sum = 5c49a66a0fe4b92ab21ef7148ea4e5ff
mode = 640 mode = 640
[template-slave-configuration] [template-slave-configuration]
...@@ -90,7 +98,7 @@ mode = 640 ...@@ -90,7 +98,7 @@ mode = 640
[template-apache-frontend-configuration] [template-apache-frontend-configuration]
recipe = slapos.recipe.build:download recipe = slapos.recipe.build:download
url = ${:_profile_base_location_}/templates/apache.conf.in url = ${:_profile_base_location_}/templates/apache.conf.in
md5sum = bae89ebc6c5e75b12535fbd6c37f647d md5sum = 72922908c1f4e72c92bb03e072660c7c
mode = 640 mode = 640
[template-apache-cached-configuration] [template-apache-cached-configuration]
...@@ -121,7 +129,7 @@ mode = 640 ...@@ -121,7 +129,7 @@ mode = 640
[template-default-virtualhost] [template-default-virtualhost]
recipe = slapos.recipe.build:download recipe = slapos.recipe.build:download
url = ${:_profile_base_location_}/templates/000.conf.in url = ${:_profile_base_location_}/templates/000.conf.in
md5sum = c2bbf029e6adc432de0884fb5cf5d2ab md5sum = b40ffdab93a80b40046e3bbb2f7a58bc
mode = 640 mode = 640
[template-default-slave-virtualhost] [template-default-slave-virtualhost]
...@@ -139,7 +147,7 @@ mode = 640 ...@@ -139,7 +147,7 @@ mode = 640
[template-squid-configuration] [template-squid-configuration]
recipe = slapos.recipe.build:download recipe = slapos.recipe.build:download
url = ${:_profile_base_location_}/templates/squid.conf.jinja2 url = ${:_profile_base_location_}/templates/squid.conf.jinja2
md5sum = 9f70474181372d34c8cd203f24ab546e md5sum = f17753fa87da074bc949b2967a330099
mode = 640 mode = 640
[template-empty] [template-empty]
...@@ -147,3 +155,10 @@ recipe = slapos.recipe.build:download ...@@ -147,3 +155,10 @@ recipe = slapos.recipe.build:download
url = ${:_profile_base_location_}/templates/empty.in url = ${:_profile_base_location_}/templates/empty.in
md5sum = c2314c3a9c3412a38d14b312d3df83c1 md5sum = c2314c3a9c3412a38d14b312d3df83c1
mode = 640 mode = 640
[template-wrapper]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/templates/wrapper.in
output = ${buildout:directory}/template-wrapper.cfg
mode = 0644
md5sum = 8cde04bfd0c0e9bd56744b988275cfd8
...@@ -21,11 +21,33 @@ parts = ...@@ -21,11 +21,33 @@ parts =
promise-squid promise-squid
dynamic-template-default-vh dynamic-template-default-vh
not-found-html not-found-html
promise-frontend-apache-configuration
promise-cached-apache-configuration
promise-apache-frontend-v4-https promise-apache-frontend-v4-https
promise-apache-frontend-v4-http promise-apache-frontend-v4-http
promise-apache-frontend-v6-https promise-apache-frontend-v6-https
promise-apache-frontend-v6-http promise-apache-frontend-v6-http
promise-apache-cached promise-apache-cached
## Monitoring part
###Parts to add for monitoring
certificate-authority
cron-entry-monitor
cron-entry-rss
deploy-index
deploy-settings-cgi
deploy-status-cgi
setup-static-files
certificate-authority
zero-parameters
public-symlink
cgi-httpd-wrapper
cgi-httpd-graceful-wrapper
monitor-promise
monitor-instance-log-access
## Monitor for apache
monitor-current-log-access
monitor-backup-log-access
extends = ${monitor-template:output}
eggs-directory = ${buildout:eggs-directory} eggs-directory = ${buildout:eggs-directory}
...@@ -95,6 +117,14 @@ apache-directory = ${apache-2.2:location} ...@@ -95,6 +117,14 @@ apache-directory = ${apache-2.2:location}
apache-ipv6 = $${instance-parameter:ipv6-random} apache-ipv6 = $${instance-parameter:ipv6-random}
apache-https-port = $${instance-parameter:configuration.port} apache-https-port = $${instance-parameter:configuration.port}
[monitor-current-log-access]
< = monitor-directory-access
source = $${directory:log}
[monitor-backup-log-access]
< = monitor-directory-access
source = $${directory:logrotate-backup}
[jinja2-template-base] [jinja2-template-base]
recipe = slapos.recipe.template:jinja2 recipe = slapos.recipe.template:jinja2
rendered = $${buildout:directory}/$${:filename} rendered = $${buildout:directory}/$${:filename}
...@@ -140,6 +170,7 @@ extra-context = ...@@ -140,6 +170,7 @@ extra-context =
section logrotate_dict logrotate section logrotate_dict logrotate
section frontend_configuration frontend-configuration section frontend_configuration frontend-configuration
section apache_configuration apache-configuration section apache_configuration apache-configuration
section connection_information_dict publish-connection-informations
[dynamic-custom-group-template-slave-list] [dynamic-custom-group-template-slave-list]
< = jinja2-template-base < = jinja2-template-base
...@@ -292,6 +323,10 @@ pid-file = $${directory:run}/httpd.pid ...@@ -292,6 +323,10 @@ pid-file = $${directory:run}/httpd.pid
protected-path = / protected-path = /
access-control-string = none access-control-string = none
cached-rewrite-file = $${directory:etc}/apache_rewrite_cached.txt cached-rewrite-file = $${directory:etc}/apache_rewrite_cached.txt
frontend-configuration-verification = ${apache-2.2:location}/bin/httpd -Sf $${:frontend-configuration}
frontend-graceful-command = $${:frontend-configuration-verification}; if [ $? -eq 0 ]; then kill -USR1 $(cat $${:pid-file}); fi
cached-configuration-verification = ${apache-2.2:location}/bin/httpd -Sf $${:cached-configuration}
cached-graceful-command = $${:cached-configuration-verification}; if [ $? -eq 0 ]; then kill -USR1 $(cat $${apache-configuration:cache-pid-file}); fi
# Apache for cache configuration # Apache for cache configuration
cache-access-log = $${directory:log}/frontend-apache-access-cached.log cache-access-log = $${directory:log}/frontend-apache-access-cached.log
...@@ -381,7 +416,7 @@ name = apache ...@@ -381,7 +416,7 @@ name = apache
log = $${apache-configuration:error-log} $${apache-configuration:access-log} log = $${apache-configuration:error-log} $${apache-configuration:access-log}
frequency = daily frequency = daily
rotatep-num = 30 rotatep-num = 30
post = ${buildout:bin-directory}/killpidfromfile $${apache-configuration:pid-file} SIGUSR1 post = $${apache-configuration:frontend-graceful-command}
sharedscripts = true sharedscripts = true
notifempty = true notifempty = true
create = true create = true
...@@ -393,7 +428,7 @@ name = apache-cached ...@@ -393,7 +428,7 @@ name = apache-cached
log = $${apache-configuration:cache-error-log} $${apache-configuration:cache-access-log} log = $${apache-configuration:cache-error-log} $${apache-configuration:cache-access-log}
frequency = daily frequency = daily
rotatep-num = 30 rotatep-num = 30
post = ${buildout:bin-directory}/killpidfromfile $${apache-configuration:cache-pid-file} SIGUSR1 post = $${apache-configuration:cached-graceful-command}
sharedscripts = true sharedscripts = true
notifempty = true notifempty = true
create = true create = true
...@@ -470,15 +505,39 @@ port = $${apache-configuration:cache-port} ...@@ -470,15 +505,39 @@ port = $${apache-configuration:cache-port}
# End of Squid part # End of Squid part
### Apaches Graceful and promises
[frontend-apache-graceful] [frontend-apache-graceful]
recipe = slapos.cookbook:wrapper < = jinja2-template-base
command-line = ${buildout:bin-directory}/killpidfromfile $${apache-configuration:pid-file} SIGUSR1 template = ${template-wrapper:output}
wrapper-path = $${directory:etc-run}/frontend-apache-graceful rendered = $${directory:etc-run}/frontend-apache-safe-graceful
mode = 0700
extra-context =
key content apache-configuration:frontend-graceful-command
[cached-apache-graceful] [cached-apache-graceful]
recipe = slapos.cookbook:wrapper < = jinja2-template-base
command-line = ${buildout:bin-directory}/killpidfromfile $${apache-configuration:cache-pid-file} SIGUSR1 template = ${template-wrapper:output}
wrapper-path = $${directory:etc-run}/cached-apache-graceful rendered = $${directory:etc-run}/cached-apache-safe-graceful
mode = 0700
extra-context =
key content apache-configuration:cached-graceful-command
# Promises checking configuration:
[promise-frontend-apache-configuration]
< = jinja2-template-base
template = ${template-wrapper:output}
rendered = $${directory:promise}/frontend-apache-configuration-promise
mode = 0700
extra-context =
key content apache-configuration:frontend-configuration-verification
[promise-cached-apache-configuration]
< = jinja2-template-base
template = ${template-wrapper:output}
rendered = $${directory:promise}/cached-apache-configuration-promise
mode = 0700
extra-context =
key content apache-configuration:cached-configuration-verification
[promise-apache-frontend-v4-https] [promise-apache-frontend-v4-https]
recipe = slapos.cookbook:check_port_listening recipe = slapos.cookbook:check_port_listening
......
...@@ -59,20 +59,24 @@ sla-{{ parameter }} = {{ slapparameter_dict.pop( sla_key + parameter ) }} ...@@ -59,20 +59,24 @@ sla-{{ parameter }} = {{ slapparameter_dict.pop( sla_key + parameter ) }}
[replicate] [replicate]
<= slap-connection <= slap-connection
recipe = slapos.cookbook:request recipe = slapos.cookbook:requestoptional
software-url = ${slap-connection:software-release-url} software-url = ${slap-connection:software-release-url}
software-type = {{frontend_type}} software-type = {{frontend_type}}
return = private-ipv4 public-ipv4 slave-instance-information-list return = private-ipv4 public-ipv4 slave-instance-information-list monitor_url
config = {{ ' '.join(slapparameter_dict.keys()) + ' ' + slave_list_name }} config = {{ ' '.join(slapparameter_dict.keys()) + ' ' + slave_list_name }}
{% for parameter, value in slapparameter_dict.iteritems() -%} {% for parameter, value in slapparameter_dict.iteritems() -%}
config-{{parameter}} = {{ value }} config-{{parameter}} = {{ value }}
{% endfor -%} {% endfor -%}
config-{{ slave_list_name }} = {{ json_module.dumps(slave_instance_list) }} config-{{ slave_list_name }} = {{ json_module.dumps(slave_instance_list) }}
connection-monitor_url =
[publish-information] [publish-information]
recipe = slapos.cookbook:publish recipe = slapos.cookbook:publish
domain = {{ slapparameter_dict.get('domain') }} domain = {{ slapparameter_dict.get('domain') }}
slave-amount = {{ slave_instance_list | length }} slave-amount = {{ slave_instance_list | length }}
{% for frontend in frontend_section_list %}
{{ frontend }}-monitor-url = {{ '${' + frontend + ':connection-monitor_url}' }}
{% endfor -%}
{% for frontend in frontend_list -%} {% for frontend in frontend_list -%}
#{{frontend}}-private-ipv4 = ${request-{{frontend}}:private-ipv4} #{{frontend}}-private-ipv4 = ${request-{{frontend}}:private-ipv4}
{% endfor -%} {% endfor -%}
......
...@@ -2,120 +2,106 @@ ...@@ -2,120 +2,106 @@
extends = common.cfg extends = common.cfg
[versions] [versions]
Jinja2 = 2.6 [versions]
Werkzeug = 0.8.3 Jinja2 = 2.7.2
apache-libcloud = 0.12.3 MarkupSafe = 0.23
PyRSS2Gen = 1.1
Werkzeug = 0.9.4
apache-libcloud = 0.14.1
async = 0.6.1 async = 0.6.1
buildout-versions = 1.7 buildout-versions = 1.7
gitdb = 0.5.4
hexagonit.recipe.cmmi = 2.0
meld3 = 0.6.10
pycrypto = 2.6
rdiff-backup = 1.0.5
slapos.recipe.build = 0.11.6
slapos.recipe.cmmi = 0.1.1
slapos.recipe.template = 2.4.2
slapos.toolbox = 0.34.0
smmap = 0.8.2
z3c.recipe.scripts = 1.0.1
cliff = 1.4.4
cmd2 = 0.6.5.1
prettytable = 0.7.2
requests = 1.2.3
slapos.cookbook = 0.82
cffi = 0.8.2 cffi = 0.8.2
cmd2 = 0.6.7
cns.recipe.symlink = 0.2.3
collective.recipe.template = 1.11
cryptography = 0.4 cryptography = 0.4
gitdb = 0.5.4
hexagonit.recipe.cmmi = 2.0
inotifyx = 0.2.0-1
itsdangerous = 0.24
lxml = 3.3.5
meld3 = 1.0.0
mr.developer = 1.30
netaddr = 0.7.11
plone.recipe.command = 1.1 plone.recipe.command = 1.1
pyOpenSSL = 0.14 pyOpenSSL = 0.14
pycrypto = 2.6.1
pyparsing = 2.0.2
pytz = 2014.3
rdiff-backup = 1.0.5
six = 1.6.1 six = 1.6.1
slapos.cookbook = 0.87
slapos.recipe.build = 0.12
slapos.recipe.cmmi = 0.2
slapos.recipe.template = 2.5
slapos.toolbox = 0.39.2
smmap = 0.8.2
stevedore = 0.15
# Required by: # Required by:
# cffi==0.8.2 # slapos.core==1.0.5
pycparser = 2.10 # slapos.toolbox==0.39.2
# Required by: Flask = 0.10.1
# slapos.cookbook==0.82
lock-file = 2.0
# Required by:
# slapos.core==0.35.1
# slapos.toolbox==0.34.0
Flask = 0.9
# Required by: # Required by:
# slapos.toolbox==0.34.0 # slapos.toolbox==0.39.2
GitPython = 0.3.2.RC1 GitPython = 0.3.2.RC1
# Required by: # Required by:
# slapos.toolbox==0.34.0 # slapos.toolbox==0.39.2
atomize = 0.1.1 atomize = 0.2.0
# Required by:
# slapos.toolbox==0.34.0
feedparser = 5.1.3
# Required by:
# slapos.cookbook==0.82
inotifyx = 0.2.0
# Required by: # Required by:
# slapos.cookbook==0.82 # slapos.core==1.0.5
# slapos.core==0.35.1 cliff = 1.6.1
# xml-marshaller==0.9.7
lxml = 3.1.2
# Required by: # Required by:
# slapos.cookbook==0.82 # paramiko==1.14.0
netaddr = 0.7.10 ecdsa = 0.11
# Required by: # Required by:
# slapos.core==0.35.1 # slapos.toolbox==0.39.2
netifaces = 0.10.3 feedparser = 5.1.3
# Required by: # Required by:
# slapos.toolbox==0.34.0 # slapos.cookbook==0.87
paramiko = 1.10.1 lock-file = 2.0
# Required by: # Required by:
# slapos.toolbox==0.34.0 # slapos.core==1.0.5
psutil = 0.7.0 netifaces = 0.10.4
# Required by: # Required by:
# slapos.core==0.35.1 # slapos.toolbox==0.39.2
pyflakes = 0.7 paramiko = 1.14.0
# Required by: # Required by:
# slapos.cookbook==0.82 # slapos.toolbox==0.39.2
pytz = 2013b psutil = 2.1.1
# Required by: # Required by:
# slapos.cookbook==0.82 # cffi==0.8.2
# slapos.core==0.35.1 pycparser = 2.10
# slapos.toolbox==0.34.0
# zc.buildout==1.6.0-dev-SlapOS-010
# zc.recipe.egg==1.3.2
setuptools = 0.6c12dev-r88846
# Required by: # Required by:
# slapos.cookbook==0.82 # slapos.core==1.0.5
# slapos.toolbox==0.34.0 requests = 2.3.0
slapos.core = 0.35.1
# Required by: # Required by:
# slapos.core==0.35.1 # slapos.toolbox==0.39.2
supervisor = 3.0b1 slapos.core = 1.0.5
# Required by: # Required by:
# slapos.core==0.35.1 # slapos.core==1.0.5
unittest2 = 0.5.1 supervisor = 3.0
# Required by: # Required by:
# slapos.cookbook==0.82 # slapos.toolbox==0.39.2
# slapos.toolbox==0.34.0
xml-marshaller = 0.9.7 xml-marshaller = 0.9.7
# Required by: # Required by:
# slapos.core==0.35.1 # slapos.core==1.0.5
zope.interface = 4.0.5 zope.interface = 4.1.1
[networkcache] [networkcache]
# signature certificates of the following uploaders. # signature certificates of the following uploaders.
......
...@@ -2,9 +2,7 @@ ...@@ -2,9 +2,7 @@
ServerName www.example.org ServerName www.example.org
SSLEngine on SSLEngine on
SSLProxyEngine on SSLProxyEngine on
SSLProtocol -ALL +SSLv3 +TLSv1 SSLProtocol ALL -SSLv2
SSLHonorCipherOrder On
SSLCipherSuite RC4-SHA:HIGH:!ADH
# Rewrite part # Rewrite part
ProxyVia On ProxyVia On
......
...@@ -53,7 +53,7 @@ log = {{slave_parameter_dict.get('access_log')}} {{slave_parameter_dict.get('err ...@@ -53,7 +53,7 @@ log = {{slave_parameter_dict.get('access_log')}} {{slave_parameter_dict.get('err
backup = {{ '${' + slave_directory_section + ':log-folder}' }} backup = {{ '${' + slave_directory_section + ':log-folder}' }}
frequency = daily frequency = daily
rotatep-num = 30 rotatep-num = 30
post = ${buildout:bin-directory}/killpidfromfile {{ apache_configuration.get('pid-file') }} SIGUSR1 post = {{ apache_configuration.get('frontend-graceful-command') }}
sharedscripts = true sharedscripts = true
notifempty = true notifempty = true
create = true create = true
...@@ -172,6 +172,10 @@ private-ipv4 = {{ local_ipv4 }} ...@@ -172,6 +172,10 @@ private-ipv4 = {{ local_ipv4 }}
{% if extra_slave_instance_list -%} {% if extra_slave_instance_list -%}
slave-instance-information-list = {{ json_module.dumps(slave_instance_information_list) }} slave-instance-information-list = {{ json_module.dumps(slave_instance_information_list) }}
{% endif -%} {% endif -%}
{% do connection_information_dict.pop('recipe') %}
{% for key, value in connection_information_dict.iteritems() -%}
{{ key }} = {{ value }}
{% endfor %}
{% do part_list.append('cached-rewrite-rules') -%} {% do part_list.append('cached-rewrite-rules') -%}
[cached-rewrite-rules] [cached-rewrite-rules]
......
...@@ -120,9 +120,7 @@ SSLSessionCache shmcb:/{{ httpd_mod_ssl_cache_directory }}/ssl_scache(512000) ...@@ -120,9 +120,7 @@ SSLSessionCache shmcb:/{{ httpd_mod_ssl_cache_directory }}/ssl_scache(512000)
SSLSessionCacheTimeout 300 SSLSessionCacheTimeout 300
SSLRandomSeed startup /dev/urandom 256 SSLRandomSeed startup /dev/urandom 256
SSLRandomSeed connect builtin SSLRandomSeed connect builtin
SSLProtocol -ALL +SSLv3 +TLSv1 SSLProtocol ALL -SSLv2
SSLHonorCipherOrder On
SSLCipherSuite RC4-SHA:HIGH:!ADH
<FilesMatch "\.(cgi|shtml|phtml|php)$"> <FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars SSLOptions +StdEnvVars
</FilesMatch> </FilesMatch>
......
...@@ -23,6 +23,8 @@ header_replace X-Forwarded-For ...@@ -23,6 +23,8 @@ header_replace X-Forwarded-For
follow_x_forwarded_for allow all follow_x_forwarded_for allow all
forwarded_for on forwarded_for on
cache_dir aufs {{ cache_path }} 5000 16 256
# Use 1Go of RAM # Use 1Go of RAM
cache_mem 1024 MB cache_mem 1024 MB
# But do not keep big object in RAM # But do not keep big object in RAM
......
#!${dash-output:dash}
{{ content }}
\ No newline at end of file
...@@ -6,28 +6,22 @@ extends = ...@@ -6,28 +6,22 @@ extends =
../../component/dash/buildout.cfg ../../component/dash/buildout.cfg
../../component/dcron/buildout.cfg ../../component/dcron/buildout.cfg
../../component/openssl/buildout.cfg ../../component/openssl/buildout.cfg
../../component/nginx/buildout.cfg
parts += parts =
backup-script-template slapos-cookbook
collective.recipe.template-egg
dcron dcron
download-static-files download-static-files
eggs monitor-eggs
extra-eggs extra-eggs
make-rss
monitor-bin monitor-bin
monitor-template monitor-template
nginx
rss-bin rss-bin
slapos-cookbook
static-folder
template-nginx-conf
[collective.recipe.template-egg] [monitor-eggs]
recipe = zc.recipe.egg recipe = zc.recipe.egg
eggs = collective.recipe.template eggs =
PyRSS2Gen collective.recipe.template
cns.recipe.symlink
[extra-eggs] [extra-eggs]
recipe = zc.recipe.egg recipe = zc.recipe.egg
...@@ -39,8 +33,8 @@ eggs = ...@@ -39,8 +33,8 @@ eggs =
[make-rss-script] [make-rss-script]
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${:_profile_base_location_}/make-rss.sh.in url = ${:_profile_base_location_}/make-rss.sh.in
md5sum = 8d3a4b212784b591316b8b93d6bd163e md5sum = 98c8f6fd81e405b0ad10db07c3776321
output = ${buildout:directory}/make-rss.sh.in output = ${buildout:directory}/template-make-rss.sh.in
mode = 0644 mode = 0644
[monitor-template] [monitor-template]
...@@ -48,14 +42,15 @@ recipe = slapos.recipe.template ...@@ -48,14 +42,15 @@ recipe = slapos.recipe.template
url = ${:_profile_base_location_}/monitor.cfg.in url = ${:_profile_base_location_}/monitor.cfg.in
output = ${buildout:directory}/monitor.cfg output = ${buildout:directory}/monitor.cfg
filename = monitor.cfg filename = monitor.cfg
md5sum = 4db2be5e8cabb5dd1d23743e0db5b02a md5sum = bd592a0f0c41ec15c643c4e91e9ec5cc
mode = 0644 mode = 0644
[monitor-bin] [monitor-bin]
recipe = hexagonit.recipe.download recipe = hexagonit.recipe.download
url = ${:_profile_base_location_}/${:filename} url = ${:_profile_base_location_}/${:filename}
download-only = true download-only = true
md5sum = 05bbb70f6f69dc4f3fa83dc0f8c9960e md5sum = 1e7b4698f6627150b1eb783b06f8b13a
destination = ${buildout:directory}/parts/monitor-template-monitor-bin
filename = monitor.py.in filename = monitor.py.in
mode = 0644 mode = 0644
...@@ -64,6 +59,7 @@ recipe = hexagonit.recipe.download ...@@ -64,6 +59,7 @@ recipe = hexagonit.recipe.download
url = ${:_profile_base_location_}/webfiles/${:filename} url = ${:_profile_base_location_}/webfiles/${:filename}
download-only = true download-only = true
md5sum = 91ac749f86aecc0c383d93e51e15a572 md5sum = 91ac749f86aecc0c383d93e51e15a572
destination = ${buildout:directory}/parts/monitor-index
filename = index.cgi.in filename = index.cgi.in
mode = 0644 mode = 0644
...@@ -71,7 +67,8 @@ mode = 0644 ...@@ -71,7 +67,8 @@ mode = 0644
recipe = hexagonit.recipe.download recipe = hexagonit.recipe.download
url = ${:_profile_base_location_}/webfiles/${:filename} url = ${:_profile_base_location_}/webfiles/${:filename}
download-only = true download-only = true
md5sum = aa375a4225e2587b22f68c28cafd7871 destination = ${buildout:directory}/parts/monitor-template-index
md5sum = e0d2aaeffc046b2ac6d9d717e1ba321d
filename = index.html.jinja2 filename = index.html.jinja2
mode = 0644 mode = 0644
...@@ -79,7 +76,8 @@ mode = 0644 ...@@ -79,7 +76,8 @@ mode = 0644
recipe = hexagonit.recipe.download recipe = hexagonit.recipe.download
url = ${:_profile_base_location_}/webfiles/${:filename} url = ${:_profile_base_location_}/webfiles/${:filename}
download-only = true download-only = true
md5sum = 4e5b7fc5c5c237836c7c81fe3e3bb903 md5sum = aa2764cab87e457410435974f729e906
destination = ${buildout:directory}/parts/monitor-template-status-cgi
filename = status.cgi.in filename = status.cgi.in
mode = 0644 mode = 0644
...@@ -88,6 +86,7 @@ recipe = hexagonit.recipe.download ...@@ -88,6 +86,7 @@ recipe = hexagonit.recipe.download
url = ${:_profile_base_location_}/webfiles/${:filename} url = ${:_profile_base_location_}/webfiles/${:filename}
download-only = true download-only = true
md5sum = 18574b804da0c65d8670959f9e7c4774 md5sum = 18574b804da0c65d8670959f9e7c4774
destination = ${buildout:directory}/parts/monitor-template-settings-cgi
filename = settings.cgi.in filename = settings.cgi.in
mode = 0644 mode = 0644
...@@ -95,7 +94,8 @@ mode = 0644 ...@@ -95,7 +94,8 @@ mode = 0644
recipe = hexagonit.recipe.download recipe = hexagonit.recipe.download
url = ${:_profile_base_location_}/${:filename} url = ${:_profile_base_location_}/${:filename}
download-only = true download-only = true
md5sum = 427d5135ca475f2a4c4e69a0da6ed8c4 md5sum = 5f1b93ccdea7c3031aef396154c64938
destination = ${buildout:directory}/parts/monitor-template-rss-bin
filename = status2rss.py filename = status2rss.py
mode = 0644 mode = 0644
...@@ -108,18 +108,9 @@ logfile = $${directory:log}/crond.log ...@@ -108,18 +108,9 @@ logfile = $${directory:log}/crond.log
[download-static-files] [download-static-files]
recipe = hexagonit.recipe.download recipe = hexagonit.recipe.download
url = https://github.com/Sebatyne/staticForMonitoring/blob/3f0e93cec706c7ad311ddbf1ebf996965ce2f0a3/static-files.tar.gz?raw=true url = https://github.com/SlapOS/staticForMonitoring/blob/db670e7568871c69a64916d462ccb57629f1c77d/static-files.tar.gz?raw=true
download-only = true download-only = true
md5sum = e98585b85634de48240b2c215e946769 md5sum = 9e3feb2b520620d5b8d478eb9a9be6de
filename = static-files.tar.gz filename = static-files.tar.gz
destination = ${buildout:directory}/parts/monitor-static-files
mode = 0644 mode = 0644
[eggs]
recipe = z3c.recipe.scripts
eggs =
slapos.cookbook
PyRSS2Gen
[versions]
PyRSS2Gen = 1.1
Jinja2 = 2.6
#!${dash-output:dash} #!${dash-output:dash}
STATUS=$${monitor-parameters:result-dir} STATUS_DB={{ monitor_parameters['db-path'] }}
RSS_FILE=$${monitor-parameters:rss-path} RSS_FILE={{ monitor_parameters['rss-path'] }}
PYTHON=${buildout:directory}/bin/${extra-eggs:interpreter} PYTHON=${buildout:directory}/bin/${extra-eggs:interpreter}
STATUS2RSS=${rss-bin:location}/${rss-bin:filename} STATUS2RSS=${rss-bin:location}/${rss-bin:filename}
NAME=`basename $STATUS` $PYTHON $STATUS2RSS "Monitoring RSS feed" "{{ monitor_parameters['url'] }}/{{ monitor_parameters['index-filename'] }}" $STATUS_DB > $RSS_FILE
cat $STATUS/* | $PYTHON $STATUS2RSS "Monitoring RSS feed" "https://[$${slap-parameters:ipv6-random}]:$${monitor-parameters:port}/$${deploy-index:filename}" > $RSS_FILE
This diff is collapsed.
...@@ -5,16 +5,21 @@ import json ...@@ -5,16 +5,21 @@ import json
import os import os
import subprocess import subprocess
import sys import sys
import sqlite3
import time import time
from optparse import OptionParser, make_option from optparse import OptionParser, make_option
FAILURE = "FAILURE"
SUCCESS = "SUCCESS"
db_path = "{{ monitor_parameter['db-path'] }}"
instance_path = "{{ directory['home'] }}" instance_path = "{{ directory['home'] }}"
monitor_dir = "{{ directory['monitor'] }}" monitor_dir = "{{ directory['monitor-custom-scripts'] }}"
pid_dir = "{{ directory['run'] }}" pid_dir = "{{ directory['run'] }}"
promise_dir = "{{ directory['promise'] }}" promise_dir = "{{ directory['promise'] }}"
monitoring_file_json = "{{ monitoring_file_json }}" monitoring_file_json = "{{ monitoring_file_json }}"
monitoring_folder_bool = "{{ monitoring_folder_bool }}"
option_list = [ option_list = [
make_option("-a", "--all", action="store_true", dest="all", make_option("-a", "--all", action="store_true", dest="all",
...@@ -30,16 +35,38 @@ option_list = [ ...@@ -30,16 +35,38 @@ option_list = [
] ]
def init_db():
db = sqlite3.connect(db_path)
c = db.cursor()
c.executescript("""
CREATE TABLE IF NOT EXISTS status (
timestamp INTEGER UNIQUE,
status VARCHAR(255));
CREATE TABLE IF NOT EXISTS individual_status (
timestamp INTEGER,
status VARCHAR(255),
element VARCHAR(255),
output TEXT);
""")
db.commit()
db.close()
def getListOfScripts(directory): def getListOfScripts(directory):
"""
Get the list of script inside of a directory (not recursive)
"""
scripts = [] scripts = []
if os.path.exists(directory) and os.path.isdir(directory): if os.path.exists(directory) and os.path.isdir(directory):
for file in os.listdir(directory): for file_name in os.listdir(directory):
scripts.append(os.path.join(directory, file)) file = os.path.join(directory, file_name)
if os.access(file, os.X_OK) and not os.path.isdir(file):
scripts.append(file)
else: else:
exit("There is a problem in your directories" \ exit("There is a problem in your directories" \
"of monitoring. Please check them") "of monitoring. Please check them")
return scripts return scripts
def runServices(directory): def runServices(directory):
services = getListOfScripts(directory) services = getListOfScripts(directory)
result = {} result = {}
...@@ -49,7 +76,8 @@ def runServices(directory): ...@@ -49,7 +76,8 @@ def runServices(directory):
try: try:
pid = int(open(service_path).read()) pid = int(open(service_path).read())
### because apache (or others) can write sockets ### because apache (or others) can write sockets
except IOError: ### We also ignore not readable pid files
except (IOError, ValueError):
continue continue
try: try:
os.kill(pid, 0) os.kill(pid, 0)
...@@ -91,22 +119,28 @@ def runScripts(directory): ...@@ -91,22 +119,28 @@ def runScripts(directory):
def writeFiles(monitors): def writeFiles(monitors):
timestamp = int(time.time())
date = datetime.datetime.now().ctime()
init_db()
db = sqlite3.connect(db_path)
fail = False fail = False
for i in monitors.values(): for key, value in monitors.iteritems():
if i != "" : element_status = SUCCESS
if value != "" :
fail = True fail = True
element_status = FAILURE
db.execute("insert into individual_status(timestamp, element, output, status) values (?, ?, ?, ?)", (timestamp, key, value, element_status))
db.commit()
status = SUCCESS
if fail: if fail:
message = "FAILURE : something went wrong\n" status = FAILURE
else: db.execute("insert into status(timestamp, status) values (?, ?)", (timestamp, status))
message = "SUCCESS : everything is ok\n" db.commit()
date = datetime.datetime.now().ctime() db.close()
monitors['datetime'] = date monitors['datetime'] = date
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)) open(monitoring_file_json, "w+").write(json.dumps(monitors))
def main():
if __name__ == "__main__":
parser = OptionParser(option_list=option_list) parser = OptionParser(option_list=option_list)
monitors = {} monitors = {}
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
...@@ -131,3 +165,6 @@ if __name__ == "__main__": ...@@ -131,3 +165,6 @@ if __name__ == "__main__":
else: else:
exit(1) exit(1)
if __name__ == "__main__":
main()
import datetime import datetime
import PyRSS2Gen import PyRSS2Gen
import sys import sys
from email.utils import parsedate_tz, mktime_tz import sqlite3
import time
import base64 import base64
# Based on http://thehelpfulhacker.net/2011/03/27/a-rss-feed-for-your-crontabs/ # Based on http://thehelpfulhacker.net/2011/03/27/a-rss-feed-for-your-crontabs/
...@@ -9,27 +10,36 @@ import base64 ...@@ -9,27 +10,36 @@ import base64
# ### Defaults # ### Defaults
TITLE = sys.argv[1] TITLE = sys.argv[1]
LINK = sys.argv[2] LINK = sys.argv[2]
db_path = sys.argv[3]
DESCRIPTION = TITLE DESCRIPTION = TITLE
SUCCESS = "SUCCESS"
FAILURE = "FAILURE"
items = [] items = []
status = ""
while 1: current_timestamp = int(time.time())
try: # We only build the RSS for the last ten days
line = sys.stdin.readline() period = 3600 * 24 * 10
except KeyboardInterrupt: db = sqlite3.connect(db_path)
break rows = db.execute("select timestamp, status from status where timestamp>? order by timestamp", (current_timestamp - period,))
for row in rows:
line_timestamp, line_status = row
line_status = line_status.encode()
if not line: if line_status == status:
break continue
time, desc = line.split(',', 1) status = line_status
event_time = datetime.datetime.fromtimestamp(line_timestamp).strftime('%Y-%m-%d %H:%M:%S')
rss_item = PyRSS2Gen.RSSItem( rss_item = PyRSS2Gen.RSSItem(
title = desc, title = status,
description = "%s, %s" % (time, desc), description = "%s: %s" % (event_time, status),
link = LINK, link = LINK,
pubDate = datetime.datetime.fromtimestamp(mktime_tz(parsedate_tz(time))), pubDate = event_time,
guid = PyRSS2Gen.Guid(base64.b64encode("%s, %s" % (time, desc))) guid = PyRSS2Gen.Guid(base64.b64encode("%s, %s" % (event_time, status)))
) )
items.append(rss_item) items.append(rss_item)
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
<li><a href="{{ category }}/{{ script }}" class="script">{{ script }}</a></li> <li><a href="{{ category }}/{{ script }}" class="script">{{ script }}</a></li>
{% endfor %} {% endfor %}
{% endfor %} {% endfor %}
<li class="pure-menu-heading category">Files</li>
<li><a href="./private/" class="link"> User: admin</br> Password is yours</a></li>
</ul> </ul>
</div> </div>
</div> </div>
......
#!{{ python_executable }} #!{{ python_executable }}
import cgi
import cgitb import cgitb
import json import json
import subprocess
def refresh():
command = ["{{ monitor_bin }}", "-a"]
subprocess.call(command)
cgitb.enable(display=0, logdir="/tmp/cgi.log") cgitb.enable(display=0, logdir="/tmp/cgi.log")
form = cgi.FieldStorage()
if "refresh" in form:
refresh()
json_file = "{{ json_file }}" json_file = "{{ json_file }}"
result = json.load(open(json_file)) result = json.load(open(json_file))
...@@ -13,8 +22,12 @@ print "<link rel=\"stylesheet\" href=\"pure-min.css\">" ...@@ -13,8 +22,12 @@ print "<link rel=\"stylesheet\" href=\"pure-min.css\">"
print "<link rel=\"stylesheet\" href=\"/style.css\">" print "<link rel=\"stylesheet\" href=\"/style.css\">"
print "</head><body>" print "</head><body>"
print "<h1>Monitoring :</h1>" print "<h1>Monitoring :</h1>"
print "<form action=\"/index.cgi\" method=\"post\" class=\"pure-form-aligned\">"
print "<input type=\"hidden\" name=\"posting-script\" value=\"{{ pwd }}/{{ this_file }}\">"
print "<p><em>Last time of monitoring process : %s</em></p>" % (result['datetime']) print "<p><em>Last time of monitoring process : %s</em></p>" % (result['datetime'])
del result['datetime'] del result['datetime']
print "<div class=\"pure-controls\"><button type=\"submit\" class=\"pure-button \
pure-button-primary\" name=\"refresh\" value=\"refresh\">Refresh</button></div></form>"
print "<br/>" print "<br/>"
print "<h2>These scripts and promises have failed :</h2>" print "<h2>These scripts and promises have failed :</h2>"
......
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