"Python Tour" eighth: the idea and process of developing monitoring software

Source: Internet
Author: User
Tags switches

In the last two weeks, has been studying the development of monitoring software, although it is a simple version, but in this process, for the development of a monitoring software framework and process is really learning a lot of things, but also think that this knowledge is very difficult to read articles or books can learn to get, only himself to practice, I think I can slowly realize this is not easy in the middle of it. And through such a process, found themselves in this aspect of the shackles of thought slowly open, but also slowly realized that kind of fun it. Here, really thank Alex teacher very wonderful explanation.

The approximate flow of monitoring software is as follows:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/74/D3/wKiom1Yp8PfQJUByAAHkBZuaRZM867.jpg "title=" Monitor the software flow. jpg "alt=" wkiom1yp8pfqjubyaahkbzuarzm867.jpg "/> Of course, the actual learning process is not to monitor MySQL or Ngnix, but only to monitor the Linux server CPU, memory, Load of the relevant indicators, but I think this is not a problem, because the idea and framework came out, the back to monitor what, naturally it is easy to write the plugin, and then add to the monitoring item inside to OK.

I just started to see the above monitoring software, the feeling should not be too difficult, but when I followed step after step to do, only to achieve this in the middle to consider and solve the problem is too much too much, summed up, to solve the problem, or the basic realization process and ideas, simple summary can be as follows:


For clients:

1. How to get the indicator items to monitor

For example, if I want to monitor the situation of the CPU, how can I get the relevant information of the CPU, by what means or what command, this step is achieved, in fact, is a monitoring CPU plug-in, the plug-in should be as independent as possible, that is not affected by other programs, and other programs with low coupling degree , in short, the function of this plugin is to get the monitoring indicator information I want.


2. How to handle the monitored metrics information obtained

Mainly refers to the client to these monitoring indicators information data processing, here should be involved in the issue, to obtain monitoring metrics information, should be based on a monitoring project to save, or based on a monitored host to save the indicator information. For example, I monitor the CPU, memory, and load of a host, should I save these three as three data structures, or should I save these three directly as a data structure? This depends on the demand, and based on the CPU, memory, load monitoring frequency can be adjusted, considering the future extensibility of the software, should be the data obtained by the three separate storage, in Python development, you can save the three to three different dictionaries. So, from this point of view, it's important to know where the frequency of monitoring comes from, and keep looking at the content below.


3. How to get the configuration information of monitoring project

For example, I want to monitor the CPU, specifically I want to monitor the CPU what information, what indicators, such as idle, nice, etc., where should I go to find these configuration information? how much time is monitored, i.e. how often is it monitored? There are ideas that can be set up directly on the client, but if you do, still consider the extension of the software problem, if you want to monitor a lot of server host, it is not to be set on each client host? Since it is monitoring, it is better to consider setting up the client's information on the server side, that is, the configuration file, and then can be obtained directly from the server side by the client, so that when monitoring multiple hosts, as long as the server side of the corresponding settings, the client run a client program can be, centralized, unified management of the idea is reflected. But the crux of the matter is, how do the clients go to server-side fetching these configuration information?


4. How to obtain configuration information of monitoring project from server side

If you are using the method policy in 3, then how can clients fetch from the server side? With the help of the Redis Database subscription service feature, the Redis database-based feature allows the problem to be solved as long as the Redis database is installed and running on both the server side and the client. Of course, the important configuration information that needs to be obtained here should be: what is this host monitoring project? What is the frequency of monitoring?


5. How to send the acquired monitoring information to the server side

With 4 of experience, the subscription service that uses Redis is the simplest. In fact, we have to take the monitoring mode is passive monitoring mode, that is, the server side will not actively to the client to obtain monitoring information, but by the client actively to the server to send monitoring information, and then the server side based on the monitoring policy has been set to determine whether the client host is abnormal, and then implement the alarm function.


For server-side:

Server side to consider more, here, the object-oriented programming idea is very important, of course, the monitoring data reception and collation, processing, alarm is not easy.


1. Using object-oriented programming idea to realize the template customization of different host monitoring projects

