arthas简单应用

news2024/9/28 16:37:48

背景说明

项目上某个接口响应时间过长,需要查看方法耗时情况进行优化

安装配置

  • 访问下载页进行下载:下载 | arthas

  • 调整文件位置进行解压缩

- 查看arthas帮助命令(非必须,官网文档更详细)

C:\tools\arthas\4.0.1\bin>java -jar arthas-boot.jar -h
[INFO] JAVA_HOME: C:\Program Files\Java\jre-1.8
[INFO] arthas-boot version: 4.0.1
Usage: arthas-boot [--use-http] [--repo-mirror <value>] [--stat-url <value>]
       [--select <value>] [--app-name <value>] [--tunnel-server <value>]
       [--height <value>] [--username <value>] [--agent-id <value>] [--width
       <value>] [--password <value>] [-v] [--target-ip <value>] [--arthas-home
       <value>] [--telnet-port <value>] [-h] [--http-port <value>] [--versions]
       [-c <value>] [--use-version <value>] [--attach-only] [-f <value>]
       [--session-timeout <value>] [--disabled-commands <value>] [pid]

Bootstrap Arthas

NOTE: Arthas 4 supports JDK 8+. If you need to diagnose applications running on
JDK 6/7, you can use Arthas 3.

EXAMPLES:
  java -jar arthas-boot.jar <pid>
  java -jar arthas-boot.jar --telnet-port 9999 --http-port -1
  java -jar arthas-boot.jar --username admin --password <password>
  java -jar arthas-boot.jar --tunnel-server 'ws://192.168.10.11:7777/ws'
--app-name demoapp
  java -jar arthas-boot.jar --tunnel-server 'ws://192.168.10.11:7777/ws'
--agent-id bvDOe8XbTM2pQWjF4cfw
  java -jar arthas-boot.jar --stat-url 'http://192.168.10.11:8080/api/stat'
  java -jar arthas-boot.jar -c 'sysprop; thread' <pid>
  java -jar arthas-boot.jar -f batch.as <pid>
  java -jar arthas-boot.jar --use-version 4.0.1
  java -jar arthas-boot.jar --versions
  java -jar arthas-boot.jar --select math-game
  java -jar arthas-boot.jar --session-timeout 3600
  java -jar arthas-boot.jar --attach-only
  java -jar arthas-boot.jar --disabled-commands stop,dump
  java -jar arthas-boot.jar --repo-mirror aliyun --use-http
WIKI:
  https://arthas.aliyun.com/doc

Options and Arguments:
    --use-http                    Enforce use http to download, default use
                                  https
    --repo-mirror <value>         Use special remote repository mirror, value is
                                  center/aliyun or http repo url.
    --stat-url <value>            The report stat url
    --select <value>              select target process by classname or
                                  JARfilename
    --app-name <value>            The app name
    --tunnel-server <value>       The tunnel server url
    --height <value>              arthas-client terminal height
    --username <value>            The username
    --agent-id <value>            The agent id register to tunnel server
    --width <value>               arthas-client terminal width
    --password <value>            The password
 -v,--verbose                     Verbose, print debug info.
    --target-ip <value>           The target jvm listen ip, default 127.0.0.1
    --arthas-home <value>         The arthas home
    --telnet-port <value>         The target jvm listen telnet port, default
                                  3658
 -h,--help                        Print usage
    --http-port <value>           The target jvm listen http port, default 8563
    --versions                    List local and remote arthas versions
 -c,--command <value>             Command to execute, multiple commands
                                  separated by ;
    --use-version <value>         Use special version arthas
    --attach-only                 Attach target process only, do not connect
 -f,--batch-file <value>          The batch file to execute
    --session-timeout <value>     The session timeout seconds, default 1800
                                  (30min)
    --disabled-commands <value>   disable some commands
 <pid>
  • 启动arthas

进入arthas-boot所在目录

C:\tools\arthas\4.0.1\bin>java -jar arthas-boot.jar
[INFO] JAVA_HOME: C:\Program Files\Java\jre-1.8
[INFO] arthas-boot version: 4.0.1
[INFO] Found existing java process, please choose one and input the serial number of the process, eg : 1. Then hit ENTER.
* [1]: 3296 org.jetbrains.idea.maven.server.RemoteMavenServer36
  [2]: 20068 org.jetbrains.idea.maven.server.indexer.MavenServerIndexerMain
  [3]: 8004 org.jetbrains.jps.cmdline.Launcher
  [4]: 28632

