Arthas 3.1.2 版本发布 | 增加 logger/heapdump/vmoption 命令
最近偶尔有用户反馈某些 HTTP 接口出现超时问题,而 web 服务端的 Trace 监控没有出现 http 返回值为 503 等异常情况。出现这种情况一般是web容器出现问题,客户端连
Arthas是Alibaba开源的Java诊断工具,深受开发者喜爱。
Github:https://github.com/alibaba/arthas
文档:https://alibaba.github.io/arthas
Arthas 3.1.2版本持续增加新特性,下面重点介绍:
- logger/heapdump/vmoption/stop命令
- 通过tunnel server连接不同网络的arthas,方便统一管控
- 易用性持续提升:提示符修改为arthas@pid形式,支持ctrl + k清屏快捷键
logger/heapdump/vmoption/stop命令
logger命令
查看logger信息,更新logger level
https://alibaba.github.io/arthas/logger.html
查看所有logger信息
以下面的 logback.xml 为例:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="APPLICATION" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>app.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>mylog-%d{yyyy-MM-dd}.%i.txt</fileNamePattern>
<maxFileSize>100MB</maxFileSize>
<maxHistory>60</maxHistory>
<totalSizeCap>2GB</totalSizeCap>
</rollingPolicy>
<encoder>
<pattern>%logger{35} - %msg%n</pattern>
</encoder>
</appender>
<appender name="ASYNC" class="ch.qos.logback.classic.AsyncAppender">
<appender-ref ref="APPLICATION" />
</appender>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%-4relative [%thread] %-5level %logger{35} - %msg %n
</pattern>
<charset>utf8</charset>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="CONSOLE" />
<appender-ref ref="ASYNC" />
</root>
</configuration>
使用 logger 命令打印的结果是:
[arthas@2062]$ logger
name ROOT
class ch.qos.logback.classic.Logger
classLoader sun.misc.Launcher$AppClassLoader@2a139a55
classLoaderHash 2a139a55
level INFO
effectiveLevel INFO
additivity true
codeSource file:/Users/hengyunabc/.m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar
appenders name CONSOLE
class ch.qos.logback.core.ConsoleAppender
classLoader sun.misc.Launcher$AppClassLoader@2a139a55
classLoaderHash 2a139a55
target System.out
name APPLICATION
class ch.qos.logback.core.rolling.RollingFileAppender
classLoader sun.misc.Launcher$AppClassLoader@2a139a55
classLoaderHash 2a139a55
file app.log
name ASYNC
class ch.qos.logback.classic.AsyncAppender
classLoader sun.misc.Launcher$AppClassLoader@2a139a55
classLoaderHash 2a139a55
appenderRef [APPLICATION]
从appenders的信息里,可以看到
- CONSOLE logger的target是System.out
- APPLICATION logger是RollingFileAppender,它的file是app.log
- ASYNC它的appenderRef是APPLICATION,即异步输出到文件里
查看指定名字的logger信息
[arthas@2062]$ logger -n org.springframework.web
name org.springframework.web
class ch.qos.logback.classic.Logger
classLoader sun.misc.Launcher$AppClassLoader@2a139a55
classLoaderHash 2a139a55
level null
effectiveLevel INFO
additivity true
codeSource file:/Users/hengyunabc/.m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar
更新logger level
[arthas@2062]$ logger --name ROOT --level debug
update logger level success.
heapdump命令
dump java heap, 类似jmap命令的heap dump功能。
dump到指定文件
[arthas@58205]$ heapdump /tmp/dump.hprof
Dumping heap to /tmp/dump.hprof...
Heap dump file created
只dump live对象
[arthas@58205]$ heapdump --live /tmp/dump.hprof
Dumping heap to /tmp/dump.hprof...
Heap dump file created
vmoption命令
查看,更新VM诊断相关的参数
查看所有的option
[arthas@56963]$ vmoption
KEY VALUE ORIGIN WRITEABLE
---------------------------------------------------------------------------------------------
HeapDumpBeforeFullGC false DEFAULT true
HeapDumpAfterFullGC false DEFAULT true
HeapDumpOnOutOfMemory false DEFAULT true
Error
HeapDumpPath DEFAULT true
CMSAbortablePrecleanW 100 DEFAULT true
aitMillis
CMSWaitDuration 2000 DEFAULT true
CMSTriggerInterval -1 DEFAULT true
PrintGC false DEFAULT true
PrintGCDetails true MANAGEMENT true
PrintGCDateStamps false DEFAULT true
PrintGCTimeStamps false DEFAULT true
PrintGCID false DEFAULT true
PrintClassHistogramBe false DEFAULT true
foreFullGC
PrintClassHistogramAf false DEFAULT true
terFullGC
PrintClassHistogram false DEFAULT true
MinHeapFreeRatio 0 DEFAULT true
MaxHeapFreeRatio 100 DEFAULT true
PrintConcurrentLocks false DEFAULT true
查看指定的option
[arthas@56963]$ vmoption PrintGCDetails
KEY VALUE ORIGIN WRITEABLE
---------------------------------------------------------------------------------------------
PrintGCDetails false MANAGEMENT true
更新指定的option
[arthas@56963]$ vmoption PrintGCDetails true
Successfully updated the vm option.
PrintGCDetails=true
stop命令
之前有用户吐槽,不小心退出Arthas console之后,shutdown会关闭系统,因此增加了stop命令来退出arthas,功能和shutdown命令一致。
通过tunnel server连接不同网络的arthas
在新版本里,增加了arthas tunnel server的功能,用户可以通过tunnel server很方便连接不同网络里的arthas agent,适合做统一管控。
启动arthas时连接到tunnel server
在启动arthas,可以传递--tunnel-server参数,比如:
as.sh --tunnel-server 'ws://47.75.156.201:7777/ws'
目前47.75.156.201是一个测试服务器,用户可以自己搭建arthas tunnel server
如果有特殊需求,可以通过--agent-id参数里指定agentId。默认情况下,会生成随机ID。
attach成功之后,会打印出agentId,比如:
,---. ,------. ,--------.,--. ,--. ,---. ,---.
/ O \ | .--. ''--. .--'| '--' | / O \ ' .-'
| .-. || '--'.' | | | .--. || .-. |`. `-.
| | | || |\ \ | | | | | || | | |.-' |
`--' `--'`--' '--' `--' `--' `--'`--' `--'`-----'
wiki https://alibaba.github.io/arthas
tutorials https://alibaba.github.io/arthas/arthas-tutorials
version 3.1.2
pid 86183
time 2019-08-30 15:40:53
id URJZ5L48RPBR2ALI5K4V
如果是启动时没有连接到 tunnel server,也可以在后续自动重连成功之后,通过 session命令来获取 agentId:
[arthas@86183]$ session
Name Value
-----------------------------------------------------
JAVA_PID 86183
SESSION_ID f7273eb5-e7b0-4a00-bc5b-3fe55d741882
AGENT_ID URJZ5L48RPBR2ALI5K4V
TUNNEL_SERVER ws://47.75.156.201:7777/ws
以上面的为例,在浏览器里访问 http://47.75.156.201:8080/ ,输入 agentId,就可以连接到本机上的arthas了。
Arthas tunnel server的工作原理
browser <-> arthas tunnel server <-> arthas tunnel client <-> arthas agent
https://github.com/alibaba/arthas/blob/master/tunnel-server/README.md
易用性持续提升
提示符修改为arthas@pid形式,用户可以确定当前进程ID,避免多个进程时误操作
[arthas@86183]$ help
增加ctrl + k清屏快捷键
总结
总之,3.1.2版本的Arthas新增加了logger/heapdump/vmoption/stop命令,增加了tunnel server,方便统一管控。另外还有一些bug修复等,可以参考
Release Note
最后,Arthas的在线教程考虑重新组织,欢迎大家参与,提出建议,详情参考这里。
本文作者:中间件小哥
本文为云栖社区原创内容,未经允许不得转载。
Arthas 3.1.2 版本发布 | 增加 logger/heapdump/vmoption 命令的更多相关文章
- Java程序员的魔法杖-Arthas 3.1.2版本发布了
Arthas已经成为我日常运维.线上排查的必备之品,听说最近更新版本了,今天这篇文章看下又增加了什么新的能力. Arthas是Alibaba开源的Java诊断工具,深受开发者喜爱. Github:ht ...
- Java快速开发平台,JEECG 3.7.7闪电版本发布,增加多套主流UI代码生成器模板
JEECG 3.7.7 闪电版本发布,提供5套主流UI代码生成器模板 导读 ⊙平台性能优化,速度闪电般提升 ⊙提供5套新的主流UI代码生成器模板(Bootstrap表单+Boots ...
- xmake v2.1.9版本发布,增加可视化图形菜单配置
此版本主要增加xmake f --menu实现用户自定义图形菜单配置,界面风格类似linux的make menuconfig: [图片上传失败-(image-505bc0-1517795319124) ...
- CAP 5.2 版本发布通告
前言 今天,我们很高兴宣布 CAP 发布 5.2 版本正式版,在这个版本中,我们主要致力于更好的优化使用体验以及支持新的 Transport,同时在该版本也进行了一些 bug 修复的工作. 自从 5. ...
- EQueue 2.3.2版本发布(支持高可用)
前言 前段时间针对EQueue的完善终于告一段落了,实在值得庆祝,自己的付出和坚持总算有了成果.这次新版本主要为EQueue实现了集群功能,基本实现了Broker的高可用.另外还增加了很多实用的功能, ...
- OGG for DB2 z/OS 12.2版本发布
2016-04-15 Oracle发布了GoldenGate for DB2 z/OS 12.2.0.1.2.可以从OTN或eDelivery下载,该版本是ogg for DB2 z/OS的第一个1 ...
- 评论Final版本发布
1. 新蜂:俄罗斯方块 产品方面:俄罗斯方块在Beta版本基础上新增了许多功能,其中游戏中按A键可以开启瞄准,这个功能在市面上是具有先发优势的,算是一个较大的亮点:在改进了文字ui和方块的贴图以及游 ...
- RDIFramework.NET ━ .NET快速信息化系统开发框架 V2.8 版本发布
(新年巨献) RDIFramework.NET ━ .NET快速信息化系统开发框架 V2.8 版本发布 历时数月,RDIFramework.NET V2.8版本发布了,感谢大家的支持. RDIFram ...
- RDIFramework.NET ━ .NET快速信息化系统开发框架 V2.7 版本发布
历时数月,RDIFramework.NET V2.7 版本发布了,感谢大家的支持. RDIFramework.NET,基于.NET的快速信息化系统开发.整合框架,为企业或个人在.NET环境下快速开发系 ...
随机推荐
- Tk1上搭建turtlebot环境
sudo apt-get install ros-indigo-turtlebot ros-indigo-turtlebot-apps ros-indigo-turtlebot-interaction ...
- pandas--层次化索引
层次化索引是pandas的一项重要功能,它使你能在一个轴上拥有多个(两个以上)索引级别. 创建一个Series,并用一个由列表或数组组成的列表作为索引. data=Series(np.random.r ...
- netstat -pa --unix >>test.txt
netstat -pa --unix >>test.txt 输出套接字 命名socket信息
- zero udp
Description UDP transport can only be used with the ZMQ_RADIO and ZMQ_DISH socket types.
- 小波变换C代码
#include <stdio.h> #include <stdlib.h> #define LENGTH 512//信号长度 /*********************** ...
- Centos6.5 安装 LAMP
Centos 安装 LAMP 系统: Centos 6.5 Apache 2.4 + PHP 7.2 + Mysql 5.7 准备工作 centos 查看版本 查看 centos版本 How to C ...
- svg圆环缓冲动画
代码如下 <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8& ...
- 使用 async await 封装微信小程序HTTP请求
1. 编写将普通回调函数形式的方法转换为promise方法的promisic方法 // util.js const promisic = function (func) { return functi ...
- Kafka Streams详细
概述 1 Kafka Streams Kafka Streams.Apache Kafka开源项目的一个组成部分.是一个功能强大,易于使用的库.用于在Kafka上构建高可分布式.拓展性,容错的应用程序 ...
- NX二次开发-删除功能区工具栏UF_UI_remove_ribbon
NX9+VS2012 1.打开D:\Program Files\Siemens\NX 9.0\UGII\menus\ug_main.men 找到装配和PMI,在中间加上一段 TOGGLE_BUTTON ...