Commit 587c0792 authored by Łukasz Nowak's avatar Łukasz Nowak

check_surykatka_json: Minimise message variation

Monitoring is about states, not exact values, so report the states, as
otherwise it results with bloating databases, very long accesses to results
and long synchronisations.

Instead of many entries like:

http://url/ : http_query: OK status code 302 on IPs IP elapsed_time: ERROR IP IP replied in 5.02s which is longer than maximum 5.00s
http://url/ : http_query: OK status code 302 on IPs IP elapsed_time: ERROR IP IP replied in 5.03s which is longer than maximum 5.00s
http://url/ : http_query: OK status code 302 on IPs IP elapsed_time: ERROR IP IP replied in 5.04s which is longer than maximum 5.00s
http://url/ : http_query: OK status code 302 on IPs IP elapsed_time: ERROR IP IP replied in 5.01s which is longer than maximum 5.00s
http://url/ : http_query: OK status code 302 on IPs IP elapsed_time: OK IP IP replied in 0.08s which is shorter than maximum 5.00s
http://url/ : http_query: OK status code 302 on IPs IP elapsed_time: OK IP IP replied in 1.37s which is shorter than maximum 5.00s
http://url/ : http_query: OK status code 302 on IPs IP elapsed_time: OK IP IP replied in 0.09s which is shorter than maximum 5.00s
http://url/ : http_query: OK status code 302 on IPs IP elapsed_time: OK IP IP replied in 1.37s which is shorter than maximum 5.00s
http://url/ : http_query: OK status code 302 on IPs IP elapsed_time: OK IP IP replied in 0.09s which is shorter than maximum 5.00s

It's minimised to:

http://url/ : http_query: OK status code 302 on IPs IP elapsed_time: ERROR IP IP replied in more time than maximum 5.00s
http://url/ : http_query: OK status code 302 on IPs IP elapsed_time: OK IP IP replied in less time than maximum 5.00s

This affects:

 * bot_status
 * http_query

Obviously some information are removed from the monitor, but anyway they are
just text entries and not parsable. So other approaches shall be used to make
graphs from those values, which is not covered by pure promise status.
parent 68e5bd44
Pipeline #13322 passed with stage
in 0 seconds
......@@ -75,18 +75,13 @@ class RunPromise(GenericPromise):
delta = self.utcnow - last_bot_datetime
# sanity check
if delta < datetime.timedelta(minutes=0):
appendError('Last bot datetime %s is in future',
last_bot_datetime_string,)
appendError('Last bot datetime is in future')
return
if delta > datetime.timedelta(minutes=15):
appendError(
'Last bot datetime %s is more than 15 minutes old',
last_bot_datetime_string,)
appendError('Last bot datetime is more than 15 minutes old')
return
self.appendInfoMessage(
'%s: OK Last bot status from %s' %
(key, last_bot_datetime_string,))
self.appendInfoMessage('%s: OK Last bot status' % (key,))
def senseSslCertificate(self):
key = 'ssl_certificate'
......@@ -236,14 +231,12 @@ class RunPromise(GenericPromise):
appendError('IP %s failed to reply' % (entry['ip']))
elif entry['total_seconds'] > maximum_elapsed_time:
appendError(
'IP %s replied in %.2fs which is longer than '
'maximum %.2fs' %
(entry['ip'], entry['total_seconds'], maximum_elapsed_time))
'IP %s replied in more time than maximum %.2fs' %
(entry['ip'], maximum_elapsed_time))
else:
self.appendInfoMessage(
'%s: OK IP %s replied in %.2fs which is shorter than '
'maximum %.2fs' % (key, entry['ip'],
entry['total_seconds'], maximum_elapsed_time))
'%s: OK IP %s replied in less time than maximum %.2fs' % (
key, entry['ip'], maximum_elapsed_time))
def sense(self):
"""
......
......@@ -114,7 +114,7 @@ class TestCheckSurykatkaJSONBotStatus(CheckSurykatkaJSONMixin):
self.launcher.run()
self.assertPassedMessage(
self.getPromiseResult(self.promise_name),
"bot_status: OK Last bot status from Fri, 13 Dec 2222 08:10:11 -0000"
"bot_status: OK Last bot status"
)
def test_no_loop(self):
......@@ -165,8 +165,7 @@ class TestCheckSurykatkaJSONBotStatus(CheckSurykatkaJSONMixin):
self.launcher.run()
self.assertFailedMessage(
self.getPromiseResult(self.promise_name),
"bot_status: ERROR Last bot datetime Sat, 13 Dec 2223 08:10:11 -0000 is "
"in future"
"bot_status: ERROR Last bot datetime is in future"
)
def test_bot_status_old(self):
......@@ -191,8 +190,7 @@ class TestCheckSurykatkaJSONBotStatus(CheckSurykatkaJSONMixin):
self.launcher.run()
self.assertFailedMessage(
self.getPromiseResult(self.promise_name),
"bot_status: ERROR Last bot datetime Sat, 13 Dec 2223 08:10:11 -0000 is "
"more than 15 minutes old"
"bot_status: ERROR Last bot datetime is more than 15 minutes old"
)
def test_not_bot_status(self):
......@@ -348,9 +346,8 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
"https://www.erp5.com/ : http_query: OK with status code 302 on IPs "
"127.0.0.1 127.0.0.2 ssl_certificate: OK Certificate on 127.0.0.1 will "
"expire on Mon, 13 Jul 2020 12:00:00 -0000, which is more than 15 days "
"elapsed_time: OK IP 127.0.0.1 replied in 4.00s which is shorter than "
"maximum 5.00s elapsed_time: OK IP 127.0.0.2 replied in 4.00s which is "
"shorter than maximum 5.00s"
"elapsed_time: OK IP 127.0.0.1 replied in less time than maximum 5.00s "
"elapsed_time: OK IP 127.0.0.2 replied in less time than maximum 5.00s"
)
def test_maximum_elapsed_time_too_long(self):
......@@ -411,10 +408,10 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
self.assertFailedMessage(
self.getPromiseResult(self.promise_name),
"https://www.erp5.com/ : elapsed_time: ERROR IP 127.0.0.1 replied in "
"6.00s which is longer than maximum 5.00s elapsed_time: ERROR IP "
"127.0.0.2 failed to reply http_query: OK with status code 302 on IPs "
"127.0.0.1 127.0.0.2 ssl_certificate: OK Certificate on 127.0.0.1 will "
"expire on Mon, 13 Jul 2020 12:00:00 -0000, which is more than 15 days"
"more time than maximum 5.00s elapsed_time: ERROR IP 127.0.0.2 failed "
"to reply http_query: OK with status code 302 on IPs 127.0.0.1 "
"127.0.0.2 ssl_certificate: OK Certificate on 127.0.0.1 will expire on "
"Mon, 13 Jul 2020 12:00:00 -0000, which is more than 15 days"
)
def test_maximum_elapsed_time_no_total_seconds(self):
......
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