File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -12,13 +12,16 @@ class APIConnectNet(object):
12
12
namespace = 'apic-management'
13
13
use_kubeconfig = False
14
14
trawler = None
15
+ health_prefix = "apiconnect"
15
16
16
17
def __init__ (self , config , trawler ):
17
18
# Takes in config object and trawler instance it's behind
18
19
# Use kubeconfig or in-cluster config for k8s comms
19
20
# self.use_kubeconfig = trawler.use_kubeconfig
20
21
# Namespace to find CRs
21
22
self .namespace = config .get ('namespace' , 'default' )
23
+ self .health_prefix = config .get ('health_prefix' , 'apiconnect' )
24
+ self .health_label = config .get ('health_label' , {})
22
25
self .trawler = trawler
23
26
self .use_kubeconfig = trawler .use_kubeconfig
24
27
@@ -45,6 +48,20 @@ def fish(self):
45
48
customResource ['plural' ])
46
49
for item in api_response ['items' ]:
47
50
for condition in item ['status' ]['conditions' ]:
51
+ if condition ['type' ] == 'Ready' :
52
+ if condition ['status' ]:
53
+ health = 1
54
+ else :
55
+ health = 0
56
+ self .trawler .set_gauge (
57
+ self .health_prefix ,
58
+ "health_status" ,
59
+ health ,
60
+ labels = {
61
+ "component" : "{} {}" .format (customResource ['plural' ][:- 1 ], item ['metadata' ]['name' ]),
62
+ ** self .health_label
63
+ })
64
+
48
65
self .trawler .set_gauge (
49
66
'apiconnect' ,
50
67
"{}_status" .format (customResource ['plural' ]),
You can’t perform that action at this time.
0 commit comments