Arthas(阿尔萨斯)--(四)

一、Arthas学习

1、Arthas学习

1、options

options:全局开关

名称 默认值 描述
unsafe false 是否支持对系统级别的类进行增强,打开该开关可能导致把 JVM 搞挂,请慎重选择!
dump false 是否支持被增强了的类 dump 到外部文件中,如果打开开关,class 文件会被 dump 到/${application working dir}/arthas-class-dump/目录下,具体位置详见控制台输出
batch-re-transform true 是否支持批量对匹配到的类执行 retransform 操作
json-format false 是否支持 json 化的输出
disable-sub-class false 是否禁用子类匹配,默认在匹配目标类的时候会默认匹配到其子类,如果想精确匹配,可以关闭此开关
support-default-method true 是否支持匹配到 default method, 默认会查找 interface,匹配里面的 default method。
save-result false 是否打开执行结果存日志功能,打开之后所有命令的运行结果都将保存到~/logs/arthas-cache/result.log
job-timeout 1d 异步后台任务的默认超时时间,超过这个时间,任务自动停止;比如设置 1d, 2h, 3m, 25s,分别代表天、小时、分、秒
print-parent-fields true 是否打印在 parent class 里的 filed
verbose false 是否打印更多详细信息
strict true 是否启用 strict 模式


 

//查看所有的 options
[arthas@7996]$ options
 LEVEL    TYPE    NAME             VALUE    SUMMARY                  DESCRIPTION
-----------------------------------------------------------------------------------------------------------------------
 0        boolea  unsafe           false    Option to support syste  This option enables to proxy functionality of JVM
          n                                 m-level class             classes. Due to serious security risk a JVM cras
                                                                     h is possibly be introduced. Do not activate it u
                                                                     nless you are able to manage.
 1        boolea  dump             false    Option to dump the enha  This option enables the enhanced classes to be du
          n                                 nced classes             mped to external file for further de-compilation
                                                                     and analysis.
 1        boolea  batch-re-transf  true     Option to support batch  This options enables to reTransform classes with
          n       orm                        reTransform Class       batch mode.
 2        boolea  json-format      false    Option to support JSON   This option enables to format object output with
          n                                 format of object output  JSON when -x option selected.
 1        boolea  disable-sub-cla  false    Option to control inclu  This option disable to include sub class when mat
          n       ss                        de sub class when class  ching class.
                                             matching
 1        boolea  support-default  true     Option to control inclu  This option disable to include default method in
          n       -method                   de default method in in  interface when matching class.
                                            terface when class matc
                                            hing
 1        boolea  save-result      false    Option to print command  This option enables to save each command's result
          n                                 's result to log file     to log file, which path is ${user.home}/logs/art
                                                                     has-cache/result.log.
 2        String  job-timeout      1d       Option to job timeout    This option setting job timeout,The unit can be d
                                                                     , h, m, s for day, hour, minute, second. 1d is on
                                                                     e day in default
 1        boolea  print-parent-fi  true     Option to print all fil  This option enables print files in parent class,
          n       elds                      eds in parent class      default value true.
 1        boolea  verbose          false    Option to print verbose  This option enables print verbose information, de
          n                                  information             fault value false.
 1        boolea  strict           true     Option to strict mode    By default, strict mode is true, not allowed to s
          n                                                          et object properties. Want to set object properti
                                                                     es, execute `options strict false`
//获取 option 的值
[arthas@7996]$ options json-format
 LEVEL    TYPE    NAME             VALUE    SUMMARY                  DESCRIPTION
-----------------------------------------------------------------------------------------------------------------------
 2        boolea  json-format      false    Option to support JSON   This option enables to format object output with
          n                                 format of object output  JSON when -x option selected.
//设置指定的 option
[arthas@7996]$ options save-result true
 NAME         BEFORE-VALUE  AFTER-VALUE
----------------------------------------
 save-result  false         true

2、profiler火焰图

profiler生成火焰图

profiler 命令支持生成应用热点的火焰图。本质上是通过不断的采样,然后把收集到的采样结果生成火焰图

profiler 命令基本运行结构是 profiler action [actionArg]

参数名称 参数说明
action 要执行的操作
actionArg 属性名模式
[i:] 采样间隔(单位:ns)(默认值:10'000'000,即 10 ms)
[f:] 将输出转储到指定路径
[d:] 运行评测指定秒
[e:] 要跟踪哪个事件(cpu, alloc, lock, cache-misses 等),默认是 cpu
//启动 profiler
$ profiler start
Started [cpu] profiling

Arthas(阿尔萨斯)--(一)

Arthas(阿尔萨斯)--(三)

一个程序员最重要的能力是:写出高质量的代码!!
有道无术,术尚可求也,有术无道,止于术。
无论你是年轻还是年长,所有程序员都需要记住:时刻努力学习新技术,否则就会被时代抛弃!

你可能感兴趣的:(JVM学习,java)