Skip to Content
Technical Articles

Max’s Adventure in SAP Cloud Platform: Pimp my Cloud Foundry CLI (2/x)

In the following blog post, I would like to present another CLI plugin for the Cloud Foundry CLI called “top” after I already introduced one of the central plugins in the SAP context in my previous blog post: The multiapps plugin.

To put the plugins into context: The multiapps plugin, which I have described and demonstrated in the previous blog post, deals with the general deployment of complex, interrelated applications as Multi-Target Applications. The following plugin is intended for the time when the deployment has already been completed – as part of frequently called “day2-operations”. Not as your primary tool, but helpful for developers.

Some community plugins are listed on the corresponding plugins page of Cloud Foundry: https://plugins.cloudfoundry.org/.

As-Is situation

What do you usually want to do once a deployment was successful? Having a look if everything has actually “arrived” in your space, if all the apps are started and how they behave, is something I do typically initially.

It is usually relatively difficult to keep track of the deployed apps, services, and their metrics or attributes after the deployment happened using the standard CF CLI commands. To understand the added value of the plugin I want to introduce to you, let’s take a brief look at the procedure without the plugin.

For example, to monitor how much of the allocated memory a single app is already using, two commands are required.

cf apps

Lists all existing apps, including some high-level information in your current space (memory, disk, URL, state), which is usually not sufficient for a more detailed analysis. Therefore, it is no less often essential to know the exact status of an application via the detailed view of one particular app. But for this you need the exact app name, which I seldomly remember. That’s why the entry point via cf apps is widespread.

cf app [app_name]

Enables a detailed view on one particular app and gives a little more information (status and health) about it. For instance: how much memory of the allocated value the app uses, when was the app last updated and which technical artifacts the app uses – for example, which docker image or buildpack the application is using.

The path to detailed information about a single app is correspondingly long and also not yet complete. In addition, the data is static and not automatically updated and but merely reflects the status at the time of execution.

Most significant pain: To type and execute all of the above commands manually. Whenever you want to display a different app or if you want to have updated information about an app/service.

We wouldn’t be here if I wouldn’t have anything for you: The top-plugin provides a remedy.

top plugin

The official description of the plugin already gives you a good idea of what the plugin does better than the standard CF CLI commands:

“This is a Cloud Foundry command-line cf interactive plugin for showing live statistics of the targeted Cloud Foundry foundation. The live statistics include application statistics and route statistics among others. The primary source of information that the top plugin uses is via monitoring the Cloud Foundry firehose.”

Live. statistics. Not very surprisingly, where the name of the plugin comes from. The description is quite similar to the Unix command top, isn’t it?

Image: booleanworld.com

You can simply navigate through all your apps (no services!) with your cursor, which is a super convenient approach compared to typing the exact app name over and over again without the plugin. Interactively monitoring a particular app and how it behaves while you test it. You can get more details about incoming requests, what kind of responses it produces (HTTP 2xx, HTTP 3xx, HTTP 4xx, HTTP 5xx), how much memory and disk it uses – without manually refreshing anything.

Mostly even without continually polling the Cloud Foundry environment for new information and burdening it with countless requests in the background. As emphasized in the official description, most information comes from the so-called Cloud Foundry Firehose, which is very interesting, apart from the actual topic.

Firehose: The Firehose is a WebSocket endpoint that streams all the event data from a Cloud Foundry deployment. The data stream includes HTTP events, app logs, container metrics from apps, and metrics from Cloud Foundry platform components. The Firehose cf CLI plugin allows you to view the output of the Firehose. For more information about the Firehose plugin, seeĀ Installing the Loggregator Firehose Plugin for cf CLI.“, so the official Cloud Foundry documentation.

Plugin demonstration

But finally, let’s have a look at the plugin. Therefore I have recorded a video. How should one demonstrate an interactive plugin in a non-interactive format like a blog post?

Installation

Adding the plugin to your CF CLI is fairly simple. Add the plugin repository (optional, if already done):

cf add-plugin-repo CF-Community https://plugins.cloudfoundry.org

Followed by installing the actual plugin itself.

cf install-plugin top

Have you ever used this particular plugin? Which other plugins do you use?

Be the first to leave a comment
You must be Logged on to comment or reply to a post.