version up eggs.
[slapos.git] / stack / monitor / monitor.cfg.in
1 [slap-parameters]
2 recipe = slapos.cookbook:slapconfiguration
3 computer = $${slap-connection:computer-id}
4 partition = $${slap-connection:partition-id}
5 url = $${slap-connection:server-url}
6 key = $${slap-connection:key-file}
7 cert = $${slap-connection:cert-file}
8
9 [monitor-parameters]
10 json-filename = monitor.json
11 json-path = $${monitor-directory:monitor-result}/$${:json-filename}
12 rss-filename = rssfeed.html
13 rss-path = $${monitor-directory:public-cgi}/$${:rss-filename}
14 executable = $${monitor-directory:bin}/monitor.py
15 port = 9685
16 htaccess-file = $${monitor-directory:etc}/.htaccess-monitor
17 url = https://[$${slap-parameters:ipv6-random}]:$${:port}
18 index-filename = index.cgi
19 index-path = $${monitor-directory:www}/$${:index-filename}
20 db-path = $${monitor-directory:etc}/monitor.db
21 monitor-password-path = $${monitor-directory:etc}/.monitor.shadow
22
23 [monitor-directory]
24 recipe = slapos.cookbook:mkdirectory
25 # Standard directory needed by monitoring stack
26 home = $${buildout:directory}
27 etc = $${:home}/etc
28 bin = $${:home}/bin
29 srv = $${:home}/srv
30 var = $${:home}/var
31 log = $${:var}/log
32 run = $${:var}/run
33 service = $${:etc}/service/
34 etc-run = $${:etc}/run/
35 tmp = $${:home}/tmp
36 promise = $${:etc}/promise
37
38 cron-entries = $${:etc}/cron.d
39 crontabs = $${:etc}/crontabs
40 cronstamps = $${:etc}/cronstamps
41
42 ca-dir = $${:srv}/ssl
43 www = $${:var}/www
44
45 cgi-bin = $${:var}/cgi-bin
46 monitoring-cgi = $${:cgi-bin}/monitoring
47 knowledge0-cgi = $${:cgi-bin}/zero-knowledge
48 public-cgi = $${:cgi-bin}/monitor-public
49
50 monitor-custom-scripts = $${:etc}/monitor
51 monitor-result = $${:var}/monitor
52
53 private-directory = $${:srv}/monitor-private
54
55 [public-symlink]
56 recipe = cns.recipe.symlink
57 symlink = $${monitor-directory:public-cgi} = $${monitor-directory:www}/monitor-public
58 autocreate = true
59
60 [cron]
61 recipe = slapos.cookbook:cron
62 dcrond-binary = ${dcron:location}/sbin/crond
63 cron-entries = $${monitor-directory:cron-entries}
64 crontabs = $${monitor-directory:crontabs}
65 cronstamps = $${monitor-directory:cronstamps}
66 catcher = $${cron-simplelogger:wrapper}
67 binary = $${monitor-directory:service}/crond
68
69 # Add log to cron
70 [cron-simplelogger]
71 recipe = slapos.cookbook:simplelogger
72 wrapper = $${monitor-directory:bin}/cron_simplelogger
73 log = $${monitor-directory:log}/cron.log
74
75 [cron-entry-monitor]
76 <= cron
77 recipe = slapos.cookbook:cron.d
78 name = launch-monitor
79 frequency = */5 * * * *
80 command = $${deploy-monitor-script:rendered} -a
81
82 [cron-entry-rss]
83 <= cron
84 recipe = slapos.cookbook:cron.d
85 name = build-rss
86 frequency = */5 * * * *
87 command = $${make-rss:rendered}
88
89 [setup-static-files]
90 recipe = plone.recipe.command
91 command = ln -s ${download-monitor-jquery:destination} $${monitor-directory:www}/static
92 update-command = $${:command}
93
94 [deploy-index]
95 recipe = slapos.recipe.template:jinja2
96 template = ${index:location}/${index:filename}
97 rendered = $${monitor-parameters:index-path}
98 update-apache-access = ${apache:location}/bin/htpasswd -cb $${monitor-parameters:htaccess-file} admin
99 mode = 0744
100 context =
101   key cgi_directory monitor-directory:cgi-bin
102   raw index_template $${deploy-index-template:location}/$${deploy-index-template:filename}
103   key monitor_password_path monitor-parameters:monitor-password-path
104   key monitor_password_script_path deploy-monitor-password-cgi:rendered
105   key apache_update_command :update-apache-access
106   raw extra_eggs_interpreter ${buildout:directory}/bin/${extra-eggs:interpreter}
107   raw default_page /static/welcome.html
108   section rewrite_element monitor-rewrite-rule
109
110 [deploy-index-template]
111 recipe = hexagonit.recipe.download
112 url = ${index-template:location}/$${:filename}
113 destination = $${monitor-directory:www}
114 filename = ${index-template:filename}
115 download-only = true
116 mode = 0644
117
118 [deploy-status-cgi]
119 recipe = slapos.recipe.template:jinja2
120 template = ${status-cgi:location}/${status-cgi:filename}
121 rendered = $${monitor-directory:monitoring-cgi}/$${:filename}
122 filename = status.cgi
123 mode = 0744
124 context =
125   key json_file monitor-parameters:json-path
126   key monitor_bin monitor-parameters:executable
127   key pwd monitor-directory:monitoring-cgi
128   key this_file :filename
129   raw python_executable ${buildout:executable}
130
131 [deploy-status-history-cgi]
132 recipe = slapos.recipe.template:jinja2
133 template = ${status-history-cgi:location}/${status-history-cgi:filename}
134 rendered = $${monitor-directory:monitoring-cgi}/$${:filename}
135 filename = status-history.cgi
136 mode = 0744
137 context =
138   key monitor_db_path monitor-parameters:db-path
139   key status_history_length zero-parameters:status-history-length
140   raw python_executable ${buildout:executable}
141
142 [deploy-settings-cgi]
143 recipe = slapos.recipe.template:jinja2
144 template = ${settings-cgi:location}/${settings-cgi:filename}
145 rendered = $${monitor-directory:knowledge0-cgi}/$${:filename}
146 filename = settings.cgi
147 mode = 0744
148 context =
149   raw config_cfg $${buildout:directory}/knowledge0.cfg
150   raw timestamp $${buildout:directory}/.timestamp
151   raw python_executable ${buildout:executable}
152   key pwd monitor-directory:knowledge0-cgi
153   key this_file :filename
154
155 [deploy-monitor-password-cgi]
156 recipe = slapos.recipe.template:jinja2
157 template = ${monitor-password-cgi:location}/${monitor-password-cgi:filename}
158 rendered = $${monitor-directory:knowledge0-cgi}/$${:filename}
159 filename = monitor-password.cgi
160 mode = 0744
161 context =
162   raw python_executable ${buildout:executable}
163   key pwd monitor-directory:knowledge0-cgi
164   key this_file :filename
165
166 [deploy-monitor-script]
167 recipe = slapos.recipe.template:jinja2
168 template = ${monitor-bin:location}/${monitor-bin:filename}
169 rendered = $${monitor-parameters:executable}
170 mode = 0744
171 context =
172   section directory monitor-directory
173   section monitor_parameter monitor-parameters
174   key monitoring_file_json monitor-parameters:json-path
175   raw python_executable ${buildout:executable}
176
177 [make-rss]
178 recipe = slapos.recipe.template:jinja2
179 template = ${make-rss-script:output}
180 rendered = $${monitor-directory:bin}/make-rss.sh
181 mode = 0744
182 context =
183   section directory monitor-directory
184   section monitor_parameters monitor-parameters
185
186 [monitor-directory-access]
187 recipe = plone.recipe.command
188 command = ln -s $${:source} $${monitor-directory:private-directory}
189 source =
190
191 [monitor-instance-log-access]
192 recipe = plone.recipe.command
193 command = if [ -d $${:source} ]; then ln -s $${:source} $${monitor-directory:private-directory}/instance-logs; fi
194 update-command = if [ -d $${:source} ]; then ln -s $${:source} $${monitor-directory:private-directory}/instance-logs; fi
195 source = $${monitor-directory:home}/.slapgrid/log/
196 location = $${:source}
197
198 [cadirectory]
199 recipe = slapos.cookbook:mkdirectory
200 requests = $${monitor-directory:ca-dir}/requests/
201 private = $${monitor-directory:ca-dir}/private/
202 certs = $${monitor-directory:ca-dir}/certs/
203 newcerts = $${monitor-directory:ca-dir}/newcerts/
204 crl = $${monitor-directory:ca-dir}/crl/
205
206 [certificate-authority]
207 recipe = slapos.cookbook:certificate_authority
208 openssl-binary = ${openssl:location}/bin/openssl
209 ca-dir = $${monitor-directory:ca-dir}
210 requests-directory = $${cadirectory:requests}
211 wrapper = $${monitor-directory:service}/certificate_authority
212 ca-private = $${cadirectory:private}
213 ca-certs = $${cadirectory:certs}
214 ca-newcerts = $${cadirectory:newcerts}
215 ca-crl = $${cadirectory:crl}
216
217 [ca-httpd]
218 <= certificate-authority
219 recipe = slapos.cookbook:certificate_authority.request
220 key-file = $${cadirectory:certs}/httpd.key
221 cert-file = $${cadirectory:certs}/httpd.crt
222 executable = $${monitor-directory:bin}/cgi-httpd
223 wrapper = $${monitor-directory:service}/cgi-httpd
224 # Put domain name
225 name = example.com
226
227 ###########
228 # Deploy a webserver running cgi scripts for monitoring
229 ###########
230 [public]
231 recipe = slapos.cookbook:zero-knowledge.write
232 filename = knowledge0.cfg
233 status-history-length = 5
234
235 [zero-parameters]
236 recipe = slapos.cookbook:zero-knowledge.read
237 filename = $${public:filename}
238
239 [monitor-rewrite-rule]
240
241 # XXX could it be something lighter?
242 [monitor-httpd-configuration]
243 pid-file = $${monitor-directory:run}/cgi-httpd.pid
244 cgid-pid-file = $${monitor-directory:run}/cgi-httpd-cgid.pid
245 error-log = $${monitor-directory:log}/cgi-httpd-error-log
246 listening-ip = $${slap-parameters:ipv6-random}
247 certificate = $${ca-httpd:cert-file}
248 key = $${ca-httpd:key-file}
249
250 [monitor-httpd-configuration-file]
251 recipe = slapos.recipe.template:jinja2
252 template = ${monitor-httpd-template:destination}/${monitor-httpd-template:filename}
253 rendered = $${monitor-directory:etc}/cgi-httpd.conf
254 mode = 0744
255 context =
256   section directory monitor-directory
257   section monitor_parameters monitor-parameters
258   section httpd_configuration monitor-httpd-configuration
259   section monitor_rewrite_rule monitor-rewrite-rule
260
261 [cgi-httpd-wrapper]
262 recipe = slapos.cookbook:wrapper
263 apache-executable = ${apache:location}/bin/httpd
264 command-line = $${:apache-executable} -f $${monitor-httpd-configuration-file:rendered} -DFOREGROUND
265 wrapper-path = $${ca-httpd:executable}
266
267 [cgi-httpd-graceful-wrapper]
268 recipe = slapos.recipe.template:jinja2
269 template = ${template-wrapper:output}
270 rendered = $${monitor-directory:etc-run}/cgi-httpd-graceful
271 mode = 0700
272 context =
273     key content :command
274 command = kill -USR1 $(cat $${monitor-httpd-configuration:pid-file})
275
276
277 [monitor-promise]
278 recipe = slapos.cookbook:check_url_available
279 path = $${monitor-directory:promise}/monitor
280 url = $${monitor-parameters:url}/$${monitor-parameters:index-filename}
281 check-secure = 1
282 dash_path = ${dash:location}/bin/dash
283 curl_path = ${curl:location}/bin/curl
284
285 [publish-connection-informations]
286 recipe = slapos.cookbook:publish
287 monitor_url = $${monitor-parameters:url}