备注

在linux服务器上也可以直接执行以下命令下载arthas-boot,使用方式是一样的

curl -O https://arthas.aliyun.com/arthas-boot.jar

测试arthas相关命令

在实际的开发过程中,比较常用的命令有trace以及watch

trace

  • 启动测试程序,代码如下

ArthasController

package com.learn.demo.api.controller;

import com.learn.demo.app.service.ArthasTestService;
import com.learn.demo.config.SwaggerTags;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author PC
 */
@Api(SwaggerTags.ARTHAS)
@RestController("arthasController.v1")
@RequestMapping(value = "/v1/arthas")
public class ArthasController {

    private final ArthasTestService arthasTestService;

    @Autowired
    public ArthasController(ArthasTestService arthasTestService) {
        this.arthasTestService = arthasTestService;
    }


    @ApiOperation(value = "trace")
    @GetMapping(value = "/trace")
    public void testTrace() {
        arthasTestService.testTrace();
    }
}

ArthasTestServiceImpl

package com.learn.demo.app.service.impl;

import com.learn.demo.app.service.ArthasTestService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

/**
 * @author PC
 * @description arthas命令测试
 */
@Service
public class ArthasTestServiceImpl implements ArthasTestService {
    private final static Logger logger = LoggerFactory.getLogger(ArthasTestServiceImpl.class);

    @Override
    public void testTrace() {
        try {
            this.sleep2Sec();
            this.sleep3Sec();
            this.sleep5Sec();
        } catch (InterruptedException interruptedException) {
            logger.error("error:", interruptedException);
        }

    }

    private void sleep5Sec() throws InterruptedException {
        this.sleep2Sec();
        this.sleep3Sec();
    }

    private void sleep3Sec() throws InterruptedException {
        Thread.sleep(3000);
    }

    private void sleep2Sec() throws InterruptedException {
        Thread.sleep(2000);
    }
}
  • 启动arthas
C:\tools\arthas\4.0.1\bin>java -jar arthas-boot.jar
[INFO] JAVA_HOME: C:\Program Files\Java\jre-1.8
[INFO] arthas-boot version: 4.0.1
[INFO] Process 29788 already using port 3658
[INFO] Process 29788 already using port 8563
[INFO] Found existing java process, please choose one and input the serial number of the process, eg : 1. Then hit ENTER.
* [1]: 29788 com.learn.demo.DemoApplication
  [2]: 3296 org.jetbrains.idea.maven.server.RemoteMavenServer36
  [3]: 20068 org.jetbrains.idea.maven.server.indexer.MavenServerIndexerMain
  [4]: 8004 org.jetbrains.jps.cmdline.Launcher
  [5]: 28632

  • 选择服务
1
[INFO] arthas home: C:\tools\arthas\4.0.1\bin
[INFO] The target process already listen port 3658, skip attach.
[INFO] arthas-client connect 127.0.0.1 3658
  ,---.  ,------. ,--------.,--.  ,--.  ,---.   ,---.
 /  O  \ |  .--. ''--.  .--'|  '--'  | /  O  \ '   .-'
|  .-.  ||  '--'.'   |  |   |  .--.  ||  .-.  |`.  `-.
|  | |  ||  |\  \    |  |   |  |  |  ||  | |  |.-'    |
`--' `--'`--' '--'   `--'   `--'  `--'`--' `--'`-----'

wiki       https://arthas.aliyun.com/doc
tutorials  https://arthas.aliyun.com/doc/arthas-tutorials.html
version    4.0.1
main_class
pid        29788
time       2024-09-26 17:04:32.494
  • 监听ArthasTestServiceImpl
[arthas@29788]$ trace com.learn.demo.app.service.impl.ArthasTestServiceImpl testTrace
Press Q or Ctrl+C to abort.
Affect(class count: 1 , method count: 1) cost in 63 ms, listenerId: 1
  • 访问接口,查看结果

