How acceptmediocrity/gzzd works
1. What this repository is
- This is a Java-based remote diagnosis platform, adapted into a single-node/standalone deployment from the original gzzd project.
- The system lets an operator open a browser UI, connect to a running Java process via an agent, and perform live operations such as debugging, thread/CPU inspection, heap histogram, file download, monitoring, and profiling.
2. Top-level module boundaries
- common: shared wire protocol, command DTOs, crypto, and utility code used by both client and server.
- clientside: the agent/runtime installed alongside target JVMs; it executes commands and collects data.
- attach: bytecode instrumentation and attach-time tooling, including Arthas-based shell support and custom agent/instrumentation logic.
- serverside: the operator-facing backend, UI, proxy, persistence, and application registry logic.
3. Operator-facing entry point
- serverside/serverside-ui is the main runtime in standalone mode.
- It contains:
- Spring MVC controllers for web/API endpoints.
- A Netty-based proxy layer for long-lived agent/UI communication.
- Static HTML/JS assets for pages like application view, machine view, monitor, profiler, console, and download.
- The README indicates this is started as a single jar, accessed on port 9091 by default.
4. Proxy layer as the central hub
- The most important runtime boundary is serverside-ui/proxy/communicate.
- It manages two sides:
- UI connections from browser sessions.
- Agent connections from deployed client agents.
- Requests from the UI are translated into command messages, routed through the proxy, sent to the relevant agent, and the response is streamed back to the browser.
5. Agent-side execution model
- clientside/clientside-agent is the JVM-side daemon.
- It maintains:
- Heartbeats and agent info refresh.
- Command/task execution.
- Netty client connectivity back to the server.
- Task factories under clientside-agent/task/* implement concrete operations such as CPU jstack, heap histogram, monitor reporting, profiler file cleanup, and process inspection.
6. Command protocol and shared message types
- common/remoting defines the protocol:
- command codes, request/response envelopes, payload holders, encoders/decoders.
- common/remoting/command contains the logical operations the system supports:
- thread info, thread count, CPU time, heap histogram, decompiler, download, monitor, machine, profiler, etc.
- This shared layer is what keeps the browser-facing server, proxy, and agent in sync.
7. Instrumentation and live debugging subsystem
- attach/instrument is the bytecode/instrumentation stack.
- It includes:
- instrument-client: debugger, monitor, profiler, classpath/location discovery, Spring-expression support, and bytecode transformers.
- instrument-agent: bootstrap and classloader support for attaching into target JVMs.
- instrument-spy: async-profiler bridge and spying hooks.
- magic-classes / magic-loader: special classloading and shaded helper classes used to make instrumentation work in hostile classloader environments.
- This subsystem is what enables live code-level inspection and instrumentation inside the target JVM.
8. Arthas integration
- attach/attach-arthas embeds Arthas shell support and command packs.
- It adds commands for agent info, config, debug, jar info, monitoring, profiler control, shutdown/stop, and shell server startup.
- In architecture terms, this is an alternate attach/debug execution path that complements the custom instrument client.
9. Profiler workflow
- Profiling is handled end-to-end across server, agent, and attach layers.
- Server-side profiler controllers and services issue start/stop/state commands.
- Agent-side profiler tasks collect and store profiler data.
- The clientside-decompiler-fernflower module provides decompilation support for viewing source-like output from bytecode when needed.
10. File and artifact handling
- attach/attach-common and several server/client modules provide file service utilities.
- These support:
- jar storage and lookup,
- downloaded artifacts,
- snapshot/cache management,
- profiler output files,
- and other temporary result payloads.
- The server also serves static frontend assets and downloadable binaries such as agent-bin.tgz.
11. Application registry / environment management
- serverside/serverside-application provides an application metadata boundary.
- It includes:
- API interfaces for applications and app servers,
- a Kubernetes-backed implementation (serverside-application-k8s),
- and DAO/service layers for managing application-to-server relationships.
- In the standalone setup this is auxiliary, but it defines how the platform resolves which target app/server an operator wants to inspect.
12. Persistence, config, and security
- serverside-common contains shared server infrastructure:
- dynamic config loading,
- encryption utilities,
- JDBC/H2 helpers,
- ZK client abstractions,
- metrics wrappers,
- and file-store utilities.
- The server side uses encryption for private tokens and request security, plus local or external config sources depending on deployment mode.
- The README notes first-time login uses admin / 123456.
13. Standalone deployment shape
- The repo is designed to run without the original distributed infrastructure in standalone mode.
- The README and scripts indicate you deploy the serverside-ui.jar plus start-all-stand-alone.sh, then start/stop by application name.
- The documented ports suggest three distinct roles can be co-located on one host:
- UI access on 9091,
- agent/debug communication on 9013,
- and an additional gateway/control port on 9014.
14. How data moves through the system
- Browser requests enter serverside-ui controllers.
- Controllers call services that build command requests.
- The proxy layer selects the agent connection and forwards the command.
- The agent executes the task locally against the target JVM or OS process.
- Results stream back through the same proxy path and are rendered in the UI, sometimes as files, sometimes as structured JSON, and sometimes as live console output.
Main entry points: commands Client Commands · communicate Proxy Hub · controller Web APIs · client Instrument Client
Components 22
Common
Shared protocol, utilities, and crypto used across server and agent
- Remoting · Shared command codes, envelopes, codecs, and message types
common/src/main/java/qunar/tc/bistoury/remoting - Core Utils · Shared crypto, file, JSON, and runtime helpers
common/src/main/java/qunar/tc/bistoury/common - Profiler Core · Compact profiler data structures and method caches
common/src/main/java/qunar/tc/bistoury/common/profiler
Clientside
Agent runtime, commands, and decompiler support deployed near target JVMs
- Agent Runtime · Standalone client agent entrypoint, heartbeat, and Netty connectivity
clientside/clientside-agent/src/main/java/qunar/tc/bistoury/agent - Agent Tasks · Concrete JVM and OS-side task factories for inspection and collection
clientside/clientside-agent/src/main/java/qunar/tc/bistoury/agent/task - Agent Common · Process discovery, response jobs, remoting task store, and KV helpers
clientside/clientside-agent-common/src/main/java/qunar/tc/bistoury/agent/common - Client Commands · Command implementations for CPU, heap, download, monitor, host, and profiler flows
clientside/clientside-command/src/main/java/qunar/tc/bistoury/commands - Decompiler · Embedded Fernflower decompiler used for source-like rendering
clientside/clientside-decompiler-fernflower/src/main/java/qunar/tc/decompiler
Attach
Instrumentation, attach-time tooling, and Arthas integration
- Bootstrap · Attach-time bootstrap and classloader support for target JVM instrumentation
attach/instrument/instrument-agent/src/main/java/qunar/tc/bistoury/instrument/agent - Instrument Client · Debugger, monitor, profiler, and source location instrumentation logic
attach/instrument/instrument-client/src/main/java/qunar/tc/bistoury/instrument/client - Spy Bridge · Async-profiler bridge and spying hooks used by instrumentation
attach/instrument/instrument-spy/src/main/java/qunar/tc/bistoury/instrument/spy - Magic Classes · Special classloading and shaded helper classes for hostile environments
attach/instrument/magic-classes/src/main/java/qunar/tc/bistoury/magic/classes - Arthas Shell · Embedded Arthas command pack and shell server integration
attach/attach-arthas/src/main/java/qunar/tc/bistoury/attach/arthas - Attach File · Shared attach-side file service utilities and jar storage helpers
attach/attach-common/src/main/java/qunar/tc/bistoury/attach
Serverside
Standalone backend, proxy, UI, persistence, and application registry
- Serverside UI · Spring MVC frontend runtime, static assets, and the standalone jar entrypoint
serverside/serverside-ui/src/main/java/qunar/tc/bistoury - Proxy Hub · Central browser-to-agent communication hub with UI and agent sessions
serverside/serverside-ui/src/main/java/qunar/tc/bistoury/proxy/communicate - UI Handlers · Browser request decoding and command processors for inspection, download, and profiler actions
serverside/serverside-ui/src/main/java/qunar/tc/bistoury/proxy/communicate/ui/handler - Agent Handlers · Agent-side connection handlers, heartbeats, and profiler file delivery
serverside/serverside-ui/src/main/java/qunar/tc/bistoury/proxy/communicate/agent/handler - Profiler Service · Profiler coordination, storage, locking, and analysis pipeline
serverside/serverside-ui/src/main/java/qunar/tc/bistoury/proxy/service - Web APIs · HTTP controllers for login, application views, config, profiler, and agent endpoints
serverside/serverside-ui/src/main/java/qunar/tc/bistoury/ui/controller - Persistence · Dynamic config, database access, encryption, and user/token storage support
serverside/serverside-common/src/main/java/qunar/tc/bistoury/serverside - App Registry · Application and app-server resolution with k8s-backed implementations
serverside/serverside-application
Connections 27
- Remoting → Proxy Hub: messages · Shared request/response datagrams and command codes define the proxy contract
- Remoting → Agent Common: codec · Agent-side remoting uses the same envelopes and serializers
- Core Utils → Persistence: helpers · Shared utilities support encryption, files, and runtime helpers
- Core Utils → Web APIs: utils · Frontend and API flows reuse common JSON, crypto, and file helpers
- Profiler Core → Profiler Service: data model · Profiler structures are shared with server-side analysis and storage
- Profiler Core → Client Commands: profile data · Profiler summaries and caches are consumed by client command execution
- Serverside UI → Web APIs: hosts · Standalone application exposes Spring MVC controllers and static assets
- Serverside UI → Proxy Hub: embeds · The standalone runtime embeds the proxy communication hub
- Web APIs → Proxy Hub: dispatches · HTTP handlers translate browser actions into proxy commands and sessions
- Web APIs → App Registry: resolves apps · Controllers consult application metadata to locate target servers
- Web APIs → Persistence: stores users · Login, token, and configuration flows use persistence services
- Proxy Hub → UI Handlers: routes ui · Browser-originated requests are decoded into command processors
- Proxy Hub → Agent Handlers: routes agent · Agent sessions receive heartbeat, info, response, and profiler file messages
- UI Handlers → Client Commands: issues commands · UI command processors build logical operations executed by the agent
- UI Handlers → Profiler Service: profiler control · Profiler start/stop/state flows coordinate with profiler services
- Agent Handlers → Agent Runtime: connects to · Proxy-side agent connections terminate in the running JVM agent
- Agent Runtime → Agent Tasks: executes · Agent runtime schedules concrete task factories and background jobs
- Agent Tasks → Client Commands: implements · Agent-side task factories realize command semantics such as heap, CPU, monitor, and profiler
- Agent Runtime → Agent Common: uses · Agent runtime relies on shared process, response, and remoting helpers
- Client Commands → Arthas Shell: alternate path · Arthas command packs provide a parallel debug and shell execution path
- Client Commands → Instrument Client: instrumentation · Commands for debugging, monitoring, and profiling rely on instrumented runtime support
- Bootstrap → Instrument Client: boots · Attach bootstrap loads instrumentation client into target JVMs
- Instrument Client → Spy Bridge: profiles · Instrumentation client delegates profiler hooks to the spy bridge
- Instrument Client → Magic Classes: loads · Special classloading helpers keep instrumentation working across classloader boundaries
- Attach File → Arthas Shell: files · Attach-side file service supports jars, snapshots, and temporary outputs
- Profiler Service → Proxy Hub: streams · Profiler data and state are transferred through the proxy hub
- Decompiler → Client Commands: supports · Decompiler output backs source-view and decompile-related commands