How to know if call to CC get monitoring api exited because of timeout

Hi,

In a script I develop to provision a new Integration Server (Windows batch), one step I do is start the IS using CC lifecycle api and then cc Monitoring api to detect when it’s up:

ex:

cc exec lifecycle start nodeAlias=%appName% runtimeComponentId=OSGI-IS*
cc get monitoring runtimestatus %appName% integrationServer-default --expected-values ONLINE --check-every 20 --wait 240
pause

This works fine. But if it takes more than 4 minutes to start the IS, the call will timeout and the script will continue. I don’t want it to continue, I need to manually make sure that the IS is up before proceeding with the other steps, so I inserted a pause command in the script. Then I can troubleshoot the problem and proceed with the execution of the script.

The problem is that the script will always pause, even if the IS was started correctly before the timeout. I would like it to pause only if there is a problem. Is there a way to know if the call to “cc get monitoring” exited because the expected value was found or if it exited because of the timeout?

Thanks.

When CC CLI command completes successfully it returns exit code 0 which you can check with ERRORLEVEL variable in your script

C:\Users\vmtest>cc get monitoring runtimestatus %appName% integrationServer-default --expected-values ONLINE --check-every 5 --wait 1
Runtime Status
ONLINE
The expected values were successfully retrieved after 1 call within 1 second.

C:\Users\vmtest>echo %ERRORLEVEL%
0

When CC CLI command completes with a status when expected values are NOT successfully retrieved in time then it returns exist code 10

C:\Users\vmtest>cc get monitoring runtimestatus %appName% integrationServer-default --expected-values ONLINE1 --check-every 5 --wait

Runtime Status
ONLINE
Runtime Status
ONLINE
The expected values [‘ONLINE1’] were not returned after 3 calls within 10 seconds.

C:\Users\vmtest>echo %ERRORLEVEL%
10

When CC CLI command completes with an 4xx or 5xx HTTP error then its exist code is the same as HTTP error

C:\Users\vmtest>cc get monitoring runtimestatus1 %appName% integrationServer-default
ERROR: 404 Not Found

C:\Users\vmtest>echo %ERRORLEVEL%
404

Thanks, that’s perfect. It’s nice that CC provides an easy way to check the running status of an application. Many apis just provide start/stop functions. It makes coding scripts so much easier.