MCPcopy Create free account
hub / github.com/apache/cloudstack / main

Function main

systemvm/debian/root/health_checks/haproxy_check.py:122–170  ·  view source on GitHub ↗

Checks for max con and each load balancing rule - source ip, ports and destination ips and ports. Also checks for http mode. Does not check for stickiness policies.

()

Source from the content-addressed store, hash-verified

120
121
122def main():
123 '''
124 Checks for max con and each load balancing rule - source ip, ports and destination
125 ips and ports. Also checks for http mode. Does not check for stickiness policies.
126 '''
127 haproxyData = getHealthChecksData("haproxyData")
128 if haproxyData is None or len(haproxyData) == 0:
129 print("No data provided to check, skipping")
130 exit(0)
131
132 with open("/etc/haproxy/haproxy.cfg", 'r') as haCfgFile:
133 haCfgLines = haCfgFile.readlines()
134 haCfgFile.close()
135
136 if len(haCfgLines) == 0:
137 print("Unable to read config file /etc/haproxy/haproxy.cfg")
138 exit(1)
139
140 haCfgSections = {}
141 currSection = None
142 currSectionDict = {}
143 for line in haCfgLines:
144 line = line.strip()
145 if len(line) == 0:
146 if currSection is not None and len(currSectionDict) > 0:
147 haCfgSections[currSection] = currSectionDict
148
149 currSection = None
150 currSectionDict = {}
151 continue
152
153 if currSection is None:
154 currSection = line
155 else:
156 lineSec = line.split(' ', 1)
157 if lineSec[0] not in currSectionDict:
158 currSectionDict[lineSec[0]] = []
159
160 currSectionDict[lineSec[0]].append(lineSec[1] if len(lineSec) > 1 else '')
161
162 checkMaxConn = checkMaxconn(haproxyData[0], haCfgSections)
163 checkIdleTimeout = checkIdletimeout(haproxyData[0], haCfgSections)
164 checkLbRules = checkLoadBalance(haproxyData, haCfgSections)
165
166 if checkMaxConn and checkIdleTimeout and checkLbRules:
167 print("All checks pass")
168 exit(0)
169 else:
170 exit(1)
171
172
173if __name__ == "__main__":

Callers 1

haproxy_check.pyFile · 0.70

Calls 8

getHealthChecksDataFunction · 0.90
exitFunction · 0.85
checkMaxconnFunction · 0.85
checkIdletimeoutFunction · 0.85
checkLoadBalanceFunction · 0.85
readlinesMethod · 0.80
closeMethod · 0.65
appendMethod · 0.45

Tested by

no test coverage detected