The client's monitoring configuration information is obtained from the server side, due to different client host monitoring of the project, the frequency of monitoring may not be the same (this is normal, different servers for different performance indicators are not the same), so through the object-oriented programming idea, the basic configuration information template for each monitoring project to write good , based on these templates, depending on the server host that needs to be monitored, customize different monitoring configuration information, then save to the Redis database, let the client host to fetch, here corresponds to the client to solve the 3rd problem.


2. How to receive and organize the monitoring data

As has been said before, still is through the Redis Database subscription service function to receive, if this way to change, then in the client host should also make corresponding changes, here corresponds to the client to solve the 5th in the problem. Here, you can write a program to run a process, the received data, according to the needs of processing data, and then add relevant information to re-integrate the received monitoring data, and then saved to the Redis database, and then by the Monitoring data processing program to process, that is, the handle program, the reason to do so , in order to reduce the degree of coupling between the program, in order to facilitate the subsequent functional expansion of the monitoring software.


3. How the monitoring data is handled

Here alone a program to run a process, from the Redis database to read the monitoring information of different monitoring items, and then the monitoring information and the 1th step to customize the template of the indicator threshold value (so the first step to write the content information is not only monitoring project configuration information template, There should also be different indicators and the relevant settings of the threshold value, if the abnormal situation is found, the exception information is saved, written to the Redis database, waiting for the alarm program to carry out related processing to achieve alarm function, so the purpose of separate to do is to reduce the degree of coupling between programs. In addition, it should be noted that the processing of monitoring data should also be based on different monitoring items (corresponding to the 2nd in the client), rather than based on different hosts, because different host monitoring of the frequency of the project can be different.


4. How to make an alarm

Here should also be a separate program to implement the alarm function, from the Redis database to read the alarm information, how to alarm this information, is directly on the screen output? Or the mail? Or a text message? Or the phone? and to whom is this information sent to the relevant person? Based on these different needs, there should be a lot of ideas.


So for an overview of the above process, you can further summarize the following:

Client: Read monitoring configuration information--Start monitoring--Get monitoring data--Send to server side

Server-side: Read the monitoring data---monitoring and data processing--Save exception information--Implement automatic alarm


Know what the idea flow of monitoring software is?

Anyway, the general development process of monitoring software or the process and thought of development should be similar to the above, but based on different functions, different needs, different ways, in the actual development process and there are too many details, in general, the process does not look too difficult, But specific to every detail of the implementation, need to spend the energy, I think is very very much, and this, should be a certain experience. But anyway, because know the general development process, and hands-on practice, so later in their own need to develop relevant monitoring software, according to their own needs, and then follow the above thinking process to do, I think, from the most basic start, is bound to develop a set of suitable for the actual production environment monitoring software.



Why learn the Python automated devops development?

This May, took over more than 600 switches in the management of the school, found that the monitoring of the switch is too weak, 600 switches, tens of thousands of users, but only a screen interface to view the monitoring platform, so, let alone automatic alarm function, forced by this helpless, I went online to find a lot of related monitoring software, either is charged, either is not used, or is very very complex operation, it is difficult to start. In fact, my needs are very simple, just hope to see if the switch has been hung, and then if it hangs, you can give me a message or make a phone call, is such a lightweight monitoring software is good.

By this September, it is helpless, can only learn to develop their own, the kind of begging for their own feeling more and more strongly.

Anyway, after learning this knowledge, I found that in fact, to develop a switch function with the functions I said above the monitoring software, in the process is more than the previous said that a lot simpler, so I think, this is not difficult to achieve.

Continuing the study of Python development, after learning the knowledge of web development, I hope that through my own ability can develop a more complete switch monitoring system based on their actual needs.

Of course, in the future to use Python to do things, it is really too much.

No matter how, the future to learn the knowledge or technology, is really too much, I hope that they do not give up, continue to work hard!







This article is from the "fragrant fluttering leaves" blog, please make sure to keep this source http://xpleaf.blog.51cto.com/9315560/1705623

"Python Tour" eighth: the idea and process of developing monitoring software

Related Article

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.