Module check_consecutive_build_fails
|
|
1
2
3
4 from __future__ import print_function
5 from __future__ import unicode_literals
6 from __future__ import division
7 from __future__ import absolute_import
8
9 import sys
10
11 from redis import StrictRedis
12
13 sys.path.append("/usr/share/copr/")
14
15
16 from backend.helpers import BackendConfigReader
17 from backend.constants import CONSECUTIVE_FAILURE_REDIS_KEY
18
19
21 opts = BackendConfigReader().read()
22 conn = StrictRedis()
23
24 key = CONSECUTIVE_FAILURE_REDIS_KEY
25
26 value = int(conn.get(key) or 0)
27 if value > opts.consecutive_failure_threshold:
28 print("Critical")
29 sys.exit(2)
30 elif value > int(0.5 * opts.consecutive_failure_threshold):
31 print("Warning")
32 sys.exit(1)
33 else:
34 print("OK")
35 sys.exit(0)
36
37
38 if __name__ == "__main__":
39 try:
40 main()
41 except Exception as error:
42 print("UNKNOWN: {}".format(error))
43 sys.exit(3)
44