`---ts=2024-09-26 17:16:43.672;thread_name=http-nio-8090-exec-2;id=35;is_daemon=true;priority=5;TCCL=org.springframework.boot.web.embedded.tomcat.TomcatEmbeddedWebappClassLoader@60aec68a
    `---[10030.9174ms] com.learn.demo.app.service.impl.ArthasTestServiceImpl:testTrace()
        +---[20.05% 2010.9733ms ] com.learn.demo.app.service.impl.ArthasTestServiceImpl:sleep2Sec() #19
        +---[30.04% 3012.9335ms ] com.learn.demo.app.service.impl.ArthasTestServiceImpl:sleep3Sec() #20
        `---[49.91% 5006.6693ms ] com.learn.demo.app.service.impl.ArthasTestServiceImpl:sleep5Sec() #21

从以上结果可以看到,虽然sleep5Sec中有两个方法,但是并没有再往下跟踪,如果还想往下跟踪,可以使用-E搭配正则表达式匹配多个类,如下

[arthas@29788]$  trace -E com.learn.demo.app.service.impl.ArthasTestServiceImpl testTrace|sleep5Sec
Press Q or Ctrl+C to abort.
Affect(class count: 1 , method count: 2) cost in 36 ms, listenerId: 4
`---ts=2024-09-26 17:22:51.887;thread_name=http-nio-8090-exec-6;id=39;is_daemon=true;priority=5;TCCL=org.springframework.boot.web.embedded.tomcat.TomcatEmbeddedWebappClassLoader@60aec68a
    `---[10049.2604ms] com.learn.demo.app.service.impl.ArthasTestServiceImpl:testTrace()
        +---[20.01% 2011.2037ms ] com.learn.demo.app.service.impl.ArthasTestServiceImpl:sleep2Sec() #19
        +---[29.96% 3010.5075ms ] com.learn.demo.app.service.impl.ArthasTestServiceImpl:sleep3Sec() #20
        `---[50.03% 5027.4925ms ] com.learn.demo.app.service.impl.ArthasTestServiceImpl:sleep5Sec() #21
            `---[100.00% 5027.4495ms ] com.learn.demo.app.service.impl.ArthasTestServiceImpl:sleep5Sec()
                +---[40.05% 2013.6029ms ] com.learn.demo.app.service.impl.ArthasTestServiceImpl:sleep2Sec() #29
                `---[59.94% 3013.699ms ] com.learn.demo.app.service.impl.ArthasTestServiceImpl:sleep3Sec() #30

还可以通过以下命令匹配所有方法(实际使用中不推荐)

