An automatic screenshot tool for application logging services.
2023-12-7 17:18:9 Author: blogs.sap.com(查看原文) 阅读量:8 收藏

After the service is up and running, we will often use Application Logging Service to check the CAP application logs and check the CPU usage rate and memory usage rate. Customers often ask us to report the operating status regularly. (Bothersome)

Application Logging Service is only saved for 7 days, and checking it every day is a pain.

It’s a pain to check it every day, and I often forget about it, so I created a tool that automatically captures and saves the memory changes of the Application Logging Service.
By using this tool, you can capture and save the memory history of your CAP application at a fixed time every day.

The created tool has been uploaded to GitHub.
https://github.com/unosistema/SAPBTPLoggingCapture

Prerequisites

  • The application is running in a CF environment.
  • The application and Application Logging Service are bound.
  • Creating a snapshot URL for the Application Logging Service (Step 0 of this article).
  • Installing Node.js

About Puppeteer (the library used in this program)

Puppeteer is a library that allows you to run Chrome without displaying a screen from Node.js.
You can scrape, type on the screen, press buttons, and take screenshots while running Chrome without a screen.
If you are interested, please search for “headless browser”.

0.Creating a snapshot URL

Let’s create a snapshot URL with Application Logging Service.

Access the Application Logging Service.

This time, we want to see the memory usage graph, so we’ll switch the graph to display.

A graph of CPU and memory trends was displayed.
Change the conditions so that we can check the changes over the past 24 hours.

A snapshot URL like the one below will be generated.
https://logs.cf.eu10-004.hana.ondemand.com/goto/(32 digit hash value)

We can check the memory usage for the past 24 hours just by accessing this snapshot URL directly.
Also, although I did not set a filter this time, the snapshot URL also remembers the filter settings.
Snapshot URL is very useful !!
However, I created a tool for people who find it troublesome/forgetful just to open their browser every day.

1.Download the program and partially rewrite it

https://github.com/unosistema/SAPBTPLoggingCapture

Please clone the program from the GitHub repository above and rewrite some of the programs.

Please rewrite the three variables in app.js

    • Snapshot URL (From Step 0)
    • SAP Universal ID(Email Address)
    • SAP Universal ID Password
// Change here!!
const btp_application_logging_snapshot_url = "xxxxxxxxxxxxxxxxxxxxxxx"; // ex. https://logs.cf.eu10-004.hana.ondemand.com/goto/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
const sap_username = "[email protected]"; // Your SAP UniversalID(e-mail)
const sap_password = "xxxxxxxxxxxx"; // Your SAP UniversalID Password

2.Installing the library

Open a command prompt or terminal, move to the program directory, and install the library using the command below.

npm install

3.Run the program

Run the program using the following command from the command prompt or terminal.

node app.js

Wait about a minute and a screenshot will be generated.

When you open the PNG file, you will see a screenshot of the graph for the past 24 hours.

Scheduling this program to run at regular intervals will definitely make operation and maintenance easier.

Just paste the captcha in the report materials to the customer.

In addition to Application Logging Service, it seems to have many uses, such as periodically taking screenshots of the HANA Cloud monitoring screen.


文章来源: https://blogs.sap.com/2023/12/07/an-automatic-screenshot-tool-for-application-logging-services./
如有侵权请联系:admin#unsafe.sh