The use and realization of weblogviewer

Source: Internet
Author: User

System code Address: Https://github.com/2225377fjs/weblogviewer

System Requirements:

Because the machine is more, occasionally need to debug some things online, look at the log condition, if you want to go to the machine to see the more trouble, I hope to be able to develop a system that can support real-time tail viewing the log on the browser, can configure and manage multiple monitoring servers, and hope that the system is relatively light, Do not affect existing applications on the server.


At first http://logio.org/found such a thing, node. JS Development, but the feeling is too simple, the function is not strong enough, there is no pause function is not tolerated, and in need to monitor the process will be no matter whether there is no need to view, Will read the data, send to the central node, wasted CPU ah, I wipe.


So personal overdraft the one out,

Code structure:



There are basically two ways to start, Python start.py and Python startnode.py, respectively.

The system is divided into two parts, which are central services and node nodes, this should be understood, node node is the server that needs to be monitored, configure the log to be monitored, then we can display the log information through the Access Center service, The central service is to get the log data by invoking the APIs provided by the node nodes.


(1) Launch Center service, Python start.py, or Python start.py daemon (the latter is started directly from the next process). Before you start, you need to configure some of the basic parameters of the central service, in fact, to provide external HTTP interface port, in config inside the serverconfig.py file, there is a


Change the HTTP port here to see how your own needs have changed.


After starting up, the interface is probably as follows (URL path: http://127.0.0.1:port/nodes):


This is a node that has been configured to see the case, click on this item:


This can see the log of the node configuration information, click to view the details of the log to see the real-time data


There is a pause button on the left, you can click Pause, and then click Start to get the data.


(2) Next is to join a node, such as the need to monitor a two log files on the B server, then start startnode.py on the B server, before starting or configure the data, in the Config directory of the node_config.py file:



Here name is the name for this node, the name needs to be unique,

Logs is also a dictionary, each K-V project represents a log file that needs to be monitored, K is the name of the file, the path to the value file, the absolute path is required


When the configuration is complete and the startnode.py is started, then go back to the beginning Web interface and select node Management:


Enter the IP of the server that started startnode.py, and its listening port, well, the node listener port is 9000 port by default, if you want to change it, go directly to the startnode.py file and change it.


In this way, the node is joined.


Let's talk about the implementation:

(1) Communication between processes using a relatively simple distributed framework, based on the entity, this does not elaborate, the framework code is in the server directory, the specific business code is placed in the app directory,

(2) When you need to view a log, node nodes will start a process, execute the tail-f command, and then read the data through PIP, the Central service will continue to the node to obtain data, when the connection is closed or disconnected will start the process shutdown.

(3) Central service pushes real-time log data to the Web interface via WebSocket

The use and realization of weblogviewer

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.