[arthas@29788]$  trace -E com.learn.demo.app.service.impl.ArthasTestServiceImpl ^.*$
Press Q or Ctrl+C to abort.
Affect(class count: 1 , method count: 5) cost in 36 ms, listenerId: 6
`---ts=2024-09-26 17:26:02.369;thread_name=http-nio-8090-exec-9;id=42;is_daemon=true;priority=5;TCCL=org.springframework.boot.web.embedded.tomcat.TomcatEmbeddedWebappClassLoader@60aec68a
    `---[10030.386ms] com.learn.demo.app.service.impl.ArthasTestServiceImpl:testTrace()
        +---[20.04% 2010.014ms ] com.learn.demo.app.service.impl.ArthasTestServiceImpl:sleep2Sec() #19
        |   `---[100.00% 2009.9902ms ] com.learn.demo.app.service.impl.ArthasTestServiceImpl:sleep2Sec()
        +---[29.99% 3008.4957ms ] com.learn.demo.app.service.impl.ArthasTestServiceImpl:sleep3Sec() #20
        |   `---[100.00% 3008.4593ms ] com.learn.demo.app.service.impl.ArthasTestServiceImpl:sleep3Sec()
        `---[49.97% 5011.8321ms ] com.learn.demo.app.service.impl.ArthasTestServiceImpl:sleep5Sec() #21
            `---[100.00% 5011.8071ms ] com.learn.demo.app.service.impl.ArthasTestServiceImpl:sleep5Sec()
                +---[40.01% 2005.0631ms ] com.learn.demo.app.service.impl.ArthasTestServiceImpl:sleep2Sec() #29
                |   `---[100.00% 2005.0008ms ] com.learn.demo.app.service.impl.ArthasTestServiceImpl:sleep2Sec()
                `---[59.99% 3006.7124ms ] com.learn.demo.app.service.impl.ArthasTestServiceImpl:sleep3Sec() #30
                    `---[100.00% 3006.688ms ] com.learn.demo.app.service.impl.ArthasTestServiceImpl:sleep3Sec()

如果想要包含jdk的方法调用,可以使用--skipJDKMethod false

[arthas@29788]$ trace -E com.learn.demo.app.service.impl.ArthasTestServiceImpl ^.*$  --skipJDKMethod false
Press Q or Ctrl+C to abort.
Affect(class count: 1 , method count: 5) cost in 58 ms, listenerId: 8
`---ts=2024-09-26 17:31:33.874;thread_name=http-nio-8090-exec-1;id=34;is_daemon=true;priority=5;TCCL=org.springframework.boot.web.embedded.tomcat.TomcatEmbeddedWebappClassLoader@60aec68a
    `---[10021.9275ms] com.learn.demo.app.service.impl.ArthasTestServiceImpl:testTrace()
        +---[19.96% 2000.6579ms ] com.learn.demo.app.service.impl.ArthasTestServiceImpl:sleep2Sec() #19
        |   `---[100.00% 2000.6237ms ] com.learn.demo.app.service.impl.ArthasTestServiceImpl:sleep2Sec()
        |       `---[100.00% 2000.5922ms ] java.lang.Thread:sleep() #38
        +---[30.00% 3006.6054ms ] com.learn.demo.app.service.impl.ArthasTestServiceImpl:sleep3Sec() #20
        |   `---[99.99% 3006.4251ms ] com.learn.demo.app.service.impl.ArthasTestServiceImpl:sleep3Sec()
        |       `---[100.00% 3006.3974ms ] java.lang.Thread:sleep() #34
        `---[50.04% 5014.4843ms ] com.learn.demo.app.service.impl.ArthasTestServiceImpl:sleep5Sec() #21
            `---[100.00% 5014.4558ms ] com.learn.demo.app.service.impl.ArthasTestServiceImpl:sleep5Sec()
                +---[40.09% 2010.5047ms ] com.learn.demo.app.service.impl.ArthasTestServiceImpl:sleep2Sec() #29
                |   `---[100.00% 2010.4748ms ] com.learn.demo.app.service.impl.ArthasTestServiceImpl:sleep2Sec()
                |       `---[100.00% 2010.4551ms ] java.lang.Thread:sleep() #38
                `---[59.91% 3003.9176ms ] com.learn.demo.app.service.impl.ArthasTestServiceImpl:sleep3Sec() #30
                    `---[100.00% 3003.8823ms ] com.learn.demo.app.service.impl.ArthasTestServiceImpl:sleep3Sec()
                        `---[100.00% 3003.8513ms ] java.lang.Thread:sleep() #34

如果想要捕获到n次就退出跟踪,可以使用-n,例如-n指定为1(默认为100),访问一次后就不再跟踪

