Equipment online state calculation method, equipment and storage medium

By utilizing the dual judgment mechanism of the local server and the remote server in the cluster system to confirm the online status of the device, the problem of status misjudgment caused by the device heartbeat load is solved, and correct and efficient calculation of the device online status is achieved.

CN118827481AActive Publication Date: 2024-10-22CHINA MOBILE M2M +1
View PDF 9 Cites 0 Cited by

Patent Information

Application Number
CN202311597847.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-11-27
Publication Date
2024-10-22
Estimated Expiration
2043-11-27

AI Technical Summary

Technical Problem

In a cluster system composed of multiple application systems, when the device heartbeat load is transferred from one server to another, it is easy to cause misjudgment of the device status.

Method used

Receive the device's heartbeat message through the local server, add the target device ID to the target queue, and send it to the remote server for confirmation. The remote server calculates the status of the device based on the received heartbeat message, reducing server resource usage and performing dual judgments. To avoid misjudgment of status.

Benefits of technology

It effectively avoids misjudgment of status when the device heartbeat is loaded to other servers, can correctly and efficiently calculate the online status of the device, and reduces the occupation of server resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118827481A_ABST
    Figure CN118827481A_ABST
Patent Text Reader

Abstract

The invention discloses an equipment online state calculation method, equipment and a storage medium, and the method comprises the steps: determining a target equipment identifier of target equipment through a local server, adding the target equipment identifier into a target queue, and transmitting the target queue to a remote server; the far-end server confirms a target heartbeat message corresponding to the target device identifier according to all received heartbeat messages sent by all devices successfully connected with the local server, and further confirms the state of the target device according to the target heartbeat message; wherein the target device is a device with overtime heartbeat in all the devices. According to the embodiment of the invention, the resource occupation condition of the server can be reduced, the heartbeat timeout condition of the equipment is doubly judged, the condition that the equipment state is misjudged when the heartbeat of the equipment is loaded to other servers is solved, and the online state of the equipment can be correctly and efficiently calculated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of device online status calculation, and in particular to a device online status calculation method, device and storage medium. Background Art

[0002] As the scale of IoT device connections continues to grow, higher requirements are placed on the number of connections and processing capabilities of the system. Single application systems can no longer meet the needs of large-scale device connections, so cluster systems consisting of multiple application systems have gradually emerged, which can effectively expand the scale of device connections.

[0003] However, in a cluster system composed of multiple application systems, if the load of a device changes from server A to server B during the heartbeat cycle, server A will find that the device heartbeat has timed out during polling, resulting in a misjudgment of the device status. Summary of the invention

[0004] The present invention provides a method, a device and a storage medium for calculating the online status of a device, so as to solve the problem in the prior art that when the heartbeat of the device is loaded to other servers, the device status may be misjudged.

[0005] To achieve the above object, an embodiment of the present invention provides a method for calculating the online status of a device, which is applied to a remote server. The method for calculating the online status of a device includes:

[0006] Receive all heartbeat messages sent by all devices that are successfully connected to the local server; wherein each of the heartbeat messages includes at least: a device identifier and a heartbeat timestamp;

[0007] Receive a target queue sent by the local server; wherein the target queue stores the target device identifier of the target device confirmed by the local server, and the target device is a device whose heartbeat has timed out among all the devices;

[0008] According to all the heartbeat messages, obtaining a target heartbeat message corresponding to the target device identifier;

[0009] The status of the target device is confirmed according to the target heartbeat message.

[0010] As an improvement of the above solution, each of the heartbeat messages further includes: a heartbeat timeout period.

[0011] As an improvement of the above solution, the step of confirming the state of the target device according to the target heartbeat message includes:

[0012] Calculate a first time difference between the current time and the heartbeat timestamp in the target heartbeat message;

[0013] If the first time difference is greater than a preset first heartbeat timeout period, confirming that the target device is in an offline state;

[0014] If the first time difference is less than or equal to the first heartbeat timeout period, it is confirmed that the target device is online.

[0015] As an improvement of the above solution, the device online status calculation method further includes:

[0016] When the number of the target device identifiers stored in the target queue is greater than a preset number threshold, the target queue is split into a plurality of sub-target queues.

[0017] As an improvement of the above solution, the target queue stores the target device identifier of the target device confirmed by the local server, including:

[0018] The target queue stores the target device identifiers of the target devices confirmed by the local server according to all the heartbeat messages sent by all the devices successfully connected to the local server.

[0019] To achieve the above object, an embodiment of the present invention further provides a method for calculating the online status of a device, which is applied to a local server. The method for calculating the online status of a device includes:

[0020] Receive all heartbeat messages sent by all devices that are successfully connected to the local server; wherein each of the heartbeat messages includes at least: a device identifier and a heartbeat timestamp;

[0021] Confirm the target device identifier of the target device according to all the heartbeat messages; wherein the target device is the device whose heartbeat has timed out among all the devices;

[0022] The target device identifier is added to a target queue, and the target queue is sent to a remote server, so that the remote server confirms the status of the target device according to all heartbeat messages received from all devices that are successfully connected to the local server.

[0023] As an improvement of the above solution, the step of confirming the target device identifier of the target device according to all the heartbeat messages includes:

[0024] Calculate a second time difference between the current time and the heartbeat timestamp in the heartbeat message;

[0025] If the second time difference is greater than a preset second heartbeat timeout period, confirming that the device is the target device;

[0026] If the second time difference is less than or equal to the second heartbeat timeout period, it is confirmed that the device is not the target device.

[0027] As an improvement of the above solution, the target device identifier is added to a target queue, and the target queue is sent to a remote server, so that the remote server confirms the status of the target device according to all heartbeat messages sent by all devices that are successfully connected to the local server, including:

[0028] The target device identifier is added to a target queue, and the target queue is sent to a remote server, so that the remote server obtains a target heartbeat message corresponding to the target device identifier based on all heartbeat messages received from all devices that are successfully connected to the local server, and confirms the status of the target device based on the target heartbeat message.

[0029] To achieve the above objectives, an embodiment of the present invention further provides a device online status calculation device, comprising a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor implements the device online status calculation method as described above when executing the computer program.

[0030] To achieve the above-mentioned purpose, an embodiment of the present invention further provides a computer-readable storage medium, which includes a stored computer program; wherein, when the computer program is running, it controls the device where the computer-readable storage medium is located to execute the device online status calculation method as described above.

[0031] Compared with the prior art, the embodiment of the present invention provides a method, device and storage medium for calculating the online status of a device. The target device identifier of the target device is confirmed by a local server, and the target device identifier is added to a target queue and sent to a remote server. The remote server confirms the target heartbeat message corresponding to the target device identifier according to all the heartbeat messages sent by all the devices that are successfully connected to the local server, and then confirms the status of the target device according to the target heartbeat message; wherein the target device is the device with a heartbeat timeout among all the devices. It can be seen that the embodiment of the present invention uses the local server to calculate the device (target device) with a heartbeat timeout among the devices that are successfully connected to the local server, and the remote server calculates the device with a heartbeat timeout among the target devices. There is no need to start a heartbeat detection thread for each device to regularly detect whether the device heartbeat has timed out, which reduces the server resource occupation, and performs a double judgment on the heartbeat timeout of the device, which can effectively avoid the situation where the device status is misjudged when the device heartbeat is loaded to other servers. The embodiment of the present invention can correctly and efficiently calculate the online status of the device. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] Figure 1is a flow chart of a method for calculating the online status of a device provided by an embodiment of the present invention;

[0033] Figure 2 is another flow chart of a method for calculating the online status of a device provided by an embodiment of the present invention;

[0034] Figure 3 is another flow chart of a method for calculating the online status of a device provided by an embodiment of the present invention;

[0035] Figure 4 It is a structural block diagram of a device online status calculation apparatus provided by an embodiment of the present invention;

[0036] Figure 5 is another structural block diagram of a device online status calculation apparatus provided by an embodiment of the present invention;

[0037] Figure 6 It is a structural block diagram of a device online status calculation device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0038] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0039] See also Figure 1 , Figure 1 1 is a flow chart of a method for calculating the online status of a device provided by an embodiment of the present invention. The method for calculating the online status of a device is applied to a remote server and includes:

[0040] S11, receiving all heartbeat messages sent by all devices that are successfully connected to the local server; wherein each of the heartbeat messages at least includes: a device identifier and a heartbeat timestamp;

[0041] S12, receiving a target queue sent by the local server; wherein the target queue stores a target device identifier of a target device confirmed by the local server, and the target device is a device whose heartbeat has timed out among all the devices;

