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): ...@@ -75,18 +75,13 @@ class RunPromise(GenericPromise):
delta = self.utcnow - last_bot_datetime delta = self.utcnow - last_bot_datetime
# sanity check # sanity check
if delta < datetime.timedelta(minutes=0): if delta < datetime.timedelta(minutes=0):
appendError('Last bot datetime %s is in future', appendError('Last bot datetime is in future')
last_bot_datetime_string,)
return return
if delta > datetime.timedelta(minutes=15): if delta > datetime.timedelta(minutes=15):
appendError( appendError('Last bot datetime is more than 15 minutes old')
'Last bot datetime %s is more than 15 minutes old',
last_bot_datetime_string,)
return return
self.appendInfoMessage( self.appendInfoMessage('%s: OK Last bot status' % (key,))
'%s: OK Last bot status from %s' %
(key, last_bot_datetime_string,))
def senseSslCertificate(self): def senseSslCertificate(self):
key = 'ssl_certificate' key = 'ssl_certificate'
...@@ -236,14 +231,12 @@ class RunPromise(GenericPromise): ...@@ -236,14 +231,12 @@ class RunPromise(GenericPromise):
appendError('IP %s failed to reply' % (entry['ip'])) appendError('IP %s failed to reply' % (entry['ip']))
elif entry['total_seconds'] > maximum_elapsed_time: elif entry['total_seconds'] > maximum_elapsed_time:
appendError( appendError(
'IP %s replied in %.2fs which is longer than ' 'IP %s replied in more time than maximum %.2fs' %
'maximum %.2fs' % (entry['ip'], maximum_elapsed_time))
(entry['ip'], entry['total_seconds'], maximum_elapsed_time))
else: else:
self.appendInfoMessage( self.appendInfoMessage(
'%s: OK IP %s replied in %.2fs which is shorter than ' '%s: OK IP %s replied in less time than maximum %.2fs' % (
'maximum %.2fs' % (key, entry['ip'], key, entry['ip'], maximum_elapsed_time))
entry['total_seconds'], maximum_elapsed_time))
def sense(self): def sense(self):
""" """
......
...@@ -114,7 +114,7 @@ class TestCheckSurykatkaJSONBotStatus(CheckSurykatkaJSONMixin): ...@@ -114,7 +114,7 @@ class TestCheckSurykatkaJSONBotStatus(CheckSurykatkaJSONMixin):
self.launcher.run() self.launcher.run()
self.assertPassedMessage( self.assertPassedMessage(
self.getPromiseResult(self.promise_name), 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): def test_no_loop(self):
...@@ -165,8 +165,7 @@ class TestCheckSurykatkaJSONBotStatus(CheckSurykatkaJSONMixin): ...@@ -165,8 +165,7 @@ class TestCheckSurykatkaJSONBotStatus(CheckSurykatkaJSONMixin):
self.launcher.run() self.launcher.run()
self.assertFailedMessage( self.assertFailedMessage(
self.getPromiseResult(self.promise_name), self.getPromiseResult(self.promise_name),
"bot_status: ERROR Last bot datetime Sat, 13 Dec 2223 08:10:11 -0000 is " "bot_status: ERROR Last bot datetime is in future"
"in future"
) )
def test_bot_status_old(self): def test_bot_status_old(self):
...@@ -191,8 +190,7 @@ class TestCheckSurykatkaJSONBotStatus(CheckSurykatkaJSONMixin): ...@@ -191,8 +190,7 @@ class TestCheckSurykatkaJSONBotStatus(CheckSurykatkaJSONMixin):
self.launcher.run() self.launcher.run()
self.assertFailedMessage( self.assertFailedMessage(
self.getPromiseResult(self.promise_name), self.getPromiseResult(self.promise_name),
"bot_status: ERROR Last bot datetime Sat, 13 Dec 2223 08:10:11 -0000 is " "bot_status: ERROR Last bot datetime is more than 15 minutes old"
"more than 15 minutes old"
) )
def test_not_bot_status(self): def test_not_bot_status(self):
...@@ -348,9 +346,8 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin): ...@@ -348,9 +346,8 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
"https://www.erp5.com/ : http_query: OK with status code 302 on IPs " "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 " "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 " "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 " "elapsed_time: OK IP 127.0.0.1 replied in less time than maximum 5.00s "
"maximum 5.00s elapsed_time: OK IP 127.0.0.2 replied in 4.00s which is " "elapsed_time: OK IP 127.0.0.2 replied in less time than maximum 5.00s"
"shorter than maximum 5.00s"
) )
def test_maximum_elapsed_time_too_long(self): def test_maximum_elapsed_time_too_long(self):
...@@ -411,10 +408,10 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin): ...@@ -411,10 +408,10 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
self.assertFailedMessage( self.assertFailedMessage(
self.getPromiseResult(self.promise_name), self.getPromiseResult(self.promise_name),
"https://www.erp5.com/ : elapsed_time: ERROR IP 127.0.0.1 replied in " "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 " "more time than maximum 5.00s elapsed_time: ERROR IP 127.0.0.2 failed "
"127.0.0.2 failed to reply http_query: OK with status code 302 on IPs " "to reply http_query: OK with status code 302 on IPs 127.0.0.1 "
"127.0.0.1 127.0.0.2 ssl_certificate: OK Certificate on 127.0.0.1 will " "127.0.0.2 ssl_certificate: OK Certificate on 127.0.0.1 will expire on "
"expire on Mon, 13 Jul 2020 12:00:00 -0000, which is more than 15 days" "Mon, 13 Jul 2020 12:00:00 -0000, which is more than 15 days"
) )
def test_maximum_elapsed_time_no_total_seconds(self): 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