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

Function execute

systemvm/debian/root/monitorServices.py:310–339  ·  view source on GitHub ↗
(script, checkType = "basic")

Source from the content-addressed store, hash-verified

308
309
310def execute(script, checkType = "basic"):
311 checkStartTime = time.time()
312 cmd = "./" + script + " " + checkType
313 printd ("Executing health check script command: " + cmd)
314
315 pout = Popen(cmd, shell=True, stdout=PIPE)
316 exitStatus = pout.wait()
317 output = pout.communicate()[0].decode().strip()
318 checkEndTime = time.time()
319
320 # we run all scripts and have to ignore the ones that do nothing
321 if not len(output) > 0 and exitStatus == 0:
322 return {}
323
324 routerHealth = RouterHealthStatus.SUCCESS
325 match exitStatus:
326 case 1:
327 routerHealth = RouterHealthStatus.FAILED
328 case 2:
329 routerHealth = RouterHealthStatus.WARNING
330 case 3:
331 routerHealth = RouterHealthStatus.UNKNOWN
332
333 printd("Ended execution of " + script)
334 return {
335 "success": routerHealth,
336 "lastUpdate": str(int(checkStartTime * 1000)),
337 "lastRunDuration": str((checkEndTime - checkStartTime) * 1000),
338 "message": output
339 }
340
341def main(checkType = "basic"):
342 startTime = time.time()

Callers 1

mainFunction · 0.70

Calls 4

printdFunction · 0.85
intFunction · 0.85
waitMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected