arthas idea plugin plug-ins, arthas use more silk slip up

I. Background

Currently Arthas official tool is not enough simple enough to remember some commands, especially some particularly strong expansion of high-level syntax, such as ognl get spring context do whatever they want, watch, trace simple enough, some of the information necessary to construct a command tool, so plug only need a simple string handling information can be used. When you need the fastest line in dealing with the problem, the most convenient commands, so Idea arthas plug-in or the presence of meaning and value.

Second, support functions

Supported features are usually treated most commonly used features, some quick links to deal with urgent problems in time do not need to look around, are some of the basic functions, automatically copied to the clipboard to go quick and easy.
[Image dump the chain fails, the source station may have security chain mechanism, it is recommended to save the picture down uploaded directly (img-cnt72s5t-1579489232408) ( ./ arthas idea plugin plug, Arthas used to silky up / format, png # align = left & display = inline & height = 286 & name = image-20200119120930544.png & originHeight = 572 & originWidth = 1074 & size = 241010 & status = done & style = none & width = 537)]

Here Insert Picture Description

2.1 watch

[Image dump the chain fails, the source station may have security chain mechanism, it is recommended to save the picture down uploaded directly (img-B4UR3lc3-1579489232409) (./ arthas idea plugin plug, Arthas used to silky up / format, png # align = left & display = inline & height = 230 & name = image-20200119120931284.png & originHeight = 460 & originWidth = 1570 & size = 326956 & status = done & style = none & width = 785)]

watch com.command.idea.plugin.utils.StringUtils toLowerFristChar '{params,returnObj,throwExp}' -n 5 -x 3
1

2.2 trace

2.2.1 Basic trace

trace com.command.idea.plugin.utils.StringUtils toLowerFristChar -n 5
1

2.2.2 trace -E

trace command only trace to match a function call in the child, and does not trace a multi-layer down. Because the trace is the price more expensive, multi-layer trace may lead eventually to trace classes and functions very much. Therefore Arthas official support trace -E get more special, the plug-in to support what trace -E

[Image dump the chain fails, the source station may have security chain mechanism, it is recommended to save the picture down uploaded directly (img-7Dq2z0z6-1579489232410) (./ arthas idea plugin plug, Arthas used to silky up / format, png # align = left & display = inline & height = 295 & name = image-20200119120931394.png & originHeight = 590 & originWidth = 1144 & size = 283907 & status = done & style = none & width = 572)]

trace -E com.github.wangji92.arthas.plugin.utils.ClipboardUtils|com.github.wangji92.arthas.plugin.utils.OgnlPsUtils getClassBeanName|setClipboardString -n 5
1

[Image dump the chain fails, the source station may have security chain mechanism, it is recommended to save the picture down uploaded directly (img-aFnbGISH-1579489232410) (./ arthas idea plugin plug, Arthas used to silky up / format, png # align = left & display = inline & height = 140 & name = image-20200119120930968.png & originHeight = 280 & originWidth = 1086 & size = 175088 & status = done & style = none & width = 543)]

2.3 static ognl (field or method)

[Image dump the chain fails, the source station may have security chain mechanism, it is recommended to save the picture down uploaded directly (img-0DptejIm-1579489232410) (./ arthas idea plugin plug, Arthas used to silky up / format, png # align = left & display = inline & height = 234 & name = image-20200119120931185.png & originHeight = 468 & originWidth = 1410 & size = 304620 & status = done & style = none & width = 705)]

2.3.1 Right-static ognl

2.3.2 obtain classload command

Must obtain, or will not find classload, arthas official to obtain classload system problems, spring project should not be able to get information about this class, so first of all about the implementation of this order

sc -d com.command.idea.plugin.utils.StringUtils
1

[Image dump the chain fails, the source station may have security chain mechanism, it is recommended to save the picture down uploaded directly (img-FWqp2xVl-1579489232411) (./ arthas idea plugin plug, Arthas used to silky up / format, png # align = left & display = inline & height = 196 & name = image-20200119120930527.png & originHeight = 392 & originWidth = 1346 & size = 218372 & status = done & style = none & width = 673)]

2.3.2 copied to the interface, get command, you can execute

[Image dump the chain fails, the source station may have security chain mechanism, it is recommended to save the picture down uploaded directly (img-FIGnmP4T-1579489232412) (./ arthas idea plugin plug, Arthas used to silky up / format, png # align = left & display = inline & height = 126 & name = image-20200119120930837.png & originHeight = 252 & originWidth = 1290 & size = 161506 & status = done & style = none & width = 645)]

ognl  -x  3  '@com.command.idea.plugin.utils.StringUtils@toLowerFristChar(" ")' -c 8bed358
1

2.4 Invoke Bean Method

This is actually obtain the spring based on the current project to obtain static spring context directly from the context of any direct method Bean, Java back-end services in general have such Utils class, so this can be seen as a constant! can refer to: http: //www.dcalabresi.com/blog/java/spring-context-static-class/ with this, we can carry on with further data reduction, since the idea of ​​this link, you can obtain the method parameter, spring bean name, and so on, very convenient.

public class ApplicationContextProvider implements ApplicationContextAware {
    
    private static ApplicationContext context;
 
    public ApplicationContext getApplicationContext() {
        return context;
    }
 
    @Override
    public void setApplicationContext(ApplicationContext ctx) {
        context = ctx;
    }
}
12345678910111213

2.4.1 set the context get spring context of

ps Here you can use @ applicationContextProvider @ context like this, such as line function call can also be used directly ognl comma-separated syntax can continue to perform, such as @ applicationContextProvider @ context, # springContext.getBean ( "name"). todo () We need to follow call any of the methods will be added in the interface on this sentence.

[Image dump the chain fails, the source station may have security chain mechanism, it is recommended to save the picture down uploaded directly (img-cixwIoFR-1579489232412) (./ arthas idea plugin plug, Arthas used to silky up / format, png # align = left & display = inline & height = 701 & name = image-20200119120930870.png & originHeight = 1402 & originWidth = 2152 & size = 547914 & status = done & style = none & width = 1076)]

2.4.2 Right-click on the need to call

The strategy here and static ognl the same, in essence, is the call ognl.
[Image dump the chain fails, the source station may have security chain mechanism, it is recommended to save the picture down uploaded directly (img-AaQuVxht-1579489232413) ( ./ arthas idea plugin plug, Arthas used to silky up / format, png # align = left & display = inline & height = 191 & name = image-20200119120931351.png & originHeight = 382 & originWidth = 1632 & size = 318255 & status = done & style = none & width = 816)]

ognl  -x  3  '#springContext=@applicationContextProvider@context,#springContext.getBean("arthasInstallCommandAction").actionPerformed(new com.intellij.openapi.actionSystem.AnActionEvent())' -c desw22
1

Special Note

Too complicated parameter is not applicable to online diagnosis for the problem, so the method parameters as simple as possible, a set of rules here, because the syntax similar to Java and ognl, acquiring the parameters of time will be the default parameter configuration process .
String -> ""
Number The, Byte, Char -> 0
the Map -> {# "": ""} Syntax OGNL
List -> {}
array int [] -> new new int [] {}
OTHER - -> new XXXClass () parameters default too complicated a direct new
Special your arguments may be obtained from springContext, you can modify the expression
..., # newParam = # springContext.getBean ( "beanName") todo (),. # springContext.getBean ( "other"). to (#newParam)
so used to define the parameters of your bash script, as this is a special usage, does not have general versatility

2.5 install(linux)

Installation script, you can as.sh a key execution

curl -sk https://arthas.gitee.io/arthas-boot.jar -o ~/.arthas-boot.jar  && echo "alias as.sh='java -jar ~/.arthas-boot.jar --repo-mirror aliyun --use-http'" >> ~/.bashrc && source ~/.bashrc
1

[Image dump the chain fails, the source station may have security chain mechanism, it is recommended to save the picture down uploaded directly (img-0O7zrdp7-1579489232413) (./ arthas idea plugin plug, Arthas used to silky up / format, png # align = left & display = inline & height = 257 & name = image-20200119120931319.png & originHeight = 514 & originWidth = 2060 & size = 649699 & status = done & style = none & width = 1030)]

2.6 Special common usage link

Third, other

3.1 Installation

[Image dump the chain fails, the source station may have security chain mechanism, it is recommended to save the picture down uploaded directly (img-CgVLtl0W-1579489232414) (./ arthas idea plugin plug, Arthas used to silky up / format, png # align = left & display = inline & height = 173 & name = image-20200119120931225.png & originHeight = 346 & originWidth = 756 & size = 133740 & status = done & style = none & width = 378)]

3.2 shortcut set

Here Insert Picture Description

3.3 code address

https://github.com/WangJi92/arthas-idea-plugin

3.4 plug-in development, publishing

Reference Plug-in Development: https://www.jianshu.com/p/722841c6d0a9
you can see the zip package compiled a
[picture outside the chain dump fails, the source station may have a security chain mechanism, it is recommended to save the pictures uploaded directly down (img-iBZ1C5Gh-1579489232415) ( ./ arthas idea plugin plug, arthas use up to silky /format,png#align=left&display=inline&height=273&name=image-20200119120931522.png&originHeight=546&originWidth=908&size=347771&status=done&style=none&width= 454)]

Fourth, Download

https://plugins.jetbrains.com/plugin/13581-arthas-idea, direct search arthas to download, idea official plug-in

Transfer: ./arthas IDEA plugin plug-ins, arthas use more silk slip up

Published 508 original articles · won praise 2162 · Views 1.79 million +

Guess you like

Origin blog.csdn.net/dataiyangu/article/details/104049175