[0042] S13. Acquire a target heartbeat message corresponding to the target device identifier according to all the heartbeat messages;

[0043] S14. Confirm the status of the target device according to the target heartbeat message.

[0044] It can be understood that the embodiment of the present invention can calculate the online status of distributed devices. When the device is successfully connected to the local server, the device sends a heartbeat message to the local server and the remote server. The local server confirms the target device identifier of the target device (device with heartbeat timeout) according to the received heartbeat message, and adds the target device identifier to the target queue and sends it to the remote server. The remote server confirms the target heartbeat message corresponding to the target device identifier according to the received heartbeat message, and confirms the status of the target device according to the target heartbeat message, which can reduce the server resource usage. In addition, by performing a double judgment on the heartbeat timeout of the device, it can effectively avoid the situation where the device status is misjudged when the device heartbeat load is transferred to other servers. The embodiment of the present invention can correctly and efficiently calculate the online status of the device.

[0045] In an optional implementation, each of the heartbeat messages further includes: a heartbeat timeout period.

[0046] In an embodiment of the present invention, each of the heartbeat messages also includes: a heartbeat timeout period; the heartbeat timeout period of each device may be the same or different, and the embodiment of the present invention may determine the heartbeat timeout of the device based on the heartbeat timeout period carried by the heartbeat message.

[0047] In an optional implementation, confirming the state of the target device according to the target heartbeat message includes:

[0048] Calculate a first time difference between the current time and the heartbeat timestamp in the target heartbeat message;

[0049] If the first time difference is greater than a preset first heartbeat timeout period, confirming that the target device is in an offline state;

[0050] If the first time difference is less than or equal to the first heartbeat timeout period, it is confirmed that the target device is online.

[0051] It is understandable that the first heartbeat timeout period corresponds to a device, and the first heartbeat timeout period of each device can be the same or different. Of course, the first heartbeat timeout period can be stored in the remote server in advance, or can be sent via the heartbeat message, and the heartbeat timeout period carried by the heartbeat message can be used as the second heartbeat timeout period.

[0052] In an optional implementation, the device online status calculation method further includes:

[0053] When the number of the target device identifiers stored in the target queue is greater than a preset number threshold, the target queue is split into a plurality of sub-target queues.

[0054] It is understandable that when the number of target device identifiers stored in the target queue is too large, the processing efficiency will be affected. In order to speed up the processing efficiency, when the number of target device identifiers stored in the target queue is too large, the target queue will be task-split into multiple sub-target queues to avoid the remote heartbeat detection thread always polling the target queue and affecting the processing of other tasks.

[0055] In an optional implementation manner, the target queue stores the target device identifier of the target device confirmed by the local server, including:

[0056] The target queue stores the target device identifiers of the target devices confirmed by the local server according to all the heartbeat messages sent by all the devices successfully connected to the local server.

[0057] It is understandable that before the remote server makes a judgment, the local server makes a judgment. Specifically, the local server confirms the target device identifier of the target device (device with heartbeat timeout) based on all heartbeat messages sent by all devices that are successfully connected to itself; then, the remote server makes another judgment to confirm whether the heartbeat of the target device has timed out and obtain the status of the target device. The embodiment of the present invention solves the problem of misjudgment caused by the device heartbeat load being transferred to other servers through double judgment, which is more in line with the actual usage scenarios and needs of users than the existing solutions.

[0058] In an optional implementation, after confirming the state of the target device according to the target heartbeat message, the device online state calculation method further includes:

[0059] The state of the target device is updated to the remote cache of the remote server.

[0060] It is understandable that the remote server also stores the connection status of the device, and when the status of the target device is confirmed, it is updated in the remote cache of the remote server.

[0061] In a specific embodiment, if Figure 2 As shown, heartbeat detection threads are created locally and remotely respectively;

[0062] 1. The device successfully connects to the local server, sends a heartbeat message, and stores the device ID, heartbeat timestamp, and heartbeat timeout in the local cache LC and the remote cache RC.

[0063] 2. The local heartbeat detection thread LT polls the device list in the local cache LC to determine whether the difference between the current time and the latest heartbeat time is greater than the heartbeat timeout. If it is greater, the device identifier is added to the target queue LQ;

