Operations and Maintenance Choreography Scenario Series - Download JVM Stack to OSS

Keywords: Java jvm Jetty Linux

Scenario introduction

Jstack is used to generate thread snapshots of the current time of the java virtual machine. Thread snapshots are a collection of method stacks that are being executed by each thread in the current java virtual machine. The main purpose of generating thread snapshots is to locate the causes of long thread pauses, such as deadlocks between threads, deadlocks, long waiting caused by requesting external resources, etc. When a thread pauses, it can look through the call stack of each thread through jstack to see what the unresponsive thread is doing in the background or waiting for what resources. In actual operation, if each dump points to the same problem, we can determine the typicality of the problem. At this time, we need to download dump for analysis. This article mainly introduces downloading JVM stack to OSS through OOS.

Solution

We are going to prepare an ECS instance with JAVA and JETTY installed. The remote connection enters the management terminal. Start Jetty. View the JAVA process.


Log on to the OOS console. If you have never used the OOS service before, please click the "Open Now" button to open it at one click. OOS Operations and Maintenance Arrangement is a safe and free service, please be assured to open.


After opening, enter the Operations and Maintenance Choreography Interface, click on the Custom Template, and click the Create Template button.


Paste the template in the Yaml column of the Create Template page.

FormatVersion: OOS-2019-06-01
Dsacription: Download JVM dump to OSS.
Parameters:
  pid:
    Description: The ID of Process.
    Type: String
  jstackUrl:
    Description: Complete path of the jstack in linux instance.
    Type: String
  outputFile:
    Description: Complete path of the output file in linux instance.
    Type: String
  instanceId:
    Description: The ID of ECS Instance.
    Type: String
    MaxLength: 30
    MinLength: 1
  instanceRole:
    Description: The ramRole attached on the instance.
    Type: String
  destUrl:
    Description: Target directory for file copy in OSS.
    Type: String
  OOSAssumeRole:
    Description: The RAM role to be assumed by OOS.
    Type: String
    Default: OOSServiceRole
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: runcommnd
  Action: ACS::ECS::RunCommand
  Properties:
    commandContent: '{{ jstackUrl }}/jstack -l {{ pid }} > {{ outputFile }}'
    instanceId: '{{ instanceId }}'
    commandType: RunShellScript
- Name: copyInstanceFileToOSS
  Action: ACS::ECS::CopyLinuxInstanceFileToOSS
  Properties:
    instanceId: "{{ instanceId }}"
    instanceRole: "{{ instanceRole }}"
    srcUrl: "{{ outputFile }}"
    destUrl: "{{ destUrl }}"
  Outputs:
    result:
      Type: String
      ValueSelector: result
Outputs:
  result:
    Type: String
    Value: "{{ copyInstanceFileToOSS.result }}"

Enter the template name and click Create the template.


Find the newly created template on the custom template page, click Create Execution, select Auto Execution, and click Next.


The parameter settings page needs to enter the following parameters:

Description of parameters:

  • pid: java process ID
  • jstackUrl: The path of jstack
  • outputFile: The complete path of the file output by the stack in the instance
  • instanceId: Instance ID
  • instanceRole: The name of RAMRole mounted to the instance
  • destUrl: The path to the stack in OSS

After confirming that the parameters are correct, click Create Execution. On the Execution Details page, you can see the detailed process of template execution.


After execution, view stack files in OSS.


The contents of the stack file are as follows:

Welcome to OOS

OOS customer support nail group: 23330931
Links to the OOS Management Console
Links to OOS Help Documents

Series of articles

Thematic articles

Aliyun Heavy Release Cloud Automation Tool-Operations, Maintenance and Arrangement OOS

Best Practices

Permission to play transshipment maintenance choreography service: Assume Role+Pass Role

Scene Series

Operations and Maintenance Scheduling Scene Series - Updating ECS Mirror
Operation and Maintenance Scheduling Scene Series - - - Automatically typing TAG for ECS instances
Operations and Maintenance Choreography Scenario Series - Copying Files from Instances to OSS
Operations and Maintenance Scheduling Scene Series - Adding Instances to SLS Machine Group
Operation and Maintenance Scheduling Scene Series - Detecting MFA Functional Status
Ali Yun Operations and Maintenance Arrangement New Function: One-button Batch Cloning ECS
Operations and Maintenance Scheduling Scenario Series - Daily Statistics of the Operational Status of Multiple Region Instances
Operations and Maintenance Scheduling Scene Series - How to Use jq
Operations and Maintenance Scheduling Scene Series - Running commands on machines in batches

Posted by Ryanz on Fri, 06 Sep 2019 03:40:28 -0700