[arthas@29788]$ trace -E com.learn.demo.app.service.impl.ArthasTestServiceImpl ^.*$  -n 1 --skipJDKMethod false
Press Q or Ctrl+C to abort.
Affect(class count: 1 , method count: 5) cost in 41 ms, listenerId: 9
`---ts=2024-09-26 17:38:15.346;thread_name=http-nio-8090-exec-3;id=36;is_daemon=true;priority=5;TCCL=org.springframework.boot.web.embedded.tomcat.TomcatEmbeddedWebappClassLoader@60aec68a
    `---[10022.2006ms] com.learn.demo.app.service.impl.ArthasTestServiceImpl:testTrace()
        +---[20.02% 2006.7205ms ] com.learn.demo.app.service.impl.ArthasTestServiceImpl:sleep2Sec() #19
        |   `---[100.00% 2006.7072ms ] com.learn.demo.app.service.impl.ArthasTestServiceImpl:sleep2Sec()
        |       `---[100.00% 2006.6909ms ] java.lang.Thread:sleep() #38
        +---[30.03% 3009.647ms ] com.learn.demo.app.service.impl.ArthasTestServiceImpl:sleep3Sec() #20
        |   `---[100.00% 3009.625ms ] com.learn.demo.app.service.impl.ArthasTestServiceImpl:sleep3Sec()
        |       `---[100.00% 3009.5833ms ] java.lang.Thread:sleep() #34
        `---[49.95% 5005.7963ms ] com.learn.demo.app.service.impl.ArthasTestServiceImpl:sleep5Sec() #21
            `---[100.00% 5005.7747ms ] com.learn.demo.app.service.impl.ArthasTestServiceImpl:sleep5Sec()
                +---[40.05% 2004.8723ms ] com.learn.demo.app.service.impl.ArthasTestServiceImpl:sleep2Sec() #29
                |   `---[100.00% 2004.857ms ] com.learn.demo.app.service.impl.ArthasTestServiceImpl:sleep2Sec()
                |       `---[100.00% 2004.8452ms ] java.lang.Thread:sleep() #38
                `---[59.95% 3000.8796ms ] com.learn.demo.app.service.impl.ArthasTestServiceImpl:sleep3Sec() #30
                    `---[100.00% 3000.8322ms ] com.learn.demo.app.service.impl.ArthasTestServiceImpl:sleep3Sec()
                        `---[100.00% 3000.8175ms ] java.lang.Thread:sleep() #34

Command execution times exceed limit: 1, so command will exit. You can set it with -n option.
[arthas@29788]$

在实际的使用过程中,我们可能并不需要每次都捕获,只需要捕获超过一定时间的记录,那么可以使用#cost命令

trace com.learn.demo.app.service.impl.ArthasTestServiceImpl testTrace -n 1 --skipJDKMethod false '#cost<8000'

访问接口,发现并没有记录

但是将,就会有记录了

trace com.learn.demo.app.service.impl.ArthasTestServiceImpl testTrace -n 1 --skipJDKMethod false '#cost>8000'

执行结果如下,命令换行会有错位,不用理会

000'has@29788]$ trace -E com.learn.demo.app.service.impl.ArthasTestServiceImpl ^.*$ -n 1 --skipJDKMethod false '#cost<8
<8000's@29788]$ trace com.learn.demo.app.service.impl.ArthasTestServiceImpl testTrace -n 1 --skipJDKMethod false '#cost
Press Q or Ctrl+C to abort.
Affect(class count: 1 , method count: 1) cost in 27 ms, listenerId: 13
>8000's@29788]$ trace com.learn.demo.app.service.impl.ArthasTestServiceImpl testTrace -n 1 --skipJDKMethod false '#cost
Press Q or Ctrl+C to abort.
Affect(class count: 1 , method count: 1) cost in 27 ms, listenerId: 14
`---ts=2024-09-26 17:48:23.872;thread_name=http-nio-8090-exec-2;id=35;is_daemon=true;priority=5;TCCL=org.springframework.boot.web.embedded.tomcat.TomcatEmbeddedWebappClassLoader@60aec68a
    `---[10026.9622ms] com.learn.demo.app.service.impl.ArthasTestServiceImpl:testTrace()
        +---[20.07% 2011.962ms ] com.learn.demo.app.service.impl.ArthasTestServiceImpl:sleep2Sec() #19
        +---[29.96% 3004.3291ms ] com.learn.demo.app.service.impl.ArthasTestServiceImpl:sleep3Sec() #20
        `---[49.97% 5010.3703ms ] com.learn.demo.app.service.impl.ArthasTestServiceImpl:sleep5Sec() #21

Command execution times exceed limit: 1, so command will exit. You can set it with -n option.
[arthas@29788]$

 watch

  • 编写测试程序

ArthasController

@ApiOperation(value = "watch")
@PostMapping(value = "/watch")
public Map<String, Object> testWatch(@RequestBody List<Object> sourceList) {
    return arthasTestService.testWatch(sourceList);
}

ArthasTestServiceImpl

@Override
public Map<String, Object> testWatch(List<Object> argList) {
    if (CollectionUtils.isEmpty(argList)) {
        return new HashMap<>(0);
    }
    return argList.stream().filter(Objects::nonNull).collect(Collectors.toMap(Object::toString, Function.identity()));
}
  • 常用命令
watch com.learn.demo.app.service.impl.ArthasTestServiceImpl testWatch '{params,returnObj,throwExp}'  -n 5  -x 3
  • 参数说明:
    • {params,returnObj,throwExp}为 ognl 表达式,表示返回的三个参数分别是入参,返回结果、异常信息
    • -x 3表示出结果的属性遍历深度,默认为 1,最大值是 4
    • 默认参数为-f,表示在函数结束之后(正常返回和异常返回)观察

官网参数说明如下

  • 访问接口测试
