Commit 8aa104b1 authored by Łukasz Nowak's avatar Łukasz Nowak

software/monitor: Implement whois checks

parent b3a71105
...@@ -22,7 +22,7 @@ md5sum = 2eb5596544d9c341acf653d4f7ce2680 ...@@ -22,7 +22,7 @@ md5sum = 2eb5596544d9c341acf653d4f7ce2680
[template-monitor-edgetest-basic] [template-monitor-edgetest-basic]
_update_hash_filename_ = instance-monitor-edgetest-basic.cfg.jinja2 _update_hash_filename_ = instance-monitor-edgetest-basic.cfg.jinja2
md5sum = d375f656087bfbd8a11188721e31de68 md5sum = d210bb35a23421f0f8a685fea973eee4
[template-node-monitoring] [template-node-monitoring]
_update_hash_filename_ = instance-node-monitoring.jinja2.cfg _update_hash_filename_ = instance-node-monitoring.jinja2.cfg
......
...@@ -44,6 +44,12 @@ ...@@ -44,6 +44,12 @@
"type": "number", "type": "number",
"minimum": 1 "minimum": 1
}, },
"check-domain-expiration-days": {
"title": "Domain Expiration Check (days)",
"description": "Amount of days to consider the domain as being to-be-expired. Defaults to global configuration.",
"type": "number",
"minimum": 1
},
"check-maximum-elapsed-time": { "check-maximum-elapsed-time": {
"title": "Maximum Elapsed Check (seconds)", "title": "Maximum Elapsed Check (seconds)",
"description": "Maximum elapsed time for a site to reply to be considered good. Defaults to global configuration.", "description": "Maximum elapsed time for a site to reply to be considered good. Defaults to global configuration.",
...@@ -84,6 +90,13 @@ ...@@ -84,6 +90,13 @@
"default": 15, "default": 15,
"minimum": 1 "minimum": 1
}, },
"check-domain-expiration-days": {
"title": "Default Domain Expiration Check (days)",
"description": "Default amount of days to consider the domain as being to-be-expired.",
"type": "number",
"default": 30,
"minimum": 1
},
"check-maximum-elapsed-time": { "check-maximum-elapsed-time": {
"title": "Default Maximum Elapsed Check (seconds)", "title": "Default Maximum Elapsed Check (seconds)",
"description": "Default maximum elapsed time for a site to reply to be considered good.", "description": "Default maximum elapsed time for a site to reply to be considered good.",
...@@ -102,7 +115,7 @@ ...@@ -102,7 +115,7 @@
"title": "[EXPERT] Enabled Senses", "title": "[EXPERT] Enabled Senses",
"description": "Space separated list of enabled senses of the promise.", "description": "Space separated list of enabled senses of the promise.",
"type": "string", "type": "string",
"default": "dns_query tcp_server http_query ssl_certificate elapsed_time" "default": "dns_query whois tcp_server http_query ssl_certificate elapsed_time"
} }
} }
} }
...@@ -3,13 +3,14 @@ ...@@ -3,13 +3,14 @@
'check-status-code': 200, 'check-status-code': 200,
'check-http-header-dict': {}, 'check-http-header-dict': {},
'check-certificate-expiration-days': 15, 'check-certificate-expiration-days': 15,
'check-domain-expiration-days': 30,
'failure-amount': 2, 'failure-amount': 2,
'check-maximum-elapsed-time': 2, 'check-maximum-elapsed-time': 2,
'check-frontend-ip-list': [], 'check-frontend-ip-list': [],
'nameserver-list': [], 'nameserver-list': [],
'enabled-sense-list': 'dns_query tcp_server http_query ssl_certificate elapsed_time' 'enabled-sense-list': 'dns_query whois tcp_server http_query ssl_certificate elapsed_time'
} %} } %}
{%- for default_key in ['check-frontend-ip-list', 'nameserver-list', 'check-status-code', 'check-certificate-expiration-days', 'check-maximum-elapsed-time', 'failure-amount', 'enabled-sense-list'] %} {%- for default_key in ['check-frontend-ip-list', 'nameserver-list', 'check-status-code', 'check-certificate-expiration-days', 'check-domain-expiration-days', 'check-maximum-elapsed-time', 'failure-amount', 'enabled-sense-list'] %}
{%- if default_key in slapparameter_dict %} {%- if default_key in slapparameter_dict %}
{%- do DEFAULT_DICT.__setitem__(default_key, slapparameter_dict[default_key]) %} {%- do DEFAULT_DICT.__setitem__(default_key, slapparameter_dict[default_key]) %}
{%- endif %} {%- endif %}
...@@ -66,6 +67,7 @@ config-url = {{ url }} ...@@ -66,6 +67,7 @@ config-url = {{ url }}
config-status-code = {{ check['check-status-code'] }} config-status-code = {{ check['check-status-code'] }}
config-http-header-dict = {{ json_module.dumps(check['check-http-header-dict']) }} config-http-header-dict = {{ json_module.dumps(check['check-http-header-dict']) }}
config-certificate-expiration-days = {{ check['check-certificate-expiration-days'] }} config-certificate-expiration-days = {{ check['check-certificate-expiration-days'] }}
config-domain-expiration-days = {{ check['check-domain-expiration-days'] }}
config-failure-amount = {{ check['failure-amount'] }} config-failure-amount = {{ check['failure-amount'] }}
config-maximum-elapsed-time = {{ check['check-maximum-elapsed-time'] }} config-maximum-elapsed-time = {{ check['check-maximum-elapsed-time'] }}
config-ip-list = {{ ' '.join(check['check-frontend-ip-list']) }} config-ip-list = {{ ' '.join(check['check-frontend-ip-list']) }}
......
...@@ -472,6 +472,12 @@ class TestEdgeBasic(EdgeMixin, SlapOSInstanceTestCase): ...@@ -472,6 +472,12 @@ class TestEdgeBasic(EdgeMixin, SlapOSInstanceTestCase):
], ],
'check-http-header-dict': {"A": "AAA"}, 'check-http-header-dict': {"A": "AAA"},
}, },
"whois-check": {
"url-list": [
"https://whois.example.com",
],
"check-domain-expiration-days": 16,
},
} }
})} })}
...@@ -496,6 +502,7 @@ URL = ...@@ -496,6 +502,7 @@ URL =
https://header.example.com https://header.example.com
https://path.example.com/path https://path.example.com/path
https://status.example.com https://status.example.com
https://whois.example.com
"""}, """},
11: {'expected_ini': """[SURYKATKA] 11: {'expected_ini': """[SURYKATKA]
INTERVAL = 120 INTERVAL = 120
...@@ -516,7 +523,8 @@ URL = ...@@ -516,7 +523,8 @@ URL =
def getInstanceSoftwareType(cls): def getInstanceSoftwareType(cls):
return 'edgetest-basic' return 'edgetest-basic'
enabled_sense_list = "'dns_query tcp_server http_query ssl_certificate '\n"\ enabled_sense_list = \
"'dns_query whois tcp_server http_query ssl_certificate '\n"\
" 'elapsed_time'" " 'elapsed_time'"
def assertSurykatkaPromises(self): def assertSurykatkaPromises(self):
...@@ -525,6 +533,7 @@ URL = ...@@ -525,6 +533,7 @@ URL =
'path-check', 'path-check',
'https://path.example.com/path', 'https://path.example.com/path',
"""extra_config_dict = { 'certificate-expiration-days': '7', """extra_config_dict = { 'certificate-expiration-days': '7',
'domain-expiration-days': '30',
'enabled-sense-list': %s, 'enabled-sense-list': %s,
'failure-amount': '1', 'failure-amount': '1',
'http-header-dict': '{}', 'http-header-dict': '{}',
...@@ -542,6 +551,7 @@ URL = ...@@ -542,6 +551,7 @@ URL =
'domain-check', 'domain-check',
'https://domain.example.com', 'https://domain.example.com',
"""extra_config_dict = { 'certificate-expiration-days': '7', """extra_config_dict = { 'certificate-expiration-days': '7',
'domain-expiration-days': '30',
'enabled-sense-list': %s, 'enabled-sense-list': %s,
'failure-amount': '1', 'failure-amount': '1',
'http-header-dict': '{}', 'http-header-dict': '{}',
...@@ -559,6 +569,7 @@ URL = ...@@ -559,6 +569,7 @@ URL =
'domain-check', 'domain-check',
'http://domain.example.com', 'http://domain.example.com',
"""extra_config_dict = { 'certificate-expiration-days': '7', """extra_config_dict = { 'certificate-expiration-days': '7',
'domain-expiration-days': '30',
'enabled-sense-list': %s, 'enabled-sense-list': %s,
'failure-amount': '1', 'failure-amount': '1',
'http-header-dict': '{}', 'http-header-dict': '{}',
...@@ -576,6 +587,7 @@ URL = ...@@ -576,6 +587,7 @@ URL =
'frontend-check', 'frontend-check',
'https://frontend.example.com', 'https://frontend.example.com',
"""extra_config_dict = { 'certificate-expiration-days': '7', """extra_config_dict = { 'certificate-expiration-days': '7',
'domain-expiration-days': '30',
'enabled-sense-list': %s, 'enabled-sense-list': %s,
'failure-amount': '1', 'failure-amount': '1',
'http-header-dict': '{}', 'http-header-dict': '{}',
...@@ -593,6 +605,7 @@ URL = ...@@ -593,6 +605,7 @@ URL =
'frontend-empty-check', 'frontend-empty-check',
'https://frontendempty.example.com', 'https://frontendempty.example.com',
"""extra_config_dict = { 'certificate-expiration-days': '7', """extra_config_dict = { 'certificate-expiration-days': '7',
'domain-expiration-days': '30',
'enabled-sense-list': %s, 'enabled-sense-list': %s,
'failure-amount': '1', 'failure-amount': '1',
'http-header-dict': '{}', 'http-header-dict': '{}',
...@@ -610,6 +623,7 @@ URL = ...@@ -610,6 +623,7 @@ URL =
'status-check', 'status-check',
'https://status.example.com', 'https://status.example.com',
"""extra_config_dict = { 'certificate-expiration-days': '7', """extra_config_dict = { 'certificate-expiration-days': '7',
'domain-expiration-days': '30',
'enabled-sense-list': %s, 'enabled-sense-list': %s,
'failure-amount': '1', 'failure-amount': '1',
'http-header-dict': '{}', 'http-header-dict': '{}',
...@@ -627,6 +641,7 @@ URL = ...@@ -627,6 +641,7 @@ URL =
'certificate-check', 'certificate-check',
'https://certificate.example.com', 'https://certificate.example.com',
"""extra_config_dict = { 'certificate-expiration-days': '11', """extra_config_dict = { 'certificate-expiration-days': '11',
'domain-expiration-days': '30',
'enabled-sense-list': %s, 'enabled-sense-list': %s,
'failure-amount': '1', 'failure-amount': '1',
'http-header-dict': '{}', 'http-header-dict': '{}',
...@@ -644,6 +659,7 @@ URL = ...@@ -644,6 +659,7 @@ URL =
'time-check', 'time-check',
'https://time.example.com', 'https://time.example.com',
"""extra_config_dict = { 'certificate-expiration-days': '7', """extra_config_dict = { 'certificate-expiration-days': '7',
'domain-expiration-days': '30',
'enabled-sense-list': %s, 'enabled-sense-list': %s,
'failure-amount': '1', 'failure-amount': '1',
'http-header-dict': '{}', 'http-header-dict': '{}',
...@@ -661,6 +677,7 @@ URL = ...@@ -661,6 +677,7 @@ URL =
'failure-check', 'failure-check',
'https://failure.example.com', 'https://failure.example.com',
"""extra_config_dict = { 'certificate-expiration-days': '7', """extra_config_dict = { 'certificate-expiration-days': '7',
'domain-expiration-days': '30',
'enabled-sense-list': %s, 'enabled-sense-list': %s,
'failure-amount': '3', 'failure-amount': '3',
'http-header-dict': '{}', 'http-header-dict': '{}',
...@@ -678,6 +695,7 @@ URL = ...@@ -678,6 +695,7 @@ URL =
'header-check', 'header-check',
'https://header.example.com', 'https://header.example.com',
"""extra_config_dict = { 'certificate-expiration-days': '7', """extra_config_dict = { 'certificate-expiration-days': '7',
'domain-expiration-days': '30',
'enabled-sense-list': %s, 'enabled-sense-list': %s,
'failure-amount': '1', 'failure-amount': '1',
'http-header-dict': '{"A": "AAA"}', 'http-header-dict': '{"A": "AAA"}',
...@@ -690,6 +708,24 @@ URL = ...@@ -690,6 +708,24 @@ URL =
self.enabled_sense_list, self.enabled_sense_list,
self.surykatka_dict['edge0'][5]['json-file'],)) self.surykatka_dict['edge0'][5]['json-file'],))
self.assertHttpQueryPromiseContent(
'edge0',
'whois-check',
'https://whois.example.com',
"""extra_config_dict = { 'certificate-expiration-days': '7',
'domain-expiration-days': '16',
'enabled-sense-list': %s,
'failure-amount': '1',
'http-header-dict': '{}',
'ip-list': '127.0.0.1 127.0.0.2',
'json-file': '%s',
'maximum-elapsed-time': '5',
'report': 'http_query',
'status-code': '201',
'url': 'https://whois.example.com'}""" % (
self.enabled_sense_list,
self.surykatka_dict['edge0'][5]['json-file'],))
def test(self): def test(self):
# Note: Those tests do not run surykatka and do not do real checks, as # Note: Those tests do not run surykatka and do not do real checks, as
# this depends too much on the environment and is really hard to # this depends too much on the environment and is really hard to
......
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