(Find more terminal tips here: https://blogs.sap.com/tag/terminaltip/)
In today’s HandsOnSAPDev live stream, Ep.65, we built the SAP Cloud Platform Workflow sample application MTA in the SAP Web IDE, and deployed it to our Cloud Foundry (CF) space from there too. We noticed that the console logging was buffering the deployment log, so we didn’t see much during the operation:
At the time, I wondered out loud whether it was possible to remotely monitor an operation.
Remember that the multiapps plugin for the
cf command line tool gives us lots of options in relation to multi target application (MTA) operations. A couple of example are:
- see a summary list of active operations with the
- download the logs of such an operation, with the
download-mta-op-logscommand (which is also available in the form of a mercifully shorter alias
This latter command is in the right ballpark, but doesn’t allow the live monitoring (or “tailing”) of log output.
After the live stream ended, I was pondering this and had a look at the documentation on the SAP Help Portal, specifically the Multitarget Application Commands for the Cloud Foundry Environment section. There, it describes the
-i option to the
cf deploy command, which allows us to interact with active MTA operations:
cf deploy [-i <OPERATION_ID>] [-a <ACTION>]
Digging a little further, it turns out that one of the actions is
monitor, and indeed that’s exactly what we’re looking for!
So, kicking off a deployment in the SAP Web IDE gives us something in the console that looks like what we see above in the screenshot. But we can switch to a more comfortable terminal environment and use this feature to monitor that very operation that we kicked off in the SAP Web IDE.
Here’s how: In the terminal, we can first find out the ID of the MTA operation, like this:
-> cf mta-ops Getting active multi-target app operations in org p2001351149trial / space dev as email@example.com... OK id type mta id status started at started by f450e444-8632-11ea-abb3-eeee0a8f6ba7 DEPLOY sample.onboarding.mta RUNNING 2020-04-24T13:53:19.367Z[UTC] firstname.lastname@example.org
We can then take the ID and use it like this:
-> cf deploy -i f450e444-8632-11ea-abb3-eeee0a8f6ba7 -a monitor Updating application "uiDeployer"... Application "uiDeployer" attributes are not modified and will not be updated Uploading application "uiDeployer"... Content of application "uiDeployer" is not changed - upload will be skipped. Starting application "uiDeployer"... Application "uiDeployer" started Application "uiDeployer" executed Stopping application "uiDeployer"... Deleting discontinued configuration entries for application "uiDeployer"... Service key "onboarding-workflow-credentials" for service "workflow" already exists Uploading content module "onboarding" in target service "workflow"... Deploying content module "onboarding" in target service "workflow"... Skipping deletion of services, because the command line option "--delete-services" is not specified. Process finished. Use "cf dmol -i f450e444-8632-11ea-abb3-eeee0a8f6ba7" to download the logs of the process.
I’d say that the ability to monitor ongoing MTA operations in the terminal, regardless of where the operation was initiated, is pretty neat. Wouldn’t you?
If this has whetted your appetite, read the next post in this collection: Terminal Tip: a CF remote monitor script, which ties these things together into a neat little script.
Share & enjoy, and remember, TheFutureIsTerminal!