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