[0064] 3. The remote heartbeat detection thread RT takes out the device list from the target queue LQ. If the device list is too large, the device list is split into tasks. The latest heartbeat time is taken out from the remote cache RC according to the device identifier. It is determined whether the difference between the current time and the latest heartbeat time is greater than the heartbeat timeout. If it is greater, the device is judged to be offline. At the same time, the latest online status of the device is updated in the remote cache RC.

[0065] In the embodiment of the present invention, the heartbeat detection thread is divided into different work responsibilities, the local heartbeat detection thread LT calculates the device list with heartbeat timeout in the local cache LC, and the remote heartbeat detection thread RT calculates the device list with heartbeat timeout in the target queue LQ, thereby reducing the resource occupation of the heartbeat thread on the server. Moreover, the local heartbeat detection thread LT and the remote heartbeat detection thread RT coordinate work and make double judgments through the target queue LQ and the remote cache RC, thereby solving the problem of misjudgment of device status when the device heartbeat packet is loaded to other servers in a distributed scenario.

[0066] See also Figure 3 , Figure 3 is another flow chart of a method for calculating a device online status provided by an embodiment of the present invention, wherein the method for calculating a device online status is applied to a local server and includes:

[0067] S21, receiving all heartbeat messages sent by all devices that are successfully connected to the local server; wherein each of the heartbeat messages includes at least: a device identifier and a heartbeat timestamp;

[0068] S22, confirming the target device identifier of the target device according to all the heartbeat messages; wherein the target device is the device whose heartbeat has timed out among all the devices;

[0069] S23, adding the target device identifier to a target queue, and sending the target queue to a remote server, so that the remote server confirms the status of the target device according to all heartbeat messages received from all devices that are successfully connected to the local server.

[0070] In an optional implementation, confirming the target device identifier of the target device according to all the heartbeat messages includes:

[0071] Calculate a second time difference between the current time and the heartbeat timestamp in the heartbeat message;

[0072] If the second time difference is greater than a preset second heartbeat timeout period, confirming that the device is the target device;

[0073] If the second time difference is less than or equal to the second heartbeat timeout period, it is confirmed that the device is not the target device.

[0074] It is understandable that the second heartbeat timeout period corresponds to the device, and the second heartbeat timeout period of each device can be the same or different. Of course, the second heartbeat timeout period can be stored in the local server in advance, or can be sent via the heartbeat message, and the heartbeat timeout period carried by the heartbeat message can be used as the second heartbeat timeout period.

[0075] In an optional implementation, adding the target device identifier to a target queue and sending the target queue to a remote server so that the remote server confirms the status of the target device according to all heartbeat messages received from all devices that are successfully connected to the local server, including:

[0076] The target device identifier is added to a target queue, and the target queue is sent to a remote server, so that the remote server obtains a target heartbeat message corresponding to the target device identifier based on all heartbeat messages received from all devices that are successfully connected to the local server, and confirms the status of the target device based on the target heartbeat message.

[0077] In an optional implementation, each of the heartbeat messages further includes: a heartbeat timeout period.

[0078] It should be noted that this embodiment is an implementation of the local server corresponding to the above method embodiment, and therefore, reference may be made to the relevant description in the above method embodiment, and the same beneficial effects can be achieved. To avoid repeated description, it will not be repeated here.

[0079] See also Figure 4 , Figure 4 : is a structural block diagram of a device online status calculation device provided by an embodiment of the present invention, wherein the device online status calculation device is applied to a remote server and includes:

[0080] The first heartbeat message receiving module 11 is used to receive all heartbeat messages sent by all devices that are successfully connected to the local server; wherein each of the heartbeat messages at least includes: a device identifier and a heartbeat timestamp;

[0081] The target queue receiving module 12 is used to receive the target queue sent by the local server; wherein the target queue stores the target device identifier of the target device confirmed by the local server, and the target device is the device whose heartbeat has timed out among all the devices;

[0082] A target heartbeat message acquisition module 13 is used to acquire a target heartbeat message corresponding to the target device identifier according to all the heartbeat messages;

[0083] The target device status confirmation module 14 is used to confirm the status of the target device according to the target heartbeat message.

[0084] Optionally, each of the heartbeat messages also includes: a heartbeat timeout period.

[0085] Optionally, the target device status confirmation module 14 is specifically used to:

[0086] Calculate a first time difference between the current time and the heartbeat timestamp in the target heartbeat message;

[0087] If the first time difference is greater than a preset first heartbeat timeout period, confirming that the target device is in an offline state;

