What does a surveillance system need to monitor?
From the granularity, from small to large can be listed: one or two lines of code, a method, a service interface, a service call chain, an application service (application port, JVM CPU and memory consumption, etc.), hardware (CPU, network card, hard disk, etc.).
The monitoring of the method can be extended to the monitoring of the HTTP link/connection pool, the monitoring of the database connection/connection pool, the invocation of other services, etc.
To monitor one or two lines of code, it is unavoidable to hack into the monitored side. Monitoring of methods and service interfaces can take advantage of facets that are woven into AOP in place. A call chain for a service, there is an intrusion on both sides of the call to the service. The application, hardware monitoring, and the application itself decoupling, but the server has an intrusion.
From the monitoring method, the agent can be injected on the monitored side, can monitor the log, can use JMX tools, can run scripts on the server, and so on.
Injecting agents requires attention to performance, robustness, and scalability. The agent can not affect the performance of the monitored, function, or because the monitoring system to add new monitoring functions, and so that the old agent does not work properly.
The monitoring log does not require direct intrusion into the code of the monitored person, but usually requires the monitored person to output the log according to certain rules. This is another form of code intrusion. In addition, log monitoring will have a certain delay and reliability. For example, if there is no log for a period of time, how does the monitoring system determine that there is no business call at this time, or is the application already oom?
The JMX tool provides a standard interface that, in addition to the JVM, should also monitor some in-memory real-time data. In the case of server scripting, some learning costs may be involved with developers.
In addition to monitoring, the monitoring system also needs to have alarm and statistical analysis functions.
Alarm function must ensure real-time and reliability.
Statistical analysis function Be careful about the growth of the database.
This article from "Programming Capricorn male" blog, declined reprint!
Design discussion: Monitoring system, monitoring what?