CN119172280A - Configuration monitoring method, device and storage medium of proxy server - Google Patents
- ️Fri Dec 20 2024
Detailed Description
In order that those skilled in the art will better understand the present invention, a technical solution in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in which it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present invention without making any inventive effort, shall fall within the scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and the claims of the present invention and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the invention described herein may be implemented in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
According to a first aspect of an embodiment of the present invention, there is provided a method for monitoring configuration of a proxy server, optionally, as shown in fig. 1, the method includes:
s102, sending an acquisition request to a target proxy server through a target port, wherein the acquisition request is used for acquiring the current configuration information of the target proxy server;
s104, receiving current configuration information returned by a target thread in a target proxy server, wherein the target thread is used for monitoring a target port;
S106, comparing the current configuration information with first configuration information in a database, wherein the first configuration information is used for representing the configuration information generated by the target proxy server under the condition of receiving a remote procedure call request;
S108, determining that the remote procedure call request is abnormal under the condition that the current configuration information is not matched with the first configuration information.
Alternatively, the method for monitoring the configuration of the proxy server can be applied to the cluster. There may be multiple nodes in a cluster, and the nodes may be master nodes (host nodes). There may be one or more slave nodes under each master node.
The target proxy server can provide proxy service for the main control node. Each master node may have a corresponding proxy server therein.
The target port may be a port provided by the monitoring service to the proxy server on the master node, the proxy server listens to the target port, and the monitoring service may send a request to the proxy server through the target port. If an acquisition request is sent, the current configuration information of the proxy server is requested to be acquired.
The database may be a redis database for storing user data. The first configuration information may be included in the user data. The first configuration information is information configured by a user. The monitoring service in this embodiment can only read the data in the database and cannot rewrite the part of the data. The first configuration information may represent configuration information generated if the target proxy server receives rpc a request. Such as data for load balancing, data for gateways, some metadata created by users, longest connection time, etc.
In the method, the target thread can monitor the target port, the monitoring service is used for sending the acquisition request to the proxy server to acquire the current configuration information of the proxy server, and the current configuration information is compared with the first configuration information in the database under the condition that the rpc request is normal, so that whether the current configuration information in the proxy server is correct or not can be compared, and if not, the rpc request is abnormal. The purpose of monitoring whether rpc requests are lost or not and whether the configuration is normally issued is achieved, and further the technical problem that whether rpc requests are lost or not and whether the configuration is normally issued or not is solved.
As an alternative example, the target thread is further configured to place the target thread in a waiting state in case the target proxy server is processing a remote procedure call request, and to obtain the current configuration information in case the target proxy server has processed the remote procedure call request, before returning the current configuration information to the monitoring service that sent the acquisition request.
In this embodiment, after the monitoring service sends the acquisition request to the target proxy server through the target port, the target thread may detect the state of the target proxy server first in the case that the target thread on the target proxy server receives the acquisition request. If the target proxy server is processing the received rpc request, the target thread waits first. After waiting for the target proxy server to process rpc the request, the current configuration information of the target proxy server is acquired.
In this embodiment, the target thread is placed in a waiting state, and the waiting duration may be set. If the request has not yet been completed for the wait period rpc, a notification message may be fed back to the monitoring service to notify the monitoring service that the target proxy server is currently processing rpc the request. The estimated processing time may also be fed back to the monitoring service. If the treatment is completed in 3 minutes. The monitoring service may adjust the time for the next transmission of the acquisition request based on the received estimated time period.
As an alternative example, receiving the current configuration information returned by the target thread in the target proxy server includes:
S202, after sending an acquisition request to a target proxy server, setting a waiting time length under the condition that the target proxy server is processing a remote procedure call request;
s204, when the configuration information is received in the waiting time, determining the received configuration information as current configuration information;
s206, when the configuration information is not received within the waiting time, the acquisition request is sent again;
S208, after the acquisition request is sent again, in the case that a plurality of configuration information is received, the configuration information sent later is determined as the current configuration information according to the time stamp in each configuration information.
In this embodiment, after sending the get request, the monitoring service may wait if the target proxy server is processing rpc the request. At this time, the target thread may send the estimated duration to the monitoring service, and the monitoring service may determine the time for sending the acquisition request next time according to the estimated duration. If the target thread does not send a message to the monitoring service, the monitoring service may set a wait period. And within the waiting time period, the target thread can be waited for to return the current configuration information or return the estimated rpc processing time period. If no message is received within the waiting period, the acquisition request may be retransmitted, with the retransmitted acquisition request having a different timestamp than the timestamp of the last transmitted acquisition request. After the acquisition request is sent again, if a plurality of configuration information is received, each configuration information has a timestamp representing the sending time, and the configuration information with the later timestamp is used as the current configuration information.
As an alternative example, sending the acquisition request to the target proxy server through the target port includes:
S302, writing a network address of a monitoring service used for sending an acquisition request into the acquisition request, so that a target thread determines that the currently received acquisition request is the acquisition request sent by the monitoring service through the network address, wherein the target thread is also used for not responding to the acquisition request under the condition that the network address in the received acquisition request is different from the network address of the monitoring service.
In this embodiment, before or when the monitoring service transmits the acquisition request, the network address of the monitoring service may be written into the acquisition request. The network address may be filled into the end of the acquisition request and spliced with the original acquisition request using special symbols as splice symbols. The target thread may have a network address table stored therein as a white list. When an acquisition request is received, locating the splice, and comparing the address after the splice with a white list, thereby determining whether to respond to the acquisition request.
As an alternative example, sending the acquisition request to the target proxy server through the target port includes:
And S402, writing the unique identifier of the target proxy server into the acquisition request so that the target thread can determine the currently received acquisition request as a request for acquiring the current configuration information of the target proxy server through the unique identifier, wherein the target thread is further used for returning a notification message to the monitoring service for sending the acquisition request when the unique identifier in the received acquisition request is different from the unique identifier of the target proxy server, and the notification message is used for prompting that the unique identifier is incorrect.
In this embodiment, before or when the monitoring service transmits the acquisition request, the unique identifier of the target proxy server may be written into the acquisition request. The unique identifier may be filled into the beginning of the acquisition request and spliced with the original acquisition request using the special symbol as a splice. The special symbol is different from the special symbol filled in the network address. When the acquisition request is received, the unique identifier in the acquisition request is compared with the unique identifier of the target proxy server, so that whether the acquisition request is allowed to acquire the current configuration information is determined. If the unique identifier in the acquisition request and the unique identifier of the target proxy server are different, a message may be sent to the monitoring service informing that the unique identifier in the acquisition request is incorrect.
As an alternative example, sending the acquisition request to the target proxy server through the target port includes:
S502, one or more servers to be monitored in all proxy servers are used as target proxy servers, and an acquisition request is sent to each target proxy server according to the respective monitoring period of each target proxy server.
In this embodiment, the target proxy server may be one or more. Each master node may include a proxy server therein, and the proxy server in the master node to be monitored may be the target proxy server. Each target proxy server may have a respective monitoring period. The monitoring period may be set or the monitoring period may be determined based on the frequency of errors requested by rpv in the history. The higher the error frequency, the shorter the monitoring period.
As an alternative example, before comparing the current configuration information with the first configuration information in the database, the method further includes:
S602, under the condition that the current configuration information of any one target proxy server is received, determining first configuration information corresponding to the server name, the network address and the unique identifier from a database according to the server name, the network address and the unique identifier of the any one target proxy server.
In this embodiment, after the monitoring service obtains the current configuration information of the target proxy server, before comparing, the first configuration information corresponding to the current configuration information may be first found out from all the configuration information in the database. When searching the first configuration information, the first configuration information can be searched according to the server name, the network address and the unique identifier of the target proxy server. After the first configuration information is found, the first configuration information is compared with the current configuration information. If the two are not matched, the fact that the current configuration information of the target proxy server is incorrect is determined, and the rec request is determined to be abnormal. Such as rec request loss, etc.
In this embodiment, the agent server may provide a centralized monitoring service, and this monitoring service serves as a control node for monitoring. The method comprises the steps of having an API interface and a service process, and using a redis database to store own data. And the writing operation of the database is not performed, the data is only read from the redis cache and the database of the api service of the network, and then the memory data of the agent server and some issued configurations in the network are inspected and checked through a certain mechanism. For the agent server, a thread is newly started on the agent, and the thread monitors the target port. The monitoring node obtains the memory data of the agent through the port, the memory data contains the current configuration information, the current configuration information is compared with the first configuration information in the database, and if inconsistent places are found, an alarm is given.
As shown in fig. 7, fig. 7 is a system schematic diagram of the present embodiment. In FIG. 7, the agent server joins a new target thread. The thread listens to a socket port (destination port) of a user datagram protocol (User Datagram Protocol, UDP) and the monitoring service sends a request from the socket to the agent. And the target thread of the Agent reads the cache of the Agent according to the request and returns the cache to the monitoring service. The cache includes current configuration information. When the target thread reads the cache, it checks whether the current agent is processing rpc, if so, waits, otherwise, sends the cache to the monitoring service. That is, the agent's cache is shared by this monitoring thread and the host process, and the monitoring thread only reads and does not write. And the read time is the time without rpc processing. For the agent to expose a udp monitor port, in order to ensure the security of the agent, the agent may only monitor the ip address of the monitoring service, or add a password to each request, where the password is the unique identifier of the agent.
Fig. 8 is a schematic diagram of a monitoring service. The monitoring service comprises three modules, namely an automatic inspection module, a CLI module and a configuration comparison alarm module.
Wherein the CLI module supports the following functions:
1. A quick check is made as to whether the designated node configuration is correct. In the checking process, it is mainly checked whether the format of the current configuration information in the cache is correct and whether the data is in the specified range.
2. The cache of the designated node is compressed. The purpose of compressed caching is to reduce the space taken up.
The inspection module is a dead loop, and acquires the hostname and ip addresses and ids of the agents from the agents table in the database through a certain algorithm, such as polling or random. And then acquiring the cache of the agent through the port exposed by the agent, and then sending the information to the comparison alarm module. The CLI module may interrupt this dead loop and designate a hostname to quickly detect the agent cache corresponding to the designated hostname.
The comparison alarm module receives information from the inspection module and checks the abnormality of the agent cache by comparing the agent cache with the data in the database. If there is a problem, an alarm is sent.
In this embodiment, the monitoring service may adopt a mode of sharing redisquese by multiple workers, so that all the workers can equally assume the task of patrol. Meanwhile, the system can be expanded and contracted horizontally without states. Typically, this service does not require very high performance and timeliness. Too frequent checking can instead affect the performance of DB and redis and put a certain stress on agents. Periodic inspection or a timed inspection scheme may be employed, such as checking the agent cache of the cluster once every three hours, beginning every day in the early morning.
By adopting the method of the embodiment, the mq message is ensured not to be lost, and rpc sent by a neutron-api-server is ensured to reach the agent end. The agent can correctly issue the configuration without losing the configuration. And as a retry and monitoring mechanism is added, the issuing configuration is ensured not to fail under the condition that the memory of the agent is not problematic.
It should be noted that, for simplicity of description, the foregoing method embodiments are all described as a series of acts, but it should be understood by those skilled in the art that the present invention is not limited by the order of acts described, as some steps may be performed in other orders or concurrently in accordance with the present invention. Further, those skilled in the art will also appreciate that the embodiments described in the specification are all preferred embodiments, and that the acts and modules referred to are not necessarily required for the present invention.
According to another aspect of the embodiment of the present application, there is also provided a configuration monitoring device of a proxy server, as shown in fig. 9, including:
A sending module 902, configured to send an acquisition request to a target proxy server through a target port, where the acquisition request is used to acquire current configuration information of the target proxy server;
A receiving module 904, configured to receive current configuration information returned by a target thread in a target proxy server, where the target thread is configured to monitor a target port;
a comparison module 906, configured to compare the current configuration information with first configuration information in the database, where the first configuration information is used to represent configuration information generated by the target proxy server when receiving the remote procedure call request;
A first determining module 908 is configured to determine that the remote procedure call request has an exception if the current configuration information does not match the first configuration information.
Alternatively, the method for monitoring the configuration of the proxy server can be applied to the cluster. There may be multiple nodes in a cluster, and the nodes may be master nodes (host nodes). There may be one or more slave nodes under each master node.
The target proxy server can provide proxy service for the main control node. Each master node may have a corresponding proxy server therein.
The target port may be a port provided by the monitoring service to the proxy server on the master node, the proxy server listens to the target port, and the monitoring service may send a request to the proxy server through the target port. If an acquisition request is sent, the current configuration information of the proxy server is requested to be acquired.
The database may be a redis database for storing user data. The first configuration information may be included in the user data. The first configuration information is information configured by a user. The monitoring service in this embodiment can only read the data in the database and cannot rewrite the part of the data. The first configuration information may represent configuration information generated if the target proxy server receives rpc a request.
In the method, the target thread can monitor the target port, the monitoring service is used for sending the acquisition request to the proxy server to acquire the current configuration information of the proxy server, and the current configuration information is compared with the first configuration information in the database under the condition that the rpc request is normal, so that whether the current configuration information in the proxy server is correct or not can be compared, and if not, the rpc request is abnormal. The purpose of monitoring whether rpc requests are lost or not and whether the configuration is normally issued is achieved, and further the technical problem that whether rpc requests are lost or not and whether the configuration is normally issued or not is solved.
For other examples of this embodiment, please refer to the above examples, and are not described herein.
Fig. 10 is a block diagram of an alternative electronic device, according to an embodiment of the application, as shown in fig. 10, including a processor 1002, a communication interface 1004, a memory 1006, and a communication bus 1008, wherein the processor 1002, the communication interface 1004, and the memory 1006 communicate with each other via the communication bus 1008, wherein,
A memory 1006 for storing a computer program;
Processor 1002, when executing computer programs stored on memory 1006, performs the following steps:
Sending an acquisition request to a target proxy server through a target port, wherein the acquisition request is used for acquiring the current configuration information of the target proxy server;
receiving current configuration information returned by a target thread in a target proxy server, wherein the target thread is used for monitoring a target port;
Comparing the current configuration information with first configuration information in a database, wherein the first configuration information is used for representing the configuration information generated by the target proxy server under the condition of receiving a remote procedure call request;
and under the condition that the current configuration information is not matched with the first configuration information, determining that the remote procedure call request is abnormal.
Alternatively, in the present embodiment, the above-described communication bus may be a PCI (PERIPHERAL COMPONENT INTERCONNECT, peripheral component interconnect standard) bus, or an EISA (Extended Industry Standard Architecture ) bus, or the like. The communication bus may be classified as an address bus, a data bus, a control bus, or the like. For ease of illustration, only one thick line is shown in fig. 10, but not only one bus or one type of bus. The communication interface is used for communication between the electronic device and other devices.
The memory may include RAM or may include non-volatile memory (non-volatile memory), such as at least one disk memory. Optionally, the memory may also be at least one memory device located remotely from the aforementioned processor.
As an example, the memory 1006 may include, but is not limited to, a sending module 902, a receiving module 904, a comparing module 906, and a first determining module 908 in the configuration monitoring device including the proxy server. In addition, other module units in the processing apparatus of the above request may be included, but are not limited to, and are not described in detail in this example.
The processor may be a general-purpose processor, including but not limited to a CPU (Central Processing Unit ), NP (Network Processor, network processor), DSP (DIGITAL SIGNAL Processing unit), ASIC (Application SPECIFIC INTEGRATED Circuit), FPGA (Field-Programmable gate array) or other Programmable logic device, discrete gate or transistor logic device, discrete hardware components.
Alternatively, specific examples in this embodiment may refer to examples described in the foregoing embodiments, and this embodiment is not described herein.
It will be understood by those skilled in the art that the structure shown in fig. 10 is only schematic, and the device implementing the configuration monitoring method of the proxy server may be a terminal device, and the terminal device may be a smart phone (such as an Android Mobile phone, an iOS Mobile phone, etc.), a tablet computer, a palm computer, a Mobile internet device (Mobile INTERNET DEVICES, MID), a PAD, etc. Fig. 10 is not limited to the structure of the electronic device described above. For example, the electronic device may also include more or fewer components (e.g., network interfaces, display devices, etc.) than shown in FIG. 10, or have a different configuration than shown in FIG. 10.
Those of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be implemented by a program for instructing a terminal device to execute on associated hardware, and the program may be stored in a computer readable storage medium, where the storage medium may include a flash disk, a ROM, a RAM, a magnetic disk, an optical disk, or the like.
According to yet another aspect of the embodiments of the present invention, there is also provided a computer-readable storage medium having a computer program stored therein, wherein the computer program when executed by a processor performs the steps in the configuration monitoring method of a proxy server described above.
Alternatively, in this embodiment, all or part of the steps in the various methods of the above embodiments may be implemented by a program for instructing the terminal device related hardware, and the program may be stored in a computer readable storage medium, where the storage medium may include a flash disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a magnetic disk, or an optical disk.
The foregoing embodiment numbers of the present invention are merely for the purpose of description, and do not represent the advantages or disadvantages of the embodiments.
The integrated units in the above embodiments may be stored in the above-described computer-readable storage medium if implemented in the form of software functional units and sold or used as separate products. Based on such understanding, the technical solution of the present invention may be embodied in essence or a part contributing to the prior art or all or part of the technical solution in the form of a software product stored in a storage medium, comprising several instructions for causing one or more computer devices (which may be personal computers, servers or network devices, etc.) to perform all or part of the steps of the method described in the embodiments of the present invention.
In the foregoing embodiments of the present invention, the descriptions of the embodiments are emphasized, and for a portion of this disclosure that is not described in detail in this embodiment, reference is made to the related descriptions of other embodiments.
In several embodiments provided by the present application, it should be understood that the disclosed client may be implemented in other manners. The above-described embodiments of the apparatus are merely exemplary, and the division of the units, such as the division of the units, is merely a logical function division, and may be implemented in another manner, for example, multiple units or components may be combined or may be integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be through some interfaces, units or modules, or may be in electrical or other forms.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present invention may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The foregoing is merely a preferred embodiment of the present invention and it should be noted that modifications and adaptations to those skilled in the art may be made without departing from the principles of the present invention, which are intended to be comprehended within the scope of the present invention.