preface

  • To do a good job, he must sharpen his tools. With a sharp weapon, you can do your job with ease.
  • Online problems are undesirable, but they are unavoidable. Due to the limitations of the online environment, traditional adding logging code redistribution programs are generally not allowed. At this point, the most painful thing is that troubleshooting is hampered by the lack of critical log information.
  • Arthas, an open source Java diagnostic tool from Alibaba, is shared below. I believe that after understanding it, we will have a feeling of regret.

The story of Arthas

  • First, attach Arthas’s GitHub address: github.com/alibaba/art…
  • The blogger first met Arthas last spring, I believe, and the blogger wrote a memoir, Portal, over the summer
  • Recently, a friend said that the boy should come to dig gold to write a blogger, so the blogger came. As it happens, Arthas is being used today, hence this blog.
  • Bloggers recently encountered a problem when an online system suddenly failed to send wechat template messages. It was suspected that someone had modified the configuration information of the wechat public number, but a function was located after several checks. To test the conjecture, arthas was introduced to see how this function was called: incoming arguments, caller, return results.

Use Arthas to troubleshoot online problems

  • Download the arthas-boot.jar package from the official website
  • Upload to the production server and start arthas:
    • java -jar arthas-boot.jar 123178
    • Here 123178 refers to the process PID
  • Don’t worry if you don’t know how to use arthas, type the command:help
    • You can see the arthas command description list
    • Since the current requirement is to observe the invocation of a function (method), the watch command should be selected
  • Don’t worry if you don’t know how to use watch, type:watch --helpView the Help documentation
    • From the help documentation, you can see many examples of use:
    • For current requirements, refer to the examples in the circled section
  • Observe the function call to obtain wechat public platform token:
    • Sure enough, just as I thought. There is a real problem with getting the token. However, the token acquisition failure affects the invocation of all wechat public account interfaces that require token as identity verification.

summary

  • In a production environment where a lot of visual tools that are usually very useful can’t be used due to limitations, it’s a little bit of a neglected command line tool like Arthas that can help us. I hope you enjoy it too.