[0088] If the first time difference is less than or equal to the first heartbeat timeout period, it is confirmed that the target device is online.

[0089] Optionally, the device online status calculation device further includes:

[0090] The splitting module is used to split the target queue into multiple sub-target queues when the number of the target device identifiers stored in the target queue is greater than a preset number threshold.

[0091] Optionally, the target queue stores a target device identifier of a target device confirmed by the local server, including:

[0092] The target queue stores the target device identifiers of the target devices confirmed by the local server according to all the heartbeat messages sent by all the devices successfully connected to the local server.

[0093] Optionally, the device online status calculation device further includes:

[0094] The status update module is used to update the status of the target device to the remote cache of the remote server.

[0095] It should be noted that the above-mentioned device online status calculation apparatus in this embodiment can implement any steps in the device online status calculation method embodiment applied to a remote server in the embodiment of the present invention, and achieve the same beneficial effects, which will not be repeated here.

[0096] See also Figure 5 , Figure 5 : is another structural block diagram of a device online status calculation device provided by an embodiment of the present invention, wherein the device online status calculation device is applied to a local server and includes:

[0097] The second heartbeat message receiving module 21 is used to receive all heartbeat messages sent by all devices that are successfully connected to the local server; wherein each of the heartbeat messages at least includes: a device identifier and a heartbeat timestamp;

[0098] A target device confirmation module 22, used to confirm the target device identifier of the target device according to all the heartbeat messages; wherein the target device is the device whose heartbeat has timed out among all the devices;

[0099] The target queue sending module 23 is used to add the target device identifier to the target queue and send the target queue to the remote server, so that the remote server confirms the status of the target device according to all heartbeat messages sent by all devices successfully connected to the local server.

[0100] Optionally, the target device confirmation module 22 is specifically used for:

[0101] Calculate a second time difference between the current time and the heartbeat timestamp in the heartbeat message;

[0102] If the second time difference is greater than a preset second heartbeat timeout period, confirming that the device is the target device;

[0103] If the second time difference is less than or equal to the second heartbeat timeout period, it is confirmed that the device is not the target device.

[0104] Optionally, the target queue sending module 23 is specifically used for:

[0105] The target device identifier is added to a target queue, and the target queue is sent to a remote server, so that the remote server obtains a target heartbeat message corresponding to the target device identifier based on all heartbeat messages received from all devices that are successfully connected to the local server, and confirms the status of the target device based on the target heartbeat message.

[0106] Optionally, each of the heartbeat messages also includes: a heartbeat timeout period.

[0107] It should be noted that the above-mentioned device online status calculation apparatus in this embodiment can implement any steps in the device online status calculation method embodiment applied to the local server in the embodiment of the present invention, and achieve the same beneficial effects, which will not be repeated here.

[0108] An embodiment of the present invention further provides a computer-readable storage medium, which includes a stored computer program; wherein, when the computer program is running, it controls the device where the computer-readable storage medium is located to execute the device online status calculation method as described in any of the above embodiments.

[0109] See also Figure 6 , Figure 6 : is a structural block diagram of a device online status calculation device provided by an embodiment of the present invention, and the device online status calculation device includes: a processor 31, a memory 32, and a computer program stored in the memory 32 and executable on the processor 31. When the processor 31 executes the computer program, the steps in the above-mentioned device online status calculation method embodiment are implemented. Alternatively, when the processor 31 executes the computer program, the functions of each module / unit in the above-mentioned device embodiments are implemented.

[0110] Exemplarily, the computer program may be divided into one or more modules / units, which are stored in the memory 32 and executed by the processor 31 to implement the present invention. The one or more modules / units may be a series of computer program instruction segments capable of implementing specific functions, which are used to describe the execution process of the computer program in the device online status computing device.

[0111] The device online status calculation device may include, but is not limited to, a processor 31 and a memory 32. Those skilled in the art may understand that the schematic diagram is only an example of the device online status calculation device and does not constitute a limitation on the device online status calculation device. The device online status calculation device may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the device online status calculation device may also include input and output devices, network access devices, buses, etc.

[0112] The processor 31 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc. The processor 31 is the control center of the device online status calculation device, and uses various interfaces and lines to connect various parts of the entire device online status calculation device.

