Method and equipment for monitoring network card of server cluster
Technical Field
The field relates to the field of computers, and more particularly to a method and apparatus for monitoring network cards of a server cluster.
Background
With the development of the times, in order to respond to a larger amount of services, the IT scale is continuously enlarged, a plurality of enterprises adopt a server cluster to provide services to the outside, and the cluster improves the throughput capacity of the services, but brings great challenges to operation and maintenance. When a cluster has hundreds or even thousands of servers, the servers are difficult to be checked one by one in a manual mode, and great challenges are brought to problem positioning. In the operation and maintenance process, the network card negotiation rate is an important index item, the network card negotiation rate is the transmission rate of the server network card and the switch on a link layer, and the negotiation rate is related to the rate supported by the network card and the rate supported by the switch port. If the network card is a ten-gigabit network card, the negotiation rate is very low, and when the network flow is relatively low, no problem exists, but when the network flow is very high, many requests cannot be processed in time, the problems are exposed, and the problems are not easy to be eliminated. Currently, there are many tools capable of querying network card negotiation rate information of a single host, and a host logged in a cluster through ssh generally checks whether the network card negotiation rate is normal. But it is difficult to find a problem when the number of hosts of a cluster reaches hundreds or thousands.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method and an apparatus for monitoring network cards of a server cluster, and by using the method of the present invention, information of all network cards in the cluster can be uniformly monitored and data analyzed, and network cards with problems are screened out and displayed, so that operation and maintenance personnel do not need to log in each machine for troubleshooting, and workload of the operation and maintenance personnel is greatly reduced.
Based on the above object, an aspect of the embodiments of the present invention provides a method for monitoring a network card of a server cluster, including the following steps:
collecting the information of the network cards in the cluster at intervals of threshold time, and screening the information of the network cards to obtain the information of the physical network cards;
traversing the physical network card information to obtain the state information of the physical network card and sending the state information to a database;
establishing a tree-shaped data model according to the state information in the database;
and analyzing the state of the physical network card according to the tree data model to maintain the network card of the server cluster.
According to an embodiment of the present invention, the screening the information of the network card to obtain the information of the physical network card includes:
and deleting the information of the virtual network card in the information of the network card.
According to one embodiment of the invention, the status information comprises: the state, type, negotiation rate, network card name, and host name of the physical network card.
According to an embodiment of the present invention, obtaining the status information of the physical network card includes:
and obtaining the state information of the physical network card through an ethtoolol tool.
According to an embodiment of the present invention, analyzing the state of the physical network card according to the tree data model to maintain the network card of the server cluster includes:
analyzing whether the negotiation rate of the physical network card in each piece of data in the tree-shaped data model is normal or not, and marking based on the abnormality;
and outputting the tree data model so that the operation and maintenance personnel can maintain the network card.
In another aspect of the embodiments of the present invention, an apparatus for monitoring a network card of a server cluster is further provided, where the apparatus includes:
the host agent module is configured to collect the information of the network cards in the cluster at intervals of threshold value time, and screen the information of the network cards to obtain the information of the physical network cards;
the information acquisition module is configured to traverse the physical network card information to acquire the state information of the physical network card and send the state information to the database;
the model building module is configured to build a tree-shaped data model according to the state information in the database;
and the analysis module is configured to analyze the state of the physical network card according to the tree-shaped data model so as to maintain the network card of the server cluster.
According to an embodiment of the present invention, the host agent module is further configured to delete the information of the virtual network card from the information of the network card.
According to one embodiment of the invention, the status information comprises: the state, type, negotiation rate, network card name, and host name of the physical network card.
According to an embodiment of the invention, the information obtaining module is further configured to obtain the state information of the physical network card through an ethnool tool.
According to one embodiment of the invention, the analysis module is further configured to analyze whether the negotiation rate of the physical network card in each piece of data in the tree-shaped data model is normal or not, and mark the negotiation rate based on the abnormality; and outputting the tree-shaped data model so that operation and maintenance personnel can maintain the network card.
The invention has the following beneficial technical effects: the method for monitoring the network card of the server cluster, provided by the embodiment of the invention, comprises the steps of collecting the information of the network card in the cluster at intervals of a threshold value, and screening the information of the network card to obtain the information of a physical network card; traversing the physical network card information, acquiring the state information of the physical network card and sending the state information to a database; establishing a tree-shaped data model according to the state information in the database; according to the technical scheme of analyzing the state of the physical network card according to the tree-shaped data model to maintain the network cards of the server cluster, information of all the network cards in the cluster can be uniformly monitored and data analysis is carried out, and the network cards with problems are screened out and displayed, so that operation and maintenance personnel do not need to log in each machine to carry out troubleshooting, and the workload of the operation and maintenance personnel is greatly reduced.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other embodiments can be obtained by using the drawings without creative efforts.
FIG. 1 is a schematic flow diagram of a method of monitoring network cards of a server cluster in accordance with one embodiment of the present invention;
fig. 2 is a schematic diagram of a device for monitoring a network card of a server cluster according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the following embodiments of the present invention are described in further detail with reference to the accompanying drawings.
Based on the foregoing objective and a first aspect of the embodiments of the present invention, an embodiment of a method for monitoring a network card of a server cluster is provided. Fig. 1 shows a schematic flow diagram of the method.
As shown in fig. 1, the method may include the steps of:
s1, collecting the network card information in the cluster at intervals of threshold time, screening the network card information to obtain physical network card information, residing in the system in a system process mode by registering a system service, starting a timing task in the process, setting the threshold time to be one minute for executing the timing task, and screening the network card list firstly and eliminating the information of the virtual network card when the timing task is executed, and only keeping the physical network card;
s2 traversing the information of the physical network card to obtain the state information of the physical network card and sending the state information to a database, wherein the information of the physical network card is traversed, the information of the state, the type, the negotiation speed and the like of the network card can be found out through an ethnool tool, the information of the name of the network card, the name of a host and the like is arranged into a fixed format and sent to the database, and the database can be an infiluxdb database;
s3, establishing a tree data model according to the state information in the database, wherein the database is responsible for storing the state information of the physical network card, and periodically establishing the tree data model according to the information in the data, wherein the data model can be a tree data model of a cluster-host-network card, and the ratio is 1: m: and n, wherein 1 is the whole cluster, m is the host, and n is the network card name. m and n can be increased or decreased according to the information in the database, and when new hosts and network cards are found, the new hosts and network cards are added into the tree-shaped data model, so that all mapping relations in the whole cluster can be timely and effectively maintained;
s4, analyzing the state of the physical network card according to the tree data model to maintain the network card of the server cluster.
By the technical scheme, the information of all network cards in the cluster can be uniformly monitored, the data can be analyzed, the network cards with problems can be screened out and displayed, operation and maintenance personnel do not need to log in each machine for checking, and the workload of the operation and maintenance personnel is greatly reduced.
In a preferred embodiment of the present invention, the screening the information of the network card to obtain the information of the physical network card includes:
deleting the information of the virtual network card in the information of the network card, wherein the acquired information of the network card in the cluster comprises the information of the virtual network card and the information of the physical network card, and the information of the virtual network card can be deleted only by maintaining the information of the physical network card.
In a preferred embodiment of the present invention, the status information comprises: the state, type, negotiation rate, network card name, and host name of the physical network card. The current state of the network card can be visually judged through the state information, so that the network card with problems can be maintained conveniently.
In a preferred embodiment of the present invention, obtaining the status information of the physical network card includes:
and obtaining the state information of the physical network card through an ethtoolol tool.
In a preferred embodiment of the present invention, analyzing the state of the physical network card according to the tree data model to maintain the network card of the server cluster includes:
analyzing whether the negotiation rate of the physical network card in each piece of data in the tree-shaped data model is normal or not, and marking based on the abnormality;
and outputting the tree data model so that the operation and maintenance personnel can maintain the network card. The data display can be used for displaying all network cards and data with inconsistent network card rates through the HTTP interface, and prominently displaying the inconsistent negotiation rates, so that operation and maintenance personnel can easily find out the situation of inconsistent network card rates of the whole cluster.
Examples
The method comprises the following steps: first, a system service is registered and resides in the system in a system process mode. The process starts a timing task, the time is set to be executed once every minute, when the timing task is executed, the network card list is firstly screened out, the information of the virtual network card is eliminated, and only the physical network card is reserved. And then traversing the information of the physical network card. And finding out the information such as the state, the type, the negotiation rate and the like of the network card through an ethtool, arranging the information such as the name of the network card, the name of the host and the like into a fixed format, and sending the fixed format to the inflixdb database.
Step two: and the influxdb database receives the data sent by each host computer and stores the data into the database.
Step three: periodically reading and sorting data in the inflixdb database, and then establishing a tree data model of a cluster-host-network card, wherein the ratio is 1: m: and n, wherein 1 is the whole cluster, m is the host, and n is the network card name. m and n can be increased or decreased according to the data of the agent module. When a new host and a new network card are found, all mapping relations in the whole cluster can be timely and effectively maintained in the tree-shaped data model added with the new host and the new network card. And then analyzing whether the negotiation rate of each piece of data is normal or not, if the negotiation rate of each piece of data is abnormal, marking that the state corresponding to the n is abnormal, otherwise marking that the n is normal, displaying all the network cards and the data with inconsistent negotiation rates of the network cards through the HTTP interface, and prominently displaying the inconsistent negotiation rates, so that operation and maintenance personnel can easily find out the condition that the negotiation rates of the network cards of the whole cluster are inconsistent.
By the technical scheme, the information of all network cards in the cluster can be uniformly monitored, the data can be analyzed, the network cards with problems can be screened out and displayed, operation and maintenance personnel do not need to log in each machine for checking, and the workload of the operation and maintenance personnel is greatly reduced.
It should be noted that, as will be understood by those skilled in the art, all or part of the processes in the methods of the above embodiments may be implemented by instructing relevant hardware through a computer program, and the above programs may be stored in a computer-readable storage medium, and when executed, the programs may include the processes of the embodiments of the methods as described above. The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), or the like. The embodiments of the computer program may achieve the same or similar effects as any of the above-described method embodiments.
Furthermore, the method disclosed according to an embodiment of the present invention may also be implemented as a computer program executed by a CPU, and the computer program may be stored in a computer-readable storage medium. The computer program, when executed by the CPU, performs the above-described functions defined in the method disclosed in the embodiments of the present invention.
In view of the above, a second aspect of the embodiments of the present invention provides an apparatus for monitoring a network card of a server cluster, as shown in fig. 2, the apparatus 200 includes:
the host agent module 201, the host agent module 201 is configured to collect the network card information in the cluster at threshold time intervals, and screen the network card information to obtain the physical network card information;
the information acquisition module 202, the information acquisition module 202 is configured to traverse the physical network card information to obtain the state information of the physical network card and send the state information to the database;
the model building module 203, the model building module 203 is configured to build a tree-shaped data model according to the state information in the database;
and the analysis module 204, wherein the analysis module 204 is configured to analyze the state of the physical network card according to the tree data model to maintain the network card of the server cluster.
In a preferred embodiment of the present invention, the host agent module 201 is further configured to delete the information of the virtual network card from the information of the network card.
In a preferred embodiment of the present invention, the status information comprises: the state, type, negotiation rate, network card name, and host name of the physical network card.
In a preferred embodiment of the present invention, the information obtaining module 202 is further configured to obtain the state information of the physical network card through an ethnool tool.
In a preferred embodiment of the present invention, the analysis module 204 is further configured to analyze whether the negotiation rate of the physical network card in each piece of data in the tree-shaped data model is normal, and mark the negotiation rate based on the abnormality; and outputting the tree-shaped data model so that operation and maintenance personnel can maintain the network card.
It should be particularly noted that the embodiment of the system described above employs the embodiment of the method described above to specifically describe the working process of each module, and those skilled in the art can easily think that the modules are applied to other embodiments of the method described above.
Further, the above-described method steps and system elements or modules may also be implemented using a controller and a computer-readable storage medium for storing a computer program for causing the controller to implement the functions of the above-described steps or elements or modules.
Those of skill would further appreciate that the various illustrative logical blocks, modules, circuits, and algorithm steps described in connection with the disclosure herein may be implemented as electronic hardware, computer software, or combinations of both. To clearly illustrate this interchangeability of hardware and software, various illustrative components, blocks, modules, circuits, and steps have been described above generally in terms of their functionality. Whether such functionality is implemented as software or hardware depends upon the particular application and design constraints imposed on the overall system. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the disclosed embodiments of the present invention.
The embodiments described above, particularly any "preferred" embodiments, are possible examples of implementations and are presented merely to clearly understand the principles of the invention. Many variations and modifications may be made to the above-described embodiments without departing from the spirit and principles of the technology described herein. All such modifications are intended to be included within the scope of this disclosure and protected by the following claims.