Commit c8b4b08f authored by Łukasz Nowak's avatar Łukasz Nowak

monitor: Switch to json-in-xml and update types

Note: This is request backward incompatible change.
parent cfe9f936
...@@ -30,7 +30,7 @@ md5sum = a57106ee88ff3295b9ffce84105da79b ...@@ -30,7 +30,7 @@ md5sum = a57106ee88ff3295b9ffce84105da79b
[template-monitor-edgebot] [template-monitor-edgebot]
_update_hash_filename_ = instance-monitor-edgebot.cfg.jinja2 _update_hash_filename_ = instance-monitor-edgebot.cfg.jinja2
md5sum = c1885a42aadd45bab3185a53258d4ff4 md5sum = 621cc3d7a71676a89d92f37e6c2c45ab
[network-bench-cfg] [network-bench-cfg]
filename = network_bench.cfg.in filename = network_bench.cfg.in
...@@ -42,4 +42,4 @@ md5sum = d3cfa1f6760e3fa64ccd64acf213bdfb ...@@ -42,4 +42,4 @@ md5sum = d3cfa1f6760e3fa64ccd64acf213bdfb
[template-surykatka-ini] [template-surykatka-ini]
_update_hash_filename_ = surykatka.ini.jinja2 _update_hash_filename_ = surykatka.ini.jinja2
md5sum = 89545501f0e5bf11608978886429da3d md5sum = 1cd568bb04c51de871277a86635c704a
{ {
"$schema": "http://json-schema.org/draft-04/schema#", "$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": { "properties": {
"nameserver": { "nameserver": {
"default": "", "default": [],
"title": "Nameserver", "title": "Nameserver",
"description": "Space separated list of name servers to use.", "description": "List of name servers to use.",
"type": "string" "type": "array"
}, },
"check-status-code": { "check-status-code": {
"default": "200", "default": 200,
"title": "Default Check HTTP Code", "title": "Default Check HTTP Code",
"description": "Default HTTP code to check against (default: 200).", "description": "Default HTTP code to check against (default: 200).",
"type": "string" "type": "number"
}, },
"check-http-header-dict": { "check-http-header-dict": {
"default": "{}", "default": "{}",
...@@ -20,28 +21,28 @@ ...@@ -20,28 +21,28 @@
"type": "object" "type": "object"
}, },
"check-frontend-ip": { "check-frontend-ip": {
"default": "", "default": [],
"title": "Default space separated list of Frontend IPs to check", "title": "Default list of Frontend IPs to check",
"description": "Default list of Frontend IPs to check, if empty no constraint is used.", "description": "Default list of Frontend IPs to check, if empty no constraint is used.",
"type": "string" "type": "array"
}, },
"check-certificate-expiration-days": { "check-certificate-expiration-days": {
"default": "15", "default": 15,
"title": "Default certificate expiration days check", "title": "Default certificate expiration days check",
"description": "Default amount of days to consider certificate as being to-be-expired (default: 15).", "description": "Default amount of days to consider certificate as being to-be-expired (default: 15).",
"type": "string" "type": "number"
}, },
"check-maximum-elapsed-time": { "check-maximum-elapsed-time": {
"default": "2", "default": 2,
"title": "Default maximum elapsed time for a site to reply (seconds)", "title": "Default maximum elapsed time for a site to reply (seconds)",
"description": "Default maximum elapsed time for a site to reply to be considered good (default: 2s).", "description": "Default maximum elapsed time for a site to reply to be considered good (default: 2s).",
"type": "string" "type": "number"
}, },
"failure-amount": { "failure-amount": {
"default": "1", "default": 1,
"title": "Default amount of failures to consider URL as in bad state", "title": "Default amount of failures to consider URL as in bad state",
"description": "Default amount of failures to consider URL as in bad state, can be set to higher value for endpoints with accepted short outages (default: 1).", "description": "Default amount of failures to consider URL as in bad state, can be set to higher value for endpoints with accepted short outages (default: 1).",
"type": "string" "type": "number"
} }
} }
} }
{ {
"$schema": "http://json-schema.org/draft-04/schema#", "$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": { "properties": {
"url": { "url": {
"title": "URL to check", "title": "URL to check",
...@@ -10,7 +11,7 @@ ...@@ -10,7 +11,7 @@
"default": "Master default", "default": "Master default",
"title": "Default Check HTTP Code.", "title": "Default Check HTTP Code.",
"description": "HTTP code to check against (default: comes from master partition).", "description": "HTTP code to check against (default: comes from master partition).",
"type": "string" "type": "number"
}, },
"check-http-header-dict": { "check-http-header-dict": {
"default": "Master default", "default": "Master default",
...@@ -20,27 +21,27 @@ ...@@ -20,27 +21,27 @@
}, },
"check-frontend-ip": { "check-frontend-ip": {
"default": "Master default", "default": "Master default",
"title": "Space separated list of Frontend IPs to check", "title": "List of Frontend IPs to check",
"description": "List of Frontend IPs to check, if empty no constraint is used (default: comes from master partition).", "description": "List of Frontend IPs to check, if empty no constraint is used (default: comes from master partition).",
"type": "string" "type": "array"
}, },
"check-certificate-expiration-days": { "check-certificate-expiration-days": {
"default": "Master default", "default": "Master default",
"title": "Certificate expiration days check", "title": "Certificate expiration days check",
"description": "Amount of days to consider certificate as being to-be-expired (default: comes from master partition).", "description": "Amount of days to consider certificate as being to-be-expired (default: comes from master partition).",
"type": "string" "type": "number"
}, },
"check-maximum-elapsed-time": { "check-maximum-elapsed-time": {
"default": "Master default", "default": "Master default",
"title": "Maximum elapsed time for a site to reply (seconds)", "title": "Maximum elapsed time for a site to reply (seconds)",
"description": "Maximum elapsed time for a site to reply to be considered good.(default: comes from master partition).", "description": "Maximum elapsed time for a site to reply to be considered good.(default: comes from master partition).",
"type": "string" "type": "number"
}, },
"failure-amount": { "failure-amount": {
"default": "Master default", "default": "Master default",
"title": "Amount of failures to consider URL as in bad state", "title": "Amount of failures to consider URL as in bad state",
"description": "Amount of failures to consider URL as in bad state, can be set to higher value for endpoints with accepted short outages (default: comes from master partition).", "description": "Amount of failures to consider URL as in bad state, can be set to higher value for endpoints with accepted short outages (default: comes from master partition).",
"type": "string" "type": "number"
} }
} }
} }
...@@ -10,20 +10,22 @@ ...@@ -10,20 +10,22 @@
{%- if extra_slave_instance_list %} {%- if extra_slave_instance_list %}
{#- Create slaves to process with setting up defaults #} {#- Create slaves to process with setting up defaults #}
{%- for slave in json_module.loads(extra_slave_instance_list) | sort(attribute='slave_title') %} {%- for slave in json_module.loads(extra_slave_instance_list) | sort(attribute='slave_title') %}
{%- if '_' in slave %}
{%- do slave.update(json_module.loads(slave.pop('_'))) %}
{%- if 'check-status-code' not in slave %} {%- if 'check-status-code' not in slave %}
{%- do slave.__setitem__('check-status-code', CONFIGURATION['check-status-code']) %} {%- do slave.__setitem__('check-status-code', int(CONFIGURATION['check-status-code'])) %}
{%- endif %} {%- endif %}
{%- if 'check-http-header-dict' not in slave %} {%- if 'check-http-header-dict' not in slave %}
{%- do slave.__setitem__('check-http-header-dict', CONFIGURATION['check-http-header-dict']) %} {%- do slave.__setitem__('check-http-header-dict', CONFIGURATION['check-http-header-dict']) %}
{%- endif %} {%- endif %}
{%- if 'check-certificate-expiration-days' not in slave %} {%- if 'check-certificate-expiration-days' not in slave %}
{%- do slave.__setitem__('check-certificate-expiration-days', CONFIGURATION['check-certificate-expiration-days']) %} {%- do slave.__setitem__('check-certificate-expiration-days', int(CONFIGURATION['check-certificate-expiration-days'])) %}
{%- endif %} {%- endif %}
{%- if 'failure-amount' not in slave %} {%- if 'failure-amount' not in slave %}
{%- do slave.__setitem__('failure-amount', CONFIGURATION['failure-amount']) %} {%- do slave.__setitem__('failure-amount', int(CONFIGURATION['failure-amount'])) %}
{%- endif %} {%- endif %}
{%- if 'check-maximum-elapsed-time' not in slave %} {%- if 'check-maximum-elapsed-time' not in slave %}
{%- do slave.__setitem__('check-maximum-elapsed-time', CONFIGURATION['check-maximum-elapsed-time']) %} {%- do slave.__setitem__('check-maximum-elapsed-time', int(CONFIGURATION['check-maximum-elapsed-time'])) %}
{%- endif %} {%- endif %}
{%- if 'check-frontend-ip' not in slave %} {%- if 'check-frontend-ip' not in slave %}
{%- do slave.__setitem__('check-frontend-ip', CONFIGURATION['check-frontend-ip']) %} {%- do slave.__setitem__('check-frontend-ip', CONFIGURATION['check-frontend-ip']) %}
...@@ -35,6 +37,7 @@ ...@@ -35,6 +37,7 @@
{%- endif %} {%- endif %}
{%- do slave_instance_dict[class].append(slave) %} {%- do slave_instance_dict[class].append(slave) %}
{%- endif %} {%- endif %}
{%- endif %}
{%- endfor %} {%- endfor %}
{%- endif %} {%- endif %}
{%- set part_list = [] %} {%- set part_list = [] %}
...@@ -55,7 +58,7 @@ config-http-header-dict = {{ slave['check-http-header-dict'] }} ...@@ -55,7 +58,7 @@ config-http-header-dict = {{ slave['check-http-header-dict'] }}
config-certificate-expiration-days = {{ slave['check-certificate-expiration-days'] }} config-certificate-expiration-days = {{ slave['check-certificate-expiration-days'] }}
config-failure-amount = {{ slave['failure-amount'] }} config-failure-amount = {{ slave['failure-amount'] }}
config-maximum-elapsed-time = {{ slave['check-maximum-elapsed-time'] }} config-maximum-elapsed-time = {{ slave['check-maximum-elapsed-time'] }}
config-ip-list = {{ slave['check-frontend-ip'] }} config-ip-list = {{ ' '.join(slave['check-frontend-ip']) }}
config-json-file = ${surykatka-config-{{ class }}:json} config-json-file = ${surykatka-config-{{ class }}:json}
{%- endfor %} {%- endfor %}
...@@ -72,7 +75,7 @@ db = ${directory:srv}/surykatka-{{ class }}.db ...@@ -72,7 +75,7 @@ db = ${directory:srv}/surykatka-{{ class }}.db
rendered = ${directory:etc}/surykatka-{{ class }}.ini rendered = ${directory:etc}/surykatka-{{ class }}.ini
template = {{ template_surykatka_ini }} template = {{ template_surykatka_ini }}
slave_instance_list = {{ dumps(slave_instance_list) }} slave_instance_list = {{ dumps(slave_instance_list) }}
nameserver = {{ dumps(CONFIGURATION['nameserver']) }} nameserver_list = {{ dumps(CONFIGURATION['nameserver']) }}
json = ${directory:srv}/surykatka-{{ class }}.json json = ${directory:srv}/surykatka-{{ class }}.json
{#- timeout is just a bit bigger than class time #} {#- timeout is just a bit bigger than class time #}
timeout = {{ int(class) + 2 }} timeout = {{ int(class) + 2 }}
...@@ -80,7 +83,7 @@ timeout = {{ int(class) + 2 }} ...@@ -80,7 +83,7 @@ timeout = {{ int(class) + 2 }}
context = context =
import json_module json import json_module json
key db :db key db :db
key nameserver :nameserver key nameserver_list :nameserver_list
key slave_instance_list :slave_instance_list key slave_instance_list :slave_instance_list
key timeout :timeout key timeout :timeout
...@@ -110,9 +113,9 @@ cron-entries = ${directory:etc}/cron.d ...@@ -110,9 +113,9 @@ cron-entries = ${directory:etc}/cron.d
name = surykatka-status-{{ class }} name = surykatka-status-{{ class }}
frequency = */2 * * * * frequency = */2 * * * *
command = ${surykatka-status-json-{{ class }}:rendered} command = ${surykatka-status-json-{{ class }}:rendered}
{%- do part_list.append('surykatka-' + class) %} {%- do part_list.append('surykatka-%i'% (class,)) %}
{%- do part_list.append('surykatka-bot-promise-' + class) %} {%- do part_list.append('surykatka-bot-promise-%i' % (class,)) %}
{%- do part_list.append('cron-entry-surykatka-status-' + class) %} {%- do part_list.append('cron-entry-surykatka-status-%i' % (class,)) %}
{%- endfor %} {%- endfor %}
[buildout] [buildout]
......
...@@ -15,14 +15,17 @@ ...@@ -15,14 +15,17 @@
"description": "Cluster of bots to perform a distributed monitoring ", "description": "Cluster of bots to perform a distributed monitoring ",
"request": "instance-edgetest-input-schema.json", "request": "instance-edgetest-input-schema.json",
"response": "instance-default-output-schema.json", "response": "instance-default-output-schema.json",
"serialisation": "json-in-xml",
"index": 1 "index": 1
}, },
"edgetest-slave": { "edgetest-slave": {
"title": "Edge Test Slave", "title": "Edge Test Slave",
"shared": true,
"software-type": "edgetest", "software-type": "edgetest",
"description": "Cluster of bots to perform a distributed monitoring ", "description": "Cluster of bots to perform a distributed monitoring ",
"request": "instance-edgetest-slave-input-schema.json", "request": "instance-edgetest-slave-input-schema.json",
"response": "instance-default-output-schema.json", "response": "instance-default-output-schema.json",
"serialisation": "json-in-xml",
"index": 2 "index": 2
} }
} }
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
INTERVAL = 120 INTERVAL = 120
TIMEOUT = {{ timeout }} TIMEOUT = {{ timeout }}
SQLITE = {{ db }} SQLITE = {{ db }}
{%- set nameserver_list = nameserver.split() %}
{%- if len(nameserver_list) > 0 %} {%- if len(nameserver_list) > 0 %}
NAMESERVER = NAMESERVER =
{%- for nameserver_entry in sorted(nameserver_list) %} {%- for nameserver_entry in sorted(nameserver_list) %}
......
...@@ -147,7 +147,7 @@ class EdgeSlaveMixin(MonitorTestMixin): ...@@ -147,7 +147,7 @@ class EdgeSlaveMixin(MonitorTestMixin):
software_release=software_url, software_release=software_url,
software_type='edgetest', software_type='edgetest',
partition_reference=partition_reference, partition_reference=partition_reference,
partition_parameter_kw=partition_parameter_kw, partition_parameter_kw={'_': json.dumps(partition_parameter_kw)},
shared=True shared=True
) )
...@@ -335,7 +335,7 @@ URL = ...@@ -335,7 +335,7 @@ URL =
) )
self.requestEdgetestSlave( self.requestEdgetestSlave(
'backend-300', 'backend-300',
{'url': 'https://www.erp5.org/', 'check-status-code': '300'}, {'url': 'https://www.erp5.org/', 'check-status-code': 300},
) )
...@@ -356,10 +356,10 @@ URL = ...@@ -356,10 +356,10 @@ URL =
@classmethod @classmethod
def getInstanceParameterDict(cls): def getInstanceParameterDict(cls):
return { return {'_': json.dumps({
'nameserver': '127.0.1.1 127.0.1.2', 'nameserver': ['127.0.1.1', '127.0.1.2'],
'check-frontend-ip': '127.0.0.1 127.0.0.2', 'check-frontend-ip': ['127.0.0.1', '127.0.0.2'],
} })}
def assertSurykatkaPromises(self): def assertSurykatkaPromises(self):
self.assertPromiseContent( self.assertPromiseContent(
...@@ -406,9 +406,9 @@ URL = ...@@ -406,9 +406,9 @@ URL =
@classmethod @classmethod
def getInstanceParameterDict(cls): def getInstanceParameterDict(cls):
return { return {'_': json.dumps({
'check-status-code': '500', 'check-status-code': 500,
} })}
def assertSurykatkaPromises(self): def assertSurykatkaPromises(self):
self.assertPromiseContent( self.assertPromiseContent(
...@@ -466,7 +466,7 @@ URL = ...@@ -466,7 +466,7 @@ URL =
) )
self.requestEdgetestSlave( self.requestEdgetestSlave(
'backend-501', 'backend-501',
{'url': 'https://www.erp5.org/', 'check-status-code': '501'}, {'url': 'https://www.erp5.org/', 'check-status-code': 501},
) )
...@@ -483,10 +483,10 @@ URL = ...@@ -483,10 +483,10 @@ URL =
@classmethod @classmethod
def getInstanceParameterDict(cls): def getInstanceParameterDict(cls):
return { return {'_': json.dumps({
'check-http-header-dict': 'check-http-header-dict':
'{"B": "BBB"}', '{"B": "BBB"}',
} })}
def assertSurykatkaPromises(self): def assertSurykatkaPromises(self):
self.assertPromiseContent( self.assertPromiseContent(
...@@ -568,9 +568,9 @@ URL = ...@@ -568,9 +568,9 @@ URL =
@classmethod @classmethod
def getInstanceParameterDict(cls): def getInstanceParameterDict(cls):
return { return {'_': json.dumps({
'check-certificate-expiration-days': '10', 'check-certificate-expiration-days': 10,
} })}
def assertSurykatkaPromises(self): def assertSurykatkaPromises(self):
self.assertPromiseContent( self.assertPromiseContent(
...@@ -658,9 +658,9 @@ URL = ...@@ -658,9 +658,9 @@ URL =
@classmethod @classmethod
def getInstanceParameterDict(cls): def getInstanceParameterDict(cls):
return { return {'_': json.dumps({
'check-maximum-elapsed-time': '5', 'check-maximum-elapsed-time': 5,
} })}
def assertSurykatkaPromises(self): def assertSurykatkaPromises(self):
self.assertPromiseContent( self.assertPromiseContent(
...@@ -743,12 +743,12 @@ URL = ...@@ -743,12 +743,12 @@ URL =
self.requestEdgetestSlave( self.requestEdgetestSlave(
'backend-20', 'backend-20',
{'url': 'https://www.erp5.org/', {'url': 'https://www.erp5.org/',
'check-maximum-elapsed-time': '20'}, 'check-maximum-elapsed-time': 20},
) )
self.requestEdgetestSlave( self.requestEdgetestSlave(
'backend-1', 'backend-1',
{'url': 'https://www.erp5.net/', {'url': 'https://www.erp5.net/',
'check-maximum-elapsed-time': '1'}, 'check-maximum-elapsed-time': 1},
) )
...@@ -766,9 +766,9 @@ URL = ...@@ -766,9 +766,9 @@ URL =
@classmethod @classmethod
def getInstanceParameterDict(cls): def getInstanceParameterDict(cls):
return { return {'_': json.dumps({
'failure-amount': '5' 'failure-amount': 5
} })}
def assertSurykatkaPromises(self): def assertSurykatkaPromises(self):
self.assertPromiseContent( self.assertPromiseContent(
......
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