[0113] The memory 32 can be used to store the computer program and / or module. The processor 31 realizes various functions of the device online status calculation device by running or executing the computer program and / or module stored in the memory 32 and calling the data stored in the memory 32. The memory 32 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), etc. In addition, the memory 32 can include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (SecureDigital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.

[0114] Wherein, if the module / unit integrated in the device online status calculation device is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor 31. Wherein, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electrical carrier signal, telecommunication signal and software distribution medium, etc.

[0115] It should be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the accompanying drawings of the device embodiments provided by the present invention, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines. A person of ordinary skill in the art may understand and implement it without paying any creative effort.

[0116] The above is a preferred embodiment of the present invention. It should be pointed out that a person skilled in the art can make several improvements and modifications without departing from the principle of the present invention. These improvements and modifications are also considered to be within the scope of protection of the present invention.

Claims

1. A method for calculating the online status of a device, characterized in that: Applied to a remote server, the device online status calculation method includes: Receive all heartbeat messages sent by all devices that are successfully connected to the local server; wherein each of the heartbeat messages includes at least: a device identifier and a heartbeat timestamp; Receive a target queue sent by the local server; wherein the target queue stores the target device identifier of the target device confirmed by the local server, and the target device is a device whose heartbeat has timed out among all the devices; According to all the heartbeat messages, obtaining a target heartbeat message corresponding to the target device identifier; The status of the target device is confirmed according to the target heartbeat message.

2. The device online status calculation method according to claim 1, characterized in that: Each of the heartbeat messages also includes: a heartbeat timeout period.

3. The device online status calculation method according to claim 1, characterized in that: The confirming the state of the target device according to the target heartbeat message includes: Calculate a first time difference between the current time and the heartbeat timestamp in the target heartbeat message; If the first time difference is greater than a preset first heartbeat timeout period, confirming that the target device is in an offline state; If the first time difference is less than or equal to the first heartbeat timeout period, it is confirmed that the target device is online.

4. The device online status calculation method according to claim 1, characterized in that: The device online status calculation method also includes: When the number of the target device identifiers stored in the target queue is greater than a preset number threshold, the target queue is split into a plurality of sub-target queues.

5. The device online status calculation method according to claim 1, characterized in that: The target queue stores the target device identifier of the target device confirmed by the local server, including: The target queue stores the target device identifiers of the target devices confirmed by the local server according to all the heartbeat messages sent by all the devices successfully connected to the local server.

6. A method for calculating the online status of a device, characterized in that: Applied to a local server, the device online status calculation method includes: Receive all heartbeat messages sent by all devices that are successfully connected to the local server; wherein each of the heartbeat messages includes at least: a device identifier and a heartbeat timestamp; Confirm the target device identifier of the target device according to all the heartbeat messages; wherein the target device is the device whose heartbeat has timed out among all the devices; The target device identifier is added to a target queue, and the target queue is sent to a remote server, so that the remote server confirms the status of the target device according to all heartbeat messages received from all devices that are successfully connected to the local server.

7. The method for calculating the online status of a device according to claim 6, characterized in that: The step of confirming the target device identifier of the target device according to all the heartbeat messages includes: Calculate a second time difference between the current time and the heartbeat timestamp in the heartbeat message; If the second time difference is greater than a preset second heartbeat timeout period, confirming that the device is the target device; If the second time difference is less than or equal to the second heartbeat timeout period, it is confirmed that the device is not the target device.

8. The method for calculating the online status of a device according to claim 6, characterized in that: The step of adding the target device identifier to a target queue and sending the target queue to a remote server, so that the remote server confirms the status of the target device according to all heartbeat messages received from all devices successfully connected to the local server, includes: The target device identifier is added to a target queue, and the target queue is sent to a remote server, so that the remote server obtains a target heartbeat message corresponding to the target device identifier based on all heartbeat messages received from all devices that are successfully connected to the local server, and confirms the status of the target device based on the target heartbeat message.

9. A device for calculating the online status of a device, characterized in that: The method comprises a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor implements the device online status calculation method according to any one of claims 1 to 8 when executing the computer program.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored computer program; wherein, when the computer program is run, it controls the device where the computer-readable storage medium is located to execute the device online status calculation method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Equipment survival detection method and equipment survival detection device

    CN103634166A

  • Heartbeat package processing method and device

    CN104166589A

  • Terminal on-line detection method, terminal and server

    CN105071996A

  • Network equipment online state monitoring system and method

    CN105553685A

  • Method and system for monitoring the running state of equipment

    CN109905286A