[arthas@9308]$ watch com.learn.demo.app.service.impl.ArthasTestServiceImpl testWatch '{params,returnObj,throwExp}'  -n 5  -x 3
Press Q or Ctrl+C to abort.
Affect(class count: 1 , method count: 1) cost in 28 ms, listenerId: 4
method=com.learn.demo.app.service.impl.ArthasTestServiceImpl.testWatch location=AtExit
ts=2024-09-26 19:38:49.137; [cost=0.4306ms] result=@ArrayList[
    @Object[][
        @ArrayList[
            @Integer[1],
            @String[test],
            @Integer[3],
        ],
    ],
    @HashMap[
        @String[1]:@Integer[1],
        @String[3]:@Integer[3],
        @String[test]:@String[test],
    ],
    null,
]

参考文档

[1].官网文档

[2].demo项目地址

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2168474.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

移动技术开发:HandlerAsyncTask

1 实验名称 Handler&AsyncTask 2 实验目的 掌握使用Handler消息传递机制和AsyncTask处理后台线程周期性的改变Activity中界面控件的属性 3 实验源代码 布局文件代码&#xff1a; &#xff08;1&#xff09;HandlerTest <?xml version"1.0" encoding&quo…

《深度学习》—— ResNet 残差神经网络

文章目录 一、什么是ResNet&#xff1f;二、残差结构&#xff08;Residual Structure&#xff09;三、Batch Normalization&#xff08;BN----批归一化&#xff09; 一、什么是ResNet&#xff1f; ResNet 网络是在 2015年 由微软实验室中的何凯明等几位大神提出&#xff0c;斩获…

文新智能体开发:省钱有道,智慧选择,属于你的“省钱小诸葛”

开发灵感 在开发购物类智能体“省购小诸葛”时&#xff0c;我的灵感源自于对现代消费者购物行为的深刻洞察与未来科技趋势的展望。想象一个时代&#xff0c;当信息的海洋变得浩瀚无垠&#xff0c;消费者在众多商品与促销活动中遨游&#xff0c;却往往感到迷茫与疲惫。这时&…

在CANoe/CANalyzer中Replay Block“一键发送”一个诊断/命令序列

案例背景&#xff1a; 在博文《在CANoeCANalyzer中“在线回放”CAN Log.asc/blf文件_canoe怎么回放blf文件-CSDN博客https://blog.csdn.net/qfmzhu/article/details/128954931》我们介绍了Replay Block模块的一些典型应用。 下面我们介绍如何使用Replay Block代替IG(Interact…

OJ在线评测系统 后端 使用代理模式编写测试类 并 实现核心业务判题流程

编写测试类(代理模式) 实现示例的代码沙箱 package com.dduo.dduoj.judge.codesandbox.impl;import com.dduo.dduoj.judge.codesandbox.CodeSandbox; import com.dduo.dduoj.judge.codesandbox.model.ExecuteCodeRequest; import com.dduo.dduoj.judge.codesandbox.model.Exec…

Linux 冯诺依曼体系结构与操作系统概念

目录 0.前言 1. 冯诺依曼体系结构概述 1.1 输入单元 1.2 中央处理单元&#xff08;CPU&#xff09; 1.3 输出单元 2. 冯诺依曼体系结构的关键特性 2.1 所有数据流向内存 2.2 数据流动示例&#xff1a;QQ聊天过程 3. 操作系统 3.1 概念 3.2 设计操作系统的目的 3.3 操作系统的“…

华为源NAT技术与目的NAT技术

1&#xff09;源NAT对报文源地址进行转换&#xff0c;分为NAT NO-PAT&#xff0c;NAPT,EASY-IP,三元组NAT&#xff1b; &#xff08;1&#xff09;NAT NO-PAT原理&#xff1a; no-port address translation:非端口地址转换&#xff1a;只转换地址&#xff0c;不转换端口&…

【C++位图】构建灵活的空间效率工具

目录 位图位图的基本概念如何用位图表示数据位图的基本操作setresettest 封装位图的设计 总结 在计算机科学中&#xff0c;位图&#xff08;Bitmap&#xff09;是一种高效的空间管理数据结构&#xff0c;广泛应用于各种场景&#xff0c;如集合操作、图像处理和资源管理。与传统…

使用docker形式部署prometheus+alertmanager+钉钉告警

一、拉取所需要的镜像 docker pull prom/node-exporter docker pull grafana/grafana docker pull prom/prometheus docker pull prom/alertmanager 其中 prom/node-exporter&#xff1a;用于收集主机系统信息和指标的 grafana/grafana&#xff1a;是一个用于可视化和分…

word2vector理论

目录 1.理论 2.公式 3.SkipGram的优化 1.理论 2.公式 3.SkipGram的优化 CBOW的优化, CBOW是用上下文预测中心词. Hirarchical softmax帮助我们最快的找到最大的softmax, 通过建立一个霍夫曼树.

【数据结构】AVL树相关知识详细梳理

1. AVL树的概念 AVL的全称是Adelson-Velsky-Landis&#xff0c;其名称来源于其发明者Adelson、Velsky和Landis&#xff0c; 是平衡二叉树搜索树。 它的出现是由于二叉搜索树虽可以缩短查找的效率&#xff0c;但如果数据有序或接近有序二叉搜索树将退化为单支树&#xff0c;查找…

城市轨道交通网络客流大数据可视化分析系统----以某市交通网络客流数据为例

1 引言 1.1研究背景、目的与意义 1.1.1研究背景 城市轨道交通系统是现代城市的重要交通方式之一&#xff0c;随着城市化进程的加速和人口增长&#xff0c;轨道交通系统的客流量不断增加。因此&#xff0c;轨道交通部门和相关企业需要对客流数据进行实时监测和分析&#xff0…

云数据库RDS MySQL性能测试与对比@2024年09月

原创&#xff1a;orczhouninedata 来源&#xff1a;云数据库技术 在不同的云厂商购买相同规格的MySQL实例(如4vCPU-16GB)&#xff0c;获得的性能相同吗&#xff0c;他们的差异如何&#xff1f;本文继续尝试回答这个问题。 详细数据&#xff1a; 测试结果概述 在本次测试中&…

常见的TTL,RS232,RS485,IIC,SPI,UART之间的联系和区别

简单总结 图片来源 RS232,RS485可参考&#xff0c;IIC&#xff0c;SPI,UART可参考 烧录程序中常听到的一句话就是USB转TTL&#xff0c;但严格来说算是USB传输数据的协议转换成TTL&#xff08;Transistor-Transistor Logic&#xff09;协议传输数据。首先&#xff0c;usb是常见…

电脑资料被拷贝了,能查出来吗?5个方法有效防止电脑泄密!

网络快速发展的背景下&#xff0c;电脑资料的安全问题日益凸显。 一旦电脑资料被非法拷贝&#xff0c;不仅可能导致企业核心机密泄露&#xff0c;还可能对个人隐私造成严重影响。 那么&#xff0c;当电脑资料被拷贝时&#xff0c;我们能否查出来&#xff1f;又该如何有效防止…

【Python】必学!教你如何在日志中隐藏明文密码?看完包会的!(附带免费源码)

前言 在项目开发中&#xff0c;有的时候会遇到一些安全需求&#xff0c;用以提升程序整体的安全性&#xff0c;提高外来非法攻击的门槛&#xff0c;而在日志中隐藏明文密码打印便是最典型的安全需求之一。 在Python中&#xff0c;明文密码往往发生于命令执行参数、debug日志、…

施耐德EcoStruxure Machine SCADA Expert(EMSE)数据监测(十八)

通过EMSE与sql数据库连接,可以实现一些过程数据的监测、存档,实现生产过程的可视化。 1.创建sql数据库表单 新建一个名为Table_Monitor的表单,添加三个元素:Re_Index 序号;Re_Date 时间;Re_Temper 温度(需要监测的数据) 2.EMSE内关联变量 2.1 先创建网格 2.2 选择数据…

unity CustomEditor的基本使用

CustomEditor用来自定义脚本的编辑面板 其基本使用方式 先准备一个类&#xff0c;继承MonoBehaviour 定义一个变量&#xff0c;然后准备一个类&#xff0c;继承自Editor 在CustomEditor中指定要去修改的类型&#xff0c;通过serializedObject.FindProperty(变量名)的方式来获…

Ubuntu下安装向日葵:闪退

下载 https://sunlogin.oray.com/download 初次安装 $ sudo dpkg -i SunloginClient_15.2.0.63064_amd64.deb 正在选中未选择的软件包 sunloginclient。 (正在读取数据库 ... 系统当前共安装有 234281 个文件和目录。) 准备解压 SunloginClient_15.2.0.63064_amd64.deb ..…

Java.动态代理

1.创建一个接口 package Mydynamicproxy1;public interface Star {public abstract String sing(String str);public abstract void dance(String str); }2.创建一个BigStar类&#xff0c;要实现Star这个接口 package Mydynamicproxy1;public class BigStar implements Star{…