A method, server, device and system for obtaining log files
By issuing and listening logs in the intermediary database, the problem that the inter -network segment device cannot obtain the log file was solved, and the test server's cross -network segment acquisition of the router log file was realized to support the test of the statistical function of the application duration.
Patent Information
- Application Number
- CN201811518400.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2018-12-12
- Publication Date
- 2025-01-28
- Estimated Expiration
- 2038-12-12
AI Technical Summary
During the process of obtaining log files, devices in different network segments cannot achieve cross-net segment acquisition of log files, resulting in the test server being unable to obtain the router's application time statistics.
By obtaining a logar for the logging of the test device in the intermediary database, and monitor whether the intermediary database has a corresponding log file, it is obtained when the log file is found. The intermediary database can use the Redis or MySQL database, and use its subscription and release function to achieve the log file of the cross -network segment.
The log file acquisition of cross -network segments is implemented, allowing the test server to obtain the log file of the router under the conditions of different network segments, thereby completing the test of the application duration statistical function.
Smart Images

Figure CN111309694B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method for obtaining a log file, a server, a device, a system, an electronic device, and a computer-readable storage medium. Background Art
[0002] When obtaining log files, it is impossible to obtain log files between devices that use different network segments to access the Internet. For example, when testing the application duration statistics function of a router, the router uses the first network segment to access the Internet, while the test server uses the second network segment to access the Internet, and the first network segment and the second network segment have no intersection. In this way, the test server cannot obtain the application duration counted by the router and cannot complete the test of the application duration statistics function of the router. Therefore, a solution for obtaining log files across network segments is urgently needed. Summary of the invention
[0003] In view of the above problems, the present invention is proposed to provide a method, server, device, system, electronic device and computer-readable storage medium for obtaining log files that overcome the above problems or at least partially solve the above problems.
[0004] According to one aspect of the present invention, a method for obtaining a log file is provided, wherein the method comprises:
[0005] When receiving a message that the test of the test device has ended, publishing a log acquisition request for the test device to the intermediary database;
[0006] Monitor whether there is a log file corresponding to the test device in the intermediary database;
[0007] When it is monitored that there is a log file corresponding to the test device in the intermediary database, the log file is obtained.
[0008] Optionally, the intermediary database is a Redis database;
[0009] The step of publishing the log acquisition request of the test device to the intermediary database includes: publishing the log acquisition request of the test device to a first channel corresponding to the test device in the Redis database;
[0010] The monitoring whether there is a log file corresponding to the test device in the intermediary database includes: subscribing to a second channel corresponding to the test device in the Redis database; when there is data in the second channel, determining whether there is a log file corresponding to the test device in the Redis database;
[0011] The first channel corresponds to the second channel one by one.
[0012] Optionally, the first channel and the second channel are identified according to a MAC address of a test device.
[0013] Optionally, the intermediary database is a MySQL database;
[0014] The step of publishing the log acquisition request of the test device to the intermediary database includes: publishing the log acquisition request of the test device to a first field corresponding to the test device in a specified data table of a Mysql database;
[0015] The monitoring of whether there is a log file corresponding to the test device in the intermediate database includes: polling and monitoring whether there is data in the second field corresponding to the test device in the specified data table of the Mysql database; when it is monitored that there is data in the second field, determining that there is a log file corresponding to the test device in the Mysql database.
[0016] Optionally, the polling and monitoring whether there is data in the second field corresponding to the test device in the specified data table of the Mysql database includes:
[0017] Set a preset time or preset frequency;
[0018] At every preset time or at a preset frequency, query whether there is data in the second field corresponding to the test device in the specified data table of the Mysql database.
[0019] Optionally, the first field and the second field corresponding to each test device in the specified data table specifically correspond to the MAC address of the test device.
[0020] Optionally, the method further comprises:
[0021] It is determined whether the usage time of each application in the obtained log file is consistent with the preset time in the corresponding test case. If it is determined to be consistent, the test passes.
[0022] According to another aspect of the present invention, a method for obtaining a log file is provided, wherein the method comprises:
[0023] Get the log files corresponding to each test device in the router;
[0024] Monitor whether there are log acquisition requests corresponding to each test device in the intermediary database;
[0025] When a log acquisition request of a test device in the intermediary database is monitored, the log file corresponding to the test device is published to the intermediary database according to the log acquisition request.
[0026] Optionally, the intermediary database is a Redis database;
[0027] The monitoring whether there is a log acquisition request corresponding to each test device in the intermediary database includes: subscribing to a first channel corresponding to each test device in the Redis database; when there is data in the first channel corresponding to a test device, determining whether there is a log acquisition request corresponding to the test device in the Redis database;
[0028] Publishing the log file corresponding to the test device to the intermediary database includes: publishing the log file corresponding to the test device to a second channel corresponding to the test device in the Redis database;
[0029] The first channel corresponds to the second channel one by one.
[0030] Optionally, the first channel and the second channel are identified according to a MAC address of a test device.
[0031] Optionally, the intermediary database is a MySQL database;
[0032] The monitoring whether there are log acquisition requests corresponding to each test device in the intermediary database comprises: polling and monitoring whether there is data in the first field corresponding to each test device in the specified data table of the Mysql database; when it is monitored that there is data in the first field corresponding to a test device in the specified data table, determining that there is a log acquisition request corresponding to the test device in the Mysql database;
[0033] The publishing the log file corresponding to the test device to the intermediary database includes: publishing the log file corresponding to the test device to a second field corresponding to the test device in a designated data table of the Mysql database.
[0034] Optionally, the polling and monitoring whether there is data in the first field corresponding to each test device in the specified data table of the Mysql database includes:
[0035] Set a preset time or preset frequency;
[0036] At every preset time or at a preset frequency, query whether there is data in the first field corresponding to the test device in the specified data table of the Mysql database.
[0037] Optionally, the first field and the second field corresponding to each test device in the specified data table specifically correspond to the MAC address of the test device.
[0038] Optionally, the method further comprises:
[0039] Analyze the obtained log files corresponding to each test device; obtain the usage time of each application corresponding to each test device;
[0040] The publishing the log file corresponding to the test device to the intermediary database includes: publishing the obtained usage duration of each application corresponding to the test device as the log file corresponding to the test device to the intermediary database.
[0041] According to another aspect of the present invention, a log file acquisition server is provided, wherein the server comprises:
[0042] A publishing unit, adapted to publish a log acquisition request of the test device to the intermediary database when receiving a message that the test of the test device is finished;
[0043] A monitoring unit, adapted to monitor whether there is a log file corresponding to the test device in the intermediary database;
[0044] The acquisition unit is adapted to acquire the log file when it is monitored that there is a log file corresponding to the test device in the intermediary database.
[0045] Optionally, the intermediary database is a Redis database;
[0046] The publishing unit is adapted to publish the log acquisition request of the test device to the first channel corresponding to the test device in the Redis database;
[0047] The monitoring unit is adapted to subscribe to a second channel corresponding to the test device in the Redis database; when there is data in the second channel, determine that there is a log file corresponding to the test device in the Redis database;
[0048] The first channel corresponds to the second channel one by one.
[0049] Optionally, the first channel and the second channel are identified according to a MAC address of a test device.
[0050] Optionally, the intermediary database is a MySQL database;
[0051] The publishing unit is adapted to publish the log acquisition request of the test device to a first field corresponding to the test device in a specified data table of a MySQL database;
[0052] The monitoring unit is adapted to poll and monitor whether there is data in the second field corresponding to the test device in the specified data table of the Mysql database; when data is detected in the second field, it is determined that there is a log file corresponding to the test device in the Mysql database.
[0053] Optionally,
[0054] The monitoring unit is adapted to set a preset time or a preset frequency; and query whether there is data in the second field corresponding to the test device in the specified data table of the Mysql database at every preset time or at a preset frequency.
[0055] Optionally, the first field and the second field corresponding to each test device in the specified data table specifically correspond to the MAC address of the test device.
[0056] Optionally, the server further includes:
[0057] The judgment unit is adapted to judge whether the usage duration of each application in the acquired log file is consistent with the preset duration in the corresponding test case. If the judgment is consistent, the test passes.
[0058] According to another aspect of the present invention, a device for obtaining a log file is provided, wherein the device comprises:
[0059] An acquisition unit, adapted to acquire log files corresponding to each test device in the router;
[0060] A monitoring unit, adapted to monitor whether there is a log acquisition request corresponding to each test device in the intermediary database;
[0061] The publishing unit is adapted to publish the log file corresponding to the test device to the intermediary database according to the log acquisition request when a log acquisition request of a test device in the intermediary database is monitored.
[0062] Optionally, the intermediary database is a Redis database;
[0063] The monitoring unit is adapted to subscribe to the first channel corresponding to each test device in the Redis database; when there is data in the first channel corresponding to a test device, it is determined that there is a log acquisition request corresponding to the test device in the Redis database;
[0064] The publishing unit is adapted to publish the log file corresponding to the test device to the second channel corresponding to the test device in the Redis database;
[0065] The first channel corresponds to the second channel one by one.
[0066] Optionally, the first channel and the second channel are identified according to a MAC address of a test device.
[0067] Optionally, the intermediary database is a MySQL database;
[0068] The monitoring unit is adapted to poll and monitor whether there is data in the first field corresponding to each test device in the specified data table of the Mysql database; when it is monitored that there is data in the first field corresponding to a test device in the specified data table, it is determined that there is a log acquisition request corresponding to the test device in the Mysql database;
[0069] The publishing unit is adapted to publish the log file corresponding to the test device to the second field corresponding to the test device in the designated data table of the Mysql database.
[0070] Optionally,
[0071] The monitoring unit is adapted to set a preset time or a preset frequency; and query whether there is data in the first field corresponding to the test device in the specified data table of the Mysql database at every preset time or at a preset frequency.
[0072] Optionally, the first field and the second field corresponding to each test device in the specified data table specifically correspond to the MAC address of the test device.
[0073] Optionally, the device further comprises:
[0074] An analysis unit, adapted to analyze the acquired log files corresponding to each test device, and obtain the usage time of each application corresponding to each test device;
[0075] The publishing unit is adapted to publish the obtained usage duration of each application corresponding to the test device as a log file corresponding to the test device to the intermediary database.
[0076] According to yet another aspect of the present invention, a system for obtaining log files is provided, wherein the system comprises the server as described above, the device as described above, and an intermediary database.
[0077] According to another aspect of the present invention, there is provided an electronic device, wherein the electronic device comprises:
[0078] processor; and,
[0079] A memory arranged to store computer executable instructions which, when executed, cause the processor to perform a method according to the foregoing.
[0080] According to yet another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores one or more programs, and when the one or more programs are executed by a processor, the aforementioned method is implemented.
[0081] According to the technical solution of the present invention, when the test server receives a message indicating that the test of the test device has ended, it publishes a log acquisition request for the test device to the intermediary database; monitors whether there is a log file corresponding to the test device in the intermediary database; and when it is monitored that there is a log file corresponding to the test device in the intermediary database, the log file is acquired. The log file acquisition device acquires the log files corresponding to each test device in the router; monitors whether there are log acquisition requests corresponding to each test device in the intermediary database; when it is monitored that a log acquisition request of a test device in the intermediary database is received, the log file corresponding to the test device is published to the intermediary database according to the log acquisition request. It can be seen that through the technical solution, through the combination of the device and the intermediary database, even if the test server and the router are across network segments, the test server can obtain the log files in the router, thereby realizing the test of the application statistics function of the router.
[0082] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0083] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present invention. Moreover, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:
[0084] Figure 1 A schematic diagram showing a flow chart of a method for obtaining a log file according to an embodiment of the present invention;
[0085] Figure 2 A schematic diagram showing a flow chart of a method for obtaining a log file according to another embodiment of the present invention;
[0086] Figure 3 A schematic diagram showing the structure of a server for obtaining log files according to an embodiment of the present invention is shown;
[0087] Figure 4 A schematic diagram showing the structure of a device for obtaining a log file according to an embodiment of the present invention is shown;
[0088] Figure 5 A schematic diagram showing the structure of a system for obtaining log files according to an embodiment of the present invention is shown;
[0089] Figure 6 A schematic diagram showing the structure of a system for obtaining log files according to another embodiment of the present invention is shown;
[0090] Figure 7 A schematic diagram of the structure of an electronic device according to an embodiment of the present invention is shown;
[0091] Figure 8 A schematic diagram of the structure of a computer-readable storage medium according to an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0092] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0093] Figure 1 The following is a flow chart showing a method for obtaining a log file according to an embodiment of the present invention, which illustrates the technical solution from the server side. Figure 1 As shown, the method includes:
[0094] Step S110: When a message indicating that the test of the test device has ended is received, a log acquisition request of the test device is published to the intermediary database.
[0095] In this embodiment, the server is connected to the test device to control the test device to execute the test case and obtain the test device information. After the test device completes the test case, it will notify the server.
[0096] Step S120: monitor whether there is a log file corresponding to the test device in the intermediary database.
[0097] When the log file acquisition device acquires the log file of the router and sends a log acquisition request to the intermediary database, it will publish the log file corresponding to the test device to the intermediary database. In this embodiment, the server determines whether there is a log file corresponding to the test device in the intermediary database by monitoring.
[0098] Step S130: when it is monitored that there is a log file corresponding to the test device in the intermediary database, the log file is obtained.
[0099] It can be seen that through this technical solution, through the combination of the device and the intermediate database, even if the server and the router are across network segments, the server can obtain the log file in the router, thereby realizing the test of the application statistics function of the router.
[0100] In this technical solution, the intermediary database can use Redis database and MySQL database. Different intermediary databases have different characteristics. Therefore, the execution method of this technical solution is also different, which is described in detail below.
[0101] In one embodiment of the present invention, the intermediary database is a Redis database.
[0102] Figure 1 Publishing the log acquisition request of the test device to the intermediary database in step S110 of the method shown includes: publishing the log acquisition request of the test device to the first channel corresponding to the test device in the Redis database.
[0103] Figure 1 Monitoring whether there is a log file corresponding to the test device in the intermediary database in step S120 of the method shown includes: subscribing to a second channel corresponding to the test device in the Redis database; when there is data in the second channel, determining whether there is a log file corresponding to the test device in the Redis database.
[0104] Among them, the first channel and the second channel correspond one to one.
[0105] In this embodiment, the intermediary database is a Redis database. By using the subscription and publishing functions of the Redis database, the server can subscribe to the channel of the Redis database to determine whether there is a log file in the Redis database.
[0106] The first channel in the Redis database is used as the channel for log acquisition requests, and the second channel is used as the channel for log files. In this way, the server subscribes to the second channel in the Redis database to determine whether there is a log file of the corresponding test device in the Redis database.
[0107] In actual applications, one test device corresponds to a first channel in the Redis database, and multiple test devices require multiple first channels in the Redis database, and each test device corresponds to the first channel one by one; one test device corresponds to a second channel in the Redis database, and multiple test devices require multiple second channels in the Redis database, and each test device corresponds to the second channel one by one. Moreover, the first channel and the second channel of a test device also correspond one by one. For example, test device 1 and test device 2, the first channel 1 and the second channel 1 in the Redis database correspond to test device 1, and the first channel 2 and the second channel 2 correspond to test device 2. When the server publishes a log acquisition request, the log acquisition request of test device 1 is published to the first channel 1, and the log acquisition request of test device 2 is published to the first channel 2. Subscribe to the second channel 1 and the second channel 2. When there is a log file in the second channel 1, the log file of test device 1 is obtained, and when there is a log file in the second channel 2, the log file of test device 2 is obtained.
[0108] Further, the first channel and the second channel are identified according to a MAC address of the test device.
[0109] In order to make the first channel and the second channel uniquely identified, the MAC address of the corresponding test device can be used for identification. MAC address (Media Access Control Address), literally translated as media access control address, also known as local area network address (LAN Address), Ethernet address (Ethernet Address) or physical address (PhysicalAddress), is an address used to confirm the location of the device on the Internet, that is, the MAC address corresponding to each test device is unique.
[0110] For example, in the Redis database, the first channel 1 corresponding to the test device 1 is MAC1, and the second channel 1 is MAC1_R; the first channel MAC2 corresponding to the test device 2, and the second channel 2 is MAC2_R.
[0111] In one embodiment of the present invention, the intermediary database is a MySQL database;
[0112] Figure 1 Publishing the log acquisition request of the test device to the intermediary database in step S110 of the method shown includes: publishing the log acquisition request of the test device to a first field corresponding to the test device in a specified data table of the Mysql database.
[0113] Figure 1Monitoring whether there is a log file corresponding to the test device in the intermediary database in step S120 of the method shown includes: polling and monitoring whether there is data in the second field corresponding to the test device in the specified data table of the Mysql database; when data is monitored in the second field, determining whether there is a log file corresponding to the test device in the Mysql database.
[0114] In this embodiment, the intermediary database is a Mysql database, which does not have the subscription and publishing functions of the Redis database. Therefore, it is implemented by creating a table. A table is created in the Mysql database, each row of which represents a test device, and the corresponding first field is used as the field of the log acquisition request, and the second field is used as the field of the log file. In this way, the server can query the second field in the Mysql database to determine whether there is a log file of the corresponding test device in the Mysql database.
[0115] Table 1 shows a table in a Mysql database of an embodiment of the present invention. As shown in Table 1, MAC1-MAC3 correspond to test device 1-test device 3 respectively. When the server receives a message that the test of test device 1 is finished, it publishes a log acquisition request of test device 1 to the first field corresponding to MAC1 in Table 1, and polls whether there is data in the second field of MAC1. When there is data in the second field, the data in the second field is acquired, that is, the log file of test device 1 is acquired.
[0116] Table 1
[0117] Test equipment identification First Field Second field MAC1 MAC2 MAC3 …
[0118] Furthermore, the above-mentioned polling monitoring whether there is data in the second field corresponding to the test device in the specified data table of the Mysql database includes: setting a preset time or a preset frequency; every preset time or according to the preset frequency, querying whether there is data in the second field corresponding to the test device in the specified data table of the Mysql database.
[0119] In this embodiment, polling is performed by setting a preset time or a preset frequency. For example, the frequency is set to be every 10 minutes, or the preset time is set to be 0 o'clock, 1 o'clock, 2 o'clock, etc.
[0120] Furthermore, the first field and the second field corresponding to each test device in the designated data table specifically correspond to the MAC address of the test device.
[0121] In order to make the first field and the second field corresponding to each test device uniquely identified, the MAC address of the corresponding test device can be used for identification. For example, in Table 1, the corresponding test device 1 is MAC1; the corresponding test device 2 is MAC2; and the corresponding test device 3 is MAC3.
[0122] In one embodiment of the present invention, Figure 1 The method shown also includes:
[0123] It is determined whether the usage time of each application in the obtained log file is consistent with the preset time in the corresponding test case. If it is determined to be consistent, the test passes.
[0124] The server obtains the log file in order to test whether the application duration statistics function of the router is accurate. Therefore, in this embodiment, the server needs to determine whether the usage duration of each application in the obtained log file is consistent with the preset duration in the corresponding test case to test whether the application duration statistics function of the router is accurate.
[0125] Figure 2 FIG. 2 is a flow chart showing a method for obtaining a log file according to another embodiment of the present invention, which method is used to illustrate the technical solution from the device side. Figure 2 As shown, the method includes:
[0126] Step S210, obtaining the log files corresponding to each test device in the router.
[0127] In this embodiment, the log file acquisition device and the router use the same network segment to access the Internet and are connected to the router to acquire the log files in the router.
[0128] Step S220: monitor whether there is a log acquisition request corresponding to each test device in the intermediary database.
[0129] In order to determine the timing of publishing the log file to the intermediary database, it is necessary to monitor whether there is a log acquisition request corresponding to each test device in the intermediary data.
[0130] Step S230 , when a log acquisition request of a test device in the intermediary database is monitored, the log file corresponding to the test device is published to the intermediary database according to the log acquisition request.
[0131] When there is a log acquisition request for a test device in the intermediary database, it means that the test device has been tested and the log file can be published to the intermediary database so that the test server can obtain the log file of the test device that has been tested from the intermediary database.
[0132] It can be seen that through this technical solution, through the combination of the device and the intermediate database, even if the test server and the router are across network segments, the test server can obtain the log file in the router, thereby realizing the test of the application statistics function of the router.
[0133] In this technical solution, the intermediary database can use Redis database and MySQL database. Different intermediary databases have different characteristics. Therefore, the execution method of this technical solution is also different, which is described in detail below.
[0134] In one embodiment of the present invention, the intermediary database is a Redis database;
[0135] Figure 2 The step S220 of the method shown includes: subscribing to the first channel corresponding to each test device in the Redis database; when there is data in the first channel corresponding to a test device, determining whether there is a log acquisition request corresponding to the test device in the Redis database.
[0136] Figure 2 Publishing the log file corresponding to the test device to the intermediary database in step S230 of the method shown includes: publishing the log file corresponding to the test device to the second channel corresponding to the test device in the Redis database.
[0137] Among them, the first channel and the second channel correspond one to one.
[0138] In this embodiment, the intermediary database is a Redis database. By using the subscription and publishing functions of the Redis database, the test server can subscribe to the channel of the Redis database to determine whether there is a log file in the Redis database.
[0139] The first channel in the Redis database is used as the channel for log acquisition requests, and the second channel is used as the channel for log files. In this way, the test server subscribes to the second channel in the Redis database to determine whether there is a log file for the corresponding test device in the Redis database.
[0140] In actual applications, one test device corresponds to a first channel in the Redis database, and multiple test devices require multiple first channels in the Redis database, and each test device corresponds to the first channel one by one; one test device corresponds to a second channel in the Redis database, and multiple test devices require multiple second channels in the Redis database, and each test device corresponds to the second channel one by one. Moreover, the first channel and the second channel of a test device also correspond one by one. For example, test device 1 and test device 2, the first channel 1 and the second channel 1 in the Redis database correspond to test device 1, and the first channel 2 and the second channel 2 correspond to test device 2. The acquisition device of the log file subscribes to the first channel of each test device. When the first channel 1 of test device 1 has a log acquisition request, the log file of test device 1 is published to the second channel of test device 1; when the first channel 1 of test device 2 has a log acquisition request, the log file of test device 2 is published to the second channel of test device 2.
[0141] Further, the first channel and the second channel are identified according to a MAC address of the test device.
[0142] In order to make the first channel and the second channel uniquely identified, the MAC address of the corresponding test device can be used for identification. MAC address (Media Access Control Address), literally translated as media access control address, also known as local area network address (LAN Address), Ethernet address (Ethernet Address) or physical address (PhysicalAddress), is an address used to confirm the location of the device on the Internet, that is, the MAC address corresponding to each test device is unique.
[0143] For example, in the Redis database, the first channel 1 corresponding to the test device 1 is MAC1, and the second channel 1 is MAC1_R; the first channel MAC2 corresponding to the test device 2, and the second channel 2 is MAC2_R.
[0144] In one embodiment of the present invention, the intermediary database is a MySQL database;
[0145] Figure 2 Monitoring whether there are log acquisition requests corresponding to each test device in the intermediary database in step S220 of the method shown includes: polling and monitoring whether there is data in the first field corresponding to each test device in the specified data table of the Mysql database; when it is monitored that there is data in the first field corresponding to a test device in the specified data table, determining that there is a log acquisition request corresponding to the test device in the Mysql database.
[0146] Figure 2 Publishing the log file corresponding to the test device to the intermediary database in step S230 of the method shown includes: publishing the log file corresponding to the test device to a second field corresponding to the test device in a specified data table of the Mysql database.
[0147] In this embodiment, the intermediary database is a Mysql database, which does not have the subscription and publishing functions of the Redis database. Therefore, it is implemented by creating a table. A table is created in the Mysql database, each row of which represents a test device, and the corresponding first field is used as the field of the log acquisition request, and the second field is used as the field of the log file. In this way, the log file acquisition device can query the first field in the Mysql database to determine whether there is a log acquisition request for the corresponding test device in the Mysql database, and the log file is published to the second field of the corresponding test device so that the server can query it.
[0148] As shown in Table 1 above, MAC1-MAC3 correspond to test device 1-test device 3 respectively. The log file acquisition device polls test device 1, that is, the first field of MAC1. When there is a log acquisition request in the first field of MAC1, the log file of test device 1 is published to the second field of MAC1. The server polls whether there is data in the second field of MAC1. When there is data in the second field, the data in the second field is obtained, that is, the log file of test device 1 is obtained.
[0149] Furthermore, the above-mentioned polling monitoring whether there is data in the first field corresponding to each test device in the specified data table of the Mysql database includes: setting a preset time or a preset frequency; every preset time or according to the preset frequency, querying whether there is data in the first field corresponding to the test device in the specified data table of the Mysql database.
[0150] In this embodiment, polling is performed by setting a preset time or a preset frequency. For example, the frequency is set to be every 10 minutes, or the preset time is set to be 0 o'clock, 1 o'clock, 2 o'clock, etc.
[0151] Furthermore, the first field and the second field corresponding to each test device in the designated data table specifically correspond to the MAC address of the test device.
[0152] In order to make the first field and the second field corresponding to each test device uniquely identified, the MAC address of the corresponding test device can be used for identification. For example, in Table 1, the corresponding test device 1 is MAC1; the corresponding test device 2 is MAC2; and the corresponding test device 3 is MAC3.
[0153] In one embodiment of the present invention, Figure 2 The method shown also includes: analyzing the obtained log files corresponding to each test device; and obtaining the usage time of each application corresponding to each test device.
[0154] Figure 2 Publishing the log file corresponding to the test device to the intermediary database in step S230 of the method shown includes: publishing the obtained usage duration of each application corresponding to the test device as the log file corresponding to the test device to the intermediary database.
[0155] When the device monitors the log acquisition request of the test device, it analyzes the log file of the test device, obtains the usage time of each application corresponding to the test device, and publishes the usage time of each application corresponding to the test device to the intermediary database. The usage time of each application in the log file is the statistics of the application time statistics function of the router. In this way, when the server obtains the log file, it can determine whether the usage time of each application in the obtained log file is consistent with the preset time in the corresponding test case. If it is determined to be consistent, the test passes.
[0156] Figure 3 FIG. 2 shows a schematic diagram of the structure of a server for obtaining log files according to an embodiment of the present invention. Figure 3 As shown, the log file acquisition server 300 includes:
[0157] The publishing unit 310 is adapted to publish a log acquisition request of the test device to the intermediary database when receiving a message indicating that the test of the test device is finished.
[0158] In this embodiment, the server is connected to the test device to control the test device to execute the test case and obtain the test device information. After the test device completes the test case, it will notify the server. The server here includes a web server.
[0159] The monitoring unit 320 is adapted to monitor whether there is a log file corresponding to the test device in the intermediary database.
[0160] When the log file acquisition device acquires the log file of the router and sends a log acquisition request to the intermediary database, it will publish the log file corresponding to the test device to the intermediary database. In this embodiment, the server determines whether there is a log file corresponding to the test device in the intermediary database by monitoring.
[0161] The acquisition unit 330 is adapted to acquire the log file when it is monitored that there is a log file corresponding to the test device in the intermediary database.
[0162] It can be seen that through this technical solution, through the combination of the device and the intermediate database, even if the server and the router are across network segments, the server can obtain the log file in the router, thereby realizing the test of the application statistics function of the router.
[0163] In this technical solution, the intermediary database can use Redis database and MySQL database. Different intermediary databases have different characteristics. Therefore, the execution method of this technical solution is also different, which is described in detail below.
[0164] In one embodiment of the present invention, the intermediary database is a Redis database.
[0165] The publishing unit 310 is adapted to publish the log acquisition request of the test device to the first channel corresponding to the test device in the Redis database.
[0166] The monitoring unit 320 is adapted to subscribe to a second channel corresponding to the test device in the Redis database; when there is data in the second channel, it is determined that there is a log file corresponding to the test device in the Redis database.
[0167] Among them, the first channel and the second channel correspond one to one.
[0168] In this embodiment, the intermediary database is a Redis database. By using the subscription and publishing functions of the Redis database, the server can subscribe to the channel of the Redis database to determine whether there is a log file in the Redis database.
[0169] The first channel in the Redis database is used as the channel for log acquisition requests, and the second channel is used as the channel for log files. In this way, the server subscribes to the second channel in the Redis database to determine whether there is a log file of the corresponding test device in the Redis database.
[0170] In actual applications, one test device corresponds to a first channel in the Redis database, and multiple test devices require multiple first channels in the Redis database, and each test device corresponds to the first channel one by one; one test device corresponds to a second channel in the Redis database, and multiple test devices require multiple second channels in the Redis database, and each test device corresponds to the second channel one by one. Moreover, the first channel and the second channel of a test device also correspond one by one. For example, test device 1 and test device 2, the first channel 1 and the second channel 1 in the Redis database correspond to test device 1, and the first channel 2 and the second channel 2 correspond to test device 2. When the server publishes a log acquisition request, the log acquisition request of test device 1 is published to the first channel 1, and the log acquisition request of test device 2 is published to the first channel 2. Subscribe to the second channel 1 and the second channel 2. When there is a log file in the second channel 1, the log file of test device 1 is obtained, and when there is a log file in the second channel 2, the log file of test device 2 is obtained.
[0171] Further, the first channel and the second channel are identified according to a MAC address of the test device.
[0172] In order to make the first channel and the second channel uniquely identified, the MAC address of the corresponding test device can be used for identification. MAC address (Media Access Control Address), literally translated as media access control address, also known as local area network address (LAN Address), Ethernet address (Ethernet Address) or physical address (PhysicalAddress), is an address used to confirm the location of the device on the Internet, that is, the MAC address corresponding to each test device is unique.
[0173] For example, in the Redis database, the first channel 1 corresponding to the test device 1 is MAC1, and the second channel 1 is MAC1_R; the first channel MAC2 corresponding to the test device 2, and the second channel 2 is MAC2_R.
[0174] In one embodiment of the present invention, the intermediate database is a MySQL database.
[0175] The publishing unit 310 is adapted to publish the log acquisition request of the test device to a first field corresponding to the test device in a designated data table of a MySQL database.
[0176] The monitoring unit 320 is adapted to poll and monitor whether there is data in the second field corresponding to the test device in the specified data table of the Mysql database; when data is detected in the second field, it is determined that there is a log file corresponding to the test device in the Mysql database.
[0177] In this embodiment, the intermediary database is a Mysql database, which does not have the subscription and publishing functions of the Redis database. Therefore, it is implemented by creating a table. A table is created in the Mysql database, each row of which represents a test device, and the corresponding first field is used as the field of the log acquisition request, and the second field is used as the field of the log file. In this way, the server can query the second field in the Mysql database to determine whether there is a log file of the corresponding test device in the Mysql database.
[0178] Table 1 shows a table in a Mysql database of an embodiment of the present invention. As shown in Table 1, MAC1-MAC3 correspond to test device 1-test device 3 respectively. When the server receives a message that the test of test device 1 is finished, it publishes a log acquisition request of test device 1 to the first field corresponding to MAC1 in Table 1, and polls whether there is data in the second field of MAC1. When there is data in the second field, the data in the second field is acquired, that is, the log file of test device 1 is acquired.
[0179] Table 1
[0180] Test equipment identification First Field Second field MAC1 MAC2 MAC3 …
[0181] Further, based on the above embodiment, the monitoring unit 320 is suitable for setting a preset time or a preset frequency; every preset time or according to the preset frequency, query whether there is data in the second field corresponding to the test device in the specified data table of the Mysql database.
[0182] In this embodiment, polling is performed by setting a preset time or a preset frequency. For example, the frequency is set to be every 10 minutes, or the preset time is set to be 0 o'clock, 1 o'clock, 2 o'clock, etc.
[0183] Furthermore, the first field and the second field corresponding to each test device in the designated data table specifically correspond to the MAC address of the test device.
[0184] In order to make the first field and the second field corresponding to each test device uniquely identified, the MAC address of the corresponding test device can be used for identification. For example, in Table 1, the corresponding test device 1 is MAC1; the corresponding test device 2 is MAC2; and the corresponding test device 3 is MAC3.
[0185] In one embodiment of the present invention, Figure 3 The server shown also includes:
[0186] The judgment unit is adapted to judge whether the usage duration of each application in the acquired log file is consistent with the preset duration in the corresponding test case. If the judgment is consistent, the test passes.
[0187] The server obtains the log file in order to test whether the application duration statistics function of the router is accurate. Therefore, in this embodiment, the server needs to determine whether the usage duration of each application in the obtained log file is consistent with the preset duration in the corresponding test case to test whether the application duration statistics function of the router is accurate.
[0188] Figure 4 FIG. 2 shows a schematic diagram of a log file acquisition device according to an embodiment of the present invention. Figure 4 As shown, the log file acquisition device 400 includes:
[0189] The acquisition unit 410 is adapted to acquire the log files corresponding to each test device in the router.
[0190] In this embodiment, the log file acquisition device and the router use the same network segment to access the Internet, are connected to the router, and are used to acquire the log files in the router. The log file acquisition device here includes a PC.
[0191] The monitoring unit 420 is adapted to monitor whether there is a log acquisition request corresponding to each test device in the intermediary database.
[0192] In order to determine the timing of publishing the log file to the intermediary database, it is necessary to monitor whether there is a log acquisition request corresponding to each test device in the intermediary data.
[0193] The publishing unit 430 is adapted to publish the log file corresponding to the test device to the intermediary database according to the log acquisition request when a log acquisition request of a test device in the intermediary database is monitored.
[0194] When there is a log acquisition request for a test device in the intermediary database, it means that the test device has been tested and the log file can be published to the intermediary database so that the test server can obtain the log file of the test device that has been tested from the intermediary database.
[0195] It can be seen that through this technical solution, through the combination of the device and the intermediate database, even if the test server and the router are across network segments, the test server can obtain the log file in the router, thereby realizing the test of the application statistics function of the router.
[0196] In this technical solution, the intermediary database can use Redis database and MySQL database. Different intermediary databases have different characteristics. Therefore, the execution method of this technical solution is also different, which is described in detail below.
[0197] In one embodiment of the present invention, the intermediary database is a Redis database.
[0198] The monitoring unit 420 is adapted to subscribe to the first channel corresponding to each test device in the Redis database; when there is data in the first channel corresponding to a test device, it is determined that there is a log acquisition request corresponding to the test device in the Redis database.
[0199] The publishing unit 430 is adapted to publish the log file corresponding to the test device to the second channel corresponding to the test device in the Redis database.
[0200] Among them, the first channel and the second channel correspond one to one.
[0201] In this embodiment, the intermediary database is a Redis database. By using the subscription and publishing functions of the Redis database, the test server can subscribe to the channel of the Redis database to determine whether there is a log file in the Redis database.
[0202] The first channel in the Redis database is used as the channel for log acquisition requests, and the second channel is used as the channel for log files. In this way, the test server subscribes to the second channel in the Redis database to determine whether there is a log file for the corresponding test device in the Redis database.
[0203] In actual applications, one test device corresponds to a first channel in the Redis database, and multiple test devices require multiple first channels in the Redis database, and each test device corresponds to the first channel one by one; one test device corresponds to a second channel in the Redis database, and multiple test devices require multiple second channels in the Redis database, and each test device corresponds to the second channel one by one. Moreover, the first channel and the second channel of a test device also correspond one by one. For example, test device 1 and test device 2, the first channel 1 and the second channel 1 in the Redis database correspond to test device 1, and the first channel 2 and the second channel 2 correspond to test device 2. The acquisition device of the log file subscribes to the first channel of each test device. When the first channel 1 of test device 1 has a log acquisition request, the log file of test device 1 is published to the second channel of test device 1; when the first channel 1 of test device 2 has a log acquisition request, the log file of test device 2 is published to the second channel of test device 2.
[0204] Further, the first channel and the second channel are identified according to a MAC address of the test device.
[0205] In order to make the first channel and the second channel uniquely identified, the MAC address of the corresponding test device can be used for identification. MAC address (Media Access Control Address), literally translated as media access control address, also known as local area network address (LAN Address), Ethernet address (Ethernet Address) or physical address (PhysicalAddress), is an address used to confirm the location of the device on the Internet, that is, the MAC address corresponding to each test device is unique.
[0206] For example, in the Redis database, the first channel 1 corresponding to the test device 1 is MAC1, and the second channel 1 is MAC1_R; the first channel MAC2 corresponding to the test device 2, and the second channel 2 is MAC2_R.
[0207] In one embodiment of the present invention, the intermediate database is a MySQL database.
[0208] The monitoring unit 420 is adapted to poll and monitor whether there is data in the first field corresponding to each test device in the specified data table of the Mysql database; when it is monitored that there is data in the first field corresponding to a test device in the specified data table, it is determined that there is a log acquisition request corresponding to the test device in the Mysql database.
[0209] The publishing unit 430 is adapted to publish the log file corresponding to the test device to the second field corresponding to the test device in the designated data table of the MySQL database.
[0210] In this embodiment, the intermediary database is a Mysql database, which does not have the subscription and publishing functions of the Redis database. Therefore, it is implemented by creating a table. A table is created in the Mysql database, each row of which represents a test device, and the corresponding first field is used as the field of the log acquisition request, and the second field is used as the field of the log file. In this way, the log file acquisition device can query the first field in the Mysql database to determine whether there is a log acquisition request for the corresponding test device in the Mysql database, and the log file is published to the second field of the corresponding test device so that the server can query it.
[0211] As shown in Table 1 above, MAC1-MAC3 correspond to test device 1-test device 3 respectively. The log file acquisition device polls test device 1, that is, the first field of MAC1. When there is a log acquisition request in the first field of MAC1, the log file of test device 1 is published to the second field of MAC1. The server polls whether there is data in the second field of MAC1. When there is data in the second field, the data in the second field is obtained, that is, the log file of test device 1 is obtained.
[0212] Further, based on the above embodiment, the monitoring unit 420 is suitable for setting a preset time or a preset frequency; every preset time or according to the preset frequency, query whether there is data in the first field corresponding to the test device in the specified data table of the Mysql database.
[0213] In this embodiment, polling is performed by setting a preset time or a preset frequency. For example, the frequency is set to be every 10 minutes, or the preset time is set to be 0 o'clock, 1 o'clock, 2 o'clock, etc.
[0214] Furthermore, the first field and the second field corresponding to each test device in the designated data table specifically correspond to the MAC address of the test device.
[0215] In order to make the first field and the second field corresponding to each test device uniquely identified, the MAC address of the corresponding test device can be used for identification. For example, in Table 1, the corresponding test device 1 is MAC1; the corresponding test device 2 is MAC2; and the corresponding test device 3 is MAC3.
[0216] In one embodiment of the present invention, Figure 4 The device shown also includes:
[0217] The analysis unit is adapted to analyze the acquired log files corresponding to each test device, and obtain the usage time of each application corresponding to each test device.
[0218] The publishing unit 430 is adapted to publish the obtained usage duration of each application corresponding to the test device as a log file corresponding to the test device to the intermediary database.
[0219] When the device monitors the log acquisition request of the test device, it analyzes the log file of the test device, obtains the usage time of each application corresponding to the test device, and publishes the usage time of each application corresponding to the test device to the intermediary database. The usage time of each application in the log file is the statistics of the application time statistics function of the router. In this way, when the server obtains the log file, it can determine whether the usage time of each application in the obtained log file is consistent with the preset time in the corresponding test case. If it is determined to be consistent, the test passes.
[0220] Figure 5 FIG. 2 shows a schematic diagram of the structure of a system for acquiring log files according to an embodiment of the present invention. Figure 5 As shown, the log file acquisition system 500 includes: Figure 3 The acquisition server 300 of the log file shown in FIG. Figure 4 The log file acquisition device 400 and the intermediate database 510 are shown.
[0221] It should be noted that Figure 5 The various embodiments of the system shown are Figure 1 and Figure 2 The method shown and its various embodiments are the same and have been described in detail above, so they will not be repeated here.
[0222] In a specific example, Figure 6 A structural schematic diagram of a log file acquisition system according to another embodiment of the present invention is shown, the system includes a PC, a Redis database, and a web server; it also includes a router and 3 test devices (not limited to 3), namely a mobile phone 1, a tablet 2 and a device 3, each test device accesses the Internet through the router, the web server is connected to the mobile phone 1, the tablet 2 and the device 3, and the PC is connected to the router.
[0223] In the Redis database, the corresponding mobile phone 1 has the first channel MAC1 and the second channel MAC1_R; the corresponding tablet 2 has the first channel MAC2 and the second channel MAC2_R; the corresponding device 3 has the first channel MAC3 and the second channel MAC3_R. Web server subscription ( Figure 6 The dotted arrows in the figure indicate subscription) MAC1_R, MAC2_R, MAC3_R; PC subscription ( Figure 6 The dotted arrows in the figure represent subscriptions to MAC1, MAC2, and MAC3. When mobile phone 1 automatically executes the test case, it notifies the web server. The web server receives the message that the test of mobile phone 1 is finished and publishes the log acquisition request of mobile phone 1 to MAC1. The PC obtains the log file of mobile phone 1 from the router. When the PC monitors that there is a log acquisition request in MAC1, it publishes the log file corresponding to mobile phone 1 to MAC1_R. When the web server monitors MAC1_R for data, it obtains the data, that is, obtains the log file of mobile phone 1.
[0224] In summary, according to the technical solution of the present invention, when the test server receives a message indicating that the test of the test device has ended, it publishes a log acquisition request for the test device to the intermediary database; monitors whether there is a log file corresponding to the test device in the intermediary database; and when it is monitored that there is a log file corresponding to the test device in the intermediary database, the log file is acquired. The log file acquisition device acquires the log files corresponding to each test device in the router; monitors whether there are log acquisition requests corresponding to each test device in the intermediary database; when it is monitored that a log acquisition request of a test device in the intermediary database is received, the log file corresponding to the test device is published to the intermediary database according to the log acquisition request. It can be seen that through the technical solution, through the combination of the device and the intermediary database, even if the test server and the router are across network segments, the test server can obtain the log files in the router, thereby realizing the test of the application statistics function of the router.
[0225] It should be noted that:
[0226] The algorithm and display provided herein are not inherently related to any particular computer, virtual device or other equipment. Various general-purpose devices can also be used together with the teachings based on this. According to the above description, it is obvious to construct the structure required for this type of device. In addition, the present invention is not directed to any specific programming language either. It should be understood that various programming languages can be utilized to realize the content of the present invention described herein, and the description of the above specific language is for the purpose of disclosing the best mode of the present invention.
[0227] In the description provided herein, a large number of specific details are described. However, it is understood that embodiments of the present invention can be practiced without these specific details. In some instances, well-known methods, structures and techniques are not shown in detail so as not to obscure the understanding of this description.
[0228] Similarly, it should be understood that in order to streamline the present disclosure and aid in understanding one or more of the various inventive aspects, in the above description of exemplary embodiments of the present invention, various features of the present invention are sometimes grouped together into a single embodiment, figure, or description thereof. However, this disclosed method should not be interpreted as reflecting the intention that the claimed invention requires more features than those explicitly recited in each claim. More specifically, as reflected in the claims below, inventive aspects lie in less than all the features of the individual embodiments disclosed above. Therefore, the claims that follow the specific embodiment are hereby expressly incorporated into the specific embodiment, with each claim itself serving as a separate embodiment of the present invention.
[0229] Those skilled in the art will appreciate that the modules in the devices in the embodiments may be adaptively changed and arranged in one or more devices different from the embodiments. The modules or units or components in the embodiments may be combined into one module or unit or component, and in addition they may be divided into a plurality of submodules or subunits or subcomponents. Except that at least some of such features and / or processes or units are mutually exclusive, all features disclosed in this specification (including the accompanying claims, abstracts and drawings) and all processes or units of any method or device disclosed in this manner may be combined in any combination. Unless otherwise expressly stated, each feature disclosed in this specification (including the accompanying claims, abstracts and drawings) may be replaced by an alternative feature providing the same, equivalent or similar purpose.
[0230] In addition, those skilled in the art will appreciate that, although some embodiments described herein include certain features included in other embodiments but not other features, the combination of features of different embodiments is meant to be within the scope of the present invention and form different embodiments. For example, in the claims below, any one of the claimed embodiments may be used in any combination.
[0231] The various component embodiments of the present invention can be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. It should be understood by those skilled in the art that a microprocessor or digital signal processor (DSP) can be used in practice to implement some or all functions of some or all components in the acquisition server, device, system, electronic device and computer-readable storage medium of the log file according to the embodiment of the present invention. The present invention can also be implemented as a device or device program (e.g., computer program and computer program product) for executing part or all of the methods described herein. Such a program implementing the present invention can be stored on a computer-readable medium, or can have the form of one or more signals. Such a signal can be downloaded from an Internet website, or provided on a carrier signal, or provided in any other form.
[0232] For example, Figure 7 FIG. 7 is a block diagram of an electronic device according to an embodiment of the present invention. The electronic device 700 conventionally includes a processor 710 and a memory 720 arranged to store computer executable instructions (program code). The memory 720 may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read-only memory), an EPROM, a hard disk, or a ROM. The memory 720 has a memory for storing instructions for executing the program. Figure 1 or Figure 2The storage space 730 for program code 740 of any method step shown in the figure and in each embodiment. For example, the storage space 730 for program code may include various program codes 740 respectively used to implement various steps in the above method. These program codes can be read from or written to one or more computer program products. These computer program products include program code carriers such as hard disks, compact disks (CDs), memory cards or floppy disks. Such computer program products are usually, for example, Figure 8 The computer readable storage medium 800. The computer readable storage medium 800 may have Figure 7 The memory 720 in the electronic device of the present invention is similarly arranged as a storage segment, storage space, etc. The program code can be compressed, for example, in an appropriate form. Generally, the storage unit stores program code 810 for executing the steps of the method according to the present invention, that is, program code that can be read by a processor such as 710, and when these program codes are run by the electronic device, the electronic device is caused to execute the various steps in the method described above.
[0233] It should be noted that the above embodiments illustrate the present invention rather than limit it, and that those skilled in the art may devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference symbol between brackets shall not be construed as a limitation on the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "one" or "an" preceding an element does not exclude the presence of a plurality of such elements. The present invention may be implemented by means of hardware comprising a number of different elements and by means of a suitably programmed computer. In a unit claim enumerating a number of devices, several of these devices may be embodied by the same hardware item. The use of the words first, second, and third, etc., does not indicate any order. These words may be interpreted as names.
[0234] The present invention discloses A1, a method for obtaining a log file, wherein the method comprises:
[0235] When receiving a message that the test of the test device has ended, publishing a log acquisition request for the test device to the intermediary database;
[0236] Monitor whether there is a log file corresponding to the test device in the intermediary database;
[0237] When it is monitored that there is a log file corresponding to the test device in the intermediary database, the log file is obtained.
[0238] A2. The method as described in A1, wherein the intermediary database is a Redis database;
[0239] The step of publishing the log acquisition request of the test device to the intermediary database includes: publishing the log acquisition request of the test device to a first channel corresponding to the test device in the Redis database;
[0240] The monitoring whether there is a log file corresponding to the test device in the intermediary database includes: subscribing to a second channel corresponding to the test device in the Redis database; when there is data in the second channel, determining whether there is a log file corresponding to the test device in the Redis database;
[0241] The first channel corresponds to the second channel one by one.
[0242] A3. The method as described in A2, wherein the first channel and the second channel are identified according to a MAC address of the test device.
[0243] A4. The method as described in A1, wherein the intermediary database is a MySQL database;
[0244] The step of publishing the log acquisition request of the test device to the intermediary database includes: publishing the log acquisition request of the test device to a first field corresponding to the test device in a specified data table of a Mysql database;
[0245] The monitoring of whether there is a log file corresponding to the test device in the intermediate database includes: polling and monitoring whether there is data in the second field corresponding to the test device in the specified data table of the Mysql database; when it is monitored that there is data in the second field, determining that there is a log file corresponding to the test device in the Mysql database.
[0246] A5. The method as described in A4, wherein the polling monitors whether there is data in the second field corresponding to the test device in the specified data table of the Mysql database, including:
[0247] Set a preset time or preset frequency;
[0248] At every preset time or at a preset frequency, query whether there is data in the second field corresponding to the test device in the specified data table of the Mysql database.
[0249] A6. The method as described in A4, wherein the first field and the second field corresponding to each test device in the specified data table specifically correspond to the MAC address of the test device.
[0250] A7. The method as described in A1, wherein the method further comprises:
[0251] It is determined whether the usage time of each application in the obtained log file is consistent with the preset time in the corresponding test case. If it is determined to be consistent, the test passes.
[0252] The present invention also discloses B8, a method for obtaining a log file, wherein the method comprises:
[0253] Get the log files corresponding to each test device in the router;
[0254] Monitor whether there are log acquisition requests corresponding to each test device in the intermediary database;
[0255] When a log acquisition request of a test device in the intermediary database is monitored, the log file corresponding to the test device is published to the intermediary database according to the log acquisition request.
[0256] B9. The method as described in B8, wherein the intermediary database is a Redis database;
[0257] The monitoring whether there is a log acquisition request corresponding to each test device in the intermediary database includes: subscribing to a first channel corresponding to each test device in the Redis database; when there is data in the first channel corresponding to a test device, determining whether there is a log acquisition request corresponding to the test device in the Redis database;
[0258] Publishing the log file corresponding to the test device to the intermediary database includes: publishing the log file corresponding to the test device to a second channel corresponding to the test device in the Redis database;
[0259] The first channel corresponds to the second channel one by one.
[0260] B10. The method as described in B9, wherein the first channel and the second channel are identified according to a MAC address of the test device.
[0261] B11. The method as described in B8, wherein the intermediary database is a MySQL database;
[0262] The monitoring whether there are log acquisition requests corresponding to each test device in the intermediary database comprises: polling and monitoring whether there is data in the first field corresponding to each test device in the specified data table of the Mysql database; when it is monitored that there is data in the first field corresponding to a test device in the specified data table, determining that there is a log acquisition request corresponding to the test device in the Mysql database;
[0263] The publishing the log file corresponding to the test device to the intermediary database includes: publishing the log file corresponding to the test device to a second field corresponding to the test device in a designated data table of the Mysql database.
[0264] B12. The method as described in B11, wherein the polling monitors whether there is data in the first field corresponding to each test device in the specified data table of the Mysql database, including:
[0265] Set a preset time or preset frequency;
[0266] At every preset time or at a preset frequency, query whether there is data in the first field corresponding to the test device in the specified data table of the Mysql database.
[0267] B13. The method as described in B11, wherein the first field and the second field corresponding to each test device in the specified data table specifically correspond to the MAC address of the test device.
[0268] B14. The method as described in B8, wherein the method further comprises:
[0269] Analyze the obtained log files corresponding to each test device; obtain the usage time of each application corresponding to each test device;
[0270] The publishing the log file corresponding to the test device to the intermediary database includes: publishing the obtained usage duration of each application corresponding to the test device as the log file corresponding to the test device to the intermediary database.
[0271] The present invention also discloses C15, a log file acquisition server, wherein the server comprises:
[0272] A publishing unit, adapted to publish a log acquisition request of the test device to the intermediary database when receiving a message that the test of the test device is finished;
[0273] A monitoring unit, adapted to monitor whether there is a log file corresponding to the test device in the intermediary database;
[0274] The acquisition unit is adapted to acquire the log file when it is monitored that there is a log file corresponding to the test device in the intermediary database.
[0275] C16. The server as described in C15, wherein the intermediary database is a Redis database;
[0276] The publishing unit is adapted to publish the log acquisition request of the test device to the first channel corresponding to the test device in the Redis database;
[0277] The monitoring unit is adapted to subscribe to a second channel corresponding to the test device in the Redis database; when there is data in the second channel, determine that there is a log file corresponding to the test device in the Redis database;
[0278] The first channel corresponds to the second channel one by one.
[0279] C17. The server as described in C16, wherein the first channel and the second channel are identified according to a MAC address of a test device.
[0280] C18. The server as described in C15, wherein the intermediary database is a MySQL database;
[0281] The publishing unit is adapted to publish the log acquisition request of the test device to a first field corresponding to the test device in a specified data table of a MySQL database;
[0282] The monitoring unit is adapted to poll and monitor whether there is data in the second field corresponding to the test device in the specified data table of the Mysql database; when data is detected in the second field, it is determined that there is a log file corresponding to the test device in the Mysql database.
[0283] C19. The server as described in C18, wherein:
[0284] The monitoring unit is adapted to set a preset time or a preset frequency; and query whether there is data in the second field corresponding to the test device in the specified data table of the Mysql database at every preset time or at a preset frequency.
[0285] C20. The server as described in C18, wherein the first field and the second field corresponding to each test device in the specified data table specifically correspond to the MAC address of the test device.
[0286] C21. The server as described in C15, wherein the server further comprises:
[0287] The judgment unit is adapted to judge whether the usage duration of each application in the acquired log file is consistent with the preset duration in the corresponding test case. If the judgment is consistent, the test passes.
[0288] The present invention also discloses D22, a device for obtaining a log file, wherein the device comprises:
[0289] An acquisition unit, adapted to acquire log files corresponding to each test device in the router;
[0290] A monitoring unit, adapted to monitor whether there is a log acquisition request corresponding to each test device in the intermediary database;
[0291] The publishing unit is adapted to publish the log file corresponding to the test device to the intermediary database according to the log acquisition request when a log acquisition request of a test device in the intermediary database is monitored.
[0292] D23. The device as described in D22, wherein the intermediate database is a Redis database;
[0293] The monitoring unit is adapted to subscribe to the first channel corresponding to each test device in the Redis database; when there is data in the first channel corresponding to a test device, it is determined that there is a log acquisition request corresponding to the test device in the Redis database;
[0294] The publishing unit is adapted to publish the log file corresponding to the test device to the second channel corresponding to the test device in the Redis database;
[0295] The first channel corresponds to the second channel one by one.
[0296] D24. An apparatus as described in D23, wherein the first channel and the second channel are identified according to a MAC address of a test device.
[0297] D25. The device as described in D22, wherein the intermediate database is a MySQL database;
[0298] The monitoring unit is adapted to poll and monitor whether there is data in the first field corresponding to each test device in the specified data table of the Mysql database; when it is monitored that there is data in the first field corresponding to a test device in the specified data table, it is determined that there is a log acquisition request corresponding to the test device in the Mysql database;
[0299] The publishing unit is adapted to publish the log file corresponding to the test device to the second field corresponding to the test device in the designated data table of the Mysql database.
[0300] D26. A device as described in D25, wherein
[0301] The monitoring unit is adapted to set a preset time or a preset frequency; and query whether there is data in the first field corresponding to the test device in the specified data table of the Mysql database at every preset time or at a preset frequency.
[0302] D27. The device as described in D25, wherein the first field and the second field corresponding to each test device in the specified data table specifically correspond to the MAC address of the test device.
[0303] D 28. The device as described in D 22, wherein the device further comprises:
[0304] An analysis unit, adapted to analyze the acquired log files corresponding to each test device, and obtain the usage time of each application corresponding to each test device;
[0305] The publishing unit is adapted to publish the obtained usage duration of each application corresponding to the test device as a log file corresponding to the test device to the intermediary database.
[0306] The present invention also discloses E29, a system for obtaining log files, wherein the system includes a server as described in any one of C15-C21, a device as described in any one of D22-D28, and an intermediate database.
[0307] The present invention also discloses F30, an electronic device, wherein the electronic device comprises:
[0308] processor; and,
[0309] A memory arranged to store computer executable instructions, which, when executed, cause the processor to perform a method according to any one of A1 to A7 or B8 to B14.
[0310] The present invention also discloses G31, a computer-readable storage medium, wherein the computer-readable storage medium stores one or more programs, and when the one or more programs are executed by a processor, they implement any one of the methods A1 to A7 or B8 to B14.
Claims
1. A method for obtaining a log file, wherein: The method includes: When receiving a message that the test of the test device has ended, publishing a log acquisition request for the test device to the intermediary database; Monitor whether there is a log file corresponding to the test device in the intermediary database; When a log file corresponding to the test device is detected in the intermediary database, the log file is obtained; The intermediary database is a Mysql database, and publishing the log acquisition request of the test device to the intermediary database includes: publishing the log acquisition request of the test device to a first field corresponding to the test device in a specified data table of the Mysql database; The monitoring of whether there is a log file corresponding to the test device in the intermediate database includes: polling and monitoring whether there is data in the second field corresponding to the test device in the specified data table of the Mysql database; when it is monitored that there is data in the second field, determining that there is a log file corresponding to the test device in the Mysql database.
2. The method of claim 1, wherein: The intermediary database is a Redis database; The step of publishing the log acquisition request of the test device to the intermediary database includes: publishing the log acquisition request of the test device to a first channel corresponding to the test device in the Redis database; The monitoring whether there is a log file corresponding to the test device in the intermediary database includes: subscribing to a second channel corresponding to the test device in the Redis database; when there is data in the second channel, determining whether there is a log file corresponding to the test device in the Redis database; The first channel corresponds to the second channel one by one.
3. The method of claim 2, wherein: The first channel and the second channel are identified according to a MAC address of the test device.
4. The method of claim 1, wherein: The polling monitoring whether there is data in the second field corresponding to the test device in the specified data table of the Mysql database includes: Set a preset time or preset frequency; At every preset time or at a preset frequency, query whether there is data in the second field corresponding to the test device in the specified data table of the Mysql database.
5. The method of claim 1, wherein: The first field and the second field corresponding to each test device in the specified data table specifically correspond to the MAC address of the test device.
6. The method of claim 1, wherein: The method further includes: It is determined whether the usage time of each application in the obtained log file is consistent with the preset time in the corresponding test case. If it is determined to be consistent, the test passes.
7. A method for obtaining a log file, wherein: The method includes: Get the log files corresponding to each test device in the router; Monitor whether there are log acquisition requests corresponding to each test device in the intermediary database; When a log acquisition request of a test device in the intermediary database is monitored, a log file corresponding to the test device is published to the intermediary database according to the log acquisition request; Wherein, the intermediary database is a Mysql database, and the monitoring of whether there is a log acquisition request corresponding to each test device in the intermediary database comprises: polling and monitoring whether there is data in the first field corresponding to each test device in the specified data table of the Mysql database; when it is monitored that there is data in the first field corresponding to a test device in the specified data table, determining that there is a log acquisition request corresponding to the test device in the Mysql database; The publishing the log file corresponding to the test device to the intermediary database includes: publishing the log file corresponding to the test device to a second field corresponding to the test device in a designated data table of the Mysql database.
8. The method of claim 7, wherein: The intermediary database is a Redis database; The monitoring whether there is a log acquisition request corresponding to each test device in the intermediary database includes: subscribing to a first channel corresponding to each test device in the Redis database; when there is data in the first channel corresponding to a test device, determining whether there is a log acquisition request corresponding to the test device in the Redis database; Publishing the log file corresponding to the test device to the intermediary database includes: publishing the log file corresponding to the test device to a second channel corresponding to the test device in the Redis database; The first channel corresponds to the second channel one by one.
9. The method of claim 8, wherein: The first channel and the second channel are identified according to a MAC address of the test device.
10. The method of claim 7, wherein: The polling monitoring whether there is data in the first field corresponding to each test device in the specified data table of the Mysql database includes: Set a preset time or preset frequency; At every preset time or at a preset frequency, query whether there is data in the first field corresponding to the test device in the specified data table of the Mysql database.
11. The method of claim 7, wherein: The first field and the second field corresponding to each test device in the specified data table specifically correspond to the MAC address of the test device.
12. The method of claim 7, wherein: The method further includes: Analyze the obtained log files corresponding to each test device; obtain the usage time of each application corresponding to each test device; The publishing the log file corresponding to the test device to the intermediary database includes: publishing the obtained usage duration of each application corresponding to the test device as the log file corresponding to the test device to the intermediary database.
13. A log file acquisition server, wherein: The server includes: A publishing unit, adapted to publish a log acquisition request of the test device to the intermediary database when receiving a message that the test of the test device is finished; A monitoring unit, adapted to monitor whether there is a log file corresponding to the test device in the intermediary database; An acquisition unit, adapted to acquire the log file when a log file corresponding to the test device is detected in the intermediary database; Wherein, the intermediary database is a Mysql database; The publishing unit is adapted to publish the log acquisition request of the test device to a first field corresponding to the test device in a specified data table of a MySQL database; The monitoring unit is adapted to poll and monitor whether there is data in the second field corresponding to the test device in the specified data table of the Mysql database; when data is detected in the second field, it is determined that there is a log file corresponding to the test device in the Mysql database.
14. The server according to claim 13, wherein: The intermediary database is a Redis database; The publishing unit is adapted to publish the log acquisition request of the test device to the first channel corresponding to the test device in the Redis database; The monitoring unit is adapted to subscribe to a second channel corresponding to the test device in the Redis database; when there is data in the second channel, determine that there is a log file corresponding to the test device in the Redis database; The first channel corresponds to the second channel one by one.
15. The server according to claim 14, wherein: The first channel and the second channel are identified according to a MAC address of the test device.
16. The server according to claim 13, wherein: The monitoring unit is adapted to set a preset time or a preset frequency; and query whether there is data in the second field corresponding to the test device in the specified data table of the Mysql database at every preset time or at a preset frequency.
17. The server according to claim 13, wherein: The first field and the second field corresponding to each test device in the specified data table specifically correspond to the MAC address of the test device.
18. The server according to claim 13, wherein: The server also includes: The judgment unit is adapted to judge whether the usage duration of each application in the acquired log file is consistent with the preset duration in the corresponding test case. If the judgment is consistent, the test passes.
19. A device for obtaining a log file, wherein: The device includes: An acquisition unit, adapted to acquire log files corresponding to each test device in the router; A monitoring unit, adapted to monitor whether there is a log acquisition request corresponding to each test device in the intermediary database; A publishing unit, adapted to, when a log acquisition request of a test device in the intermediary database is monitored, publish the log file corresponding to the test device to the intermediary database according to the log acquisition request; Wherein, the intermediary database is a Mysql database; The monitoring unit is adapted to poll and monitor whether there is data in the first field corresponding to each test device in the specified data table of the Mysql database; when it is monitored that there is data in the first field corresponding to a test device in the specified data table, it is determined that there is a log acquisition request corresponding to the test device in the Mysql database; The publishing unit is adapted to publish the log file corresponding to the test device to the second field corresponding to the test device in the designated data table of the Mysql database.
20. The device of claim 19, wherein: The intermediary database is a Redis database; The monitoring unit is adapted to subscribe to the first channel corresponding to each test device in the Redis database; when there is data in the first channel corresponding to a test device, it is determined that there is a log acquisition request corresponding to the test device in the Redis database; The publishing unit is adapted to publish the log file corresponding to the test device to the second channel corresponding to the test device in the Redis database; The first channel corresponds to the second channel one by one.
21. The device of claim 20, wherein: The first channel and the second channel are identified according to a MAC address of the test device.
22. The apparatus of claim 19, wherein: The monitoring unit is adapted to set a preset time or a preset frequency; and query whether there is data in the first field corresponding to the test device in the specified data table of the Mysql database at every preset time or at a preset frequency.
23. The apparatus of claim 19, wherein: The first field and the second field corresponding to each test device in the specified data table specifically correspond to the MAC address of the test device.
24. The apparatus of claim 19, wherein: The device also includes: An analysis unit, adapted to analyze the acquired log files corresponding to each test device, and obtain the usage time of each application corresponding to each test device; The publishing unit is adapted to publish the obtained usage duration of each application corresponding to the test device as a log file corresponding to the test device to the intermediary database.
25. A system for obtaining a log file, wherein: The system comprises the server according to any one of claims 13-18 and the device according to any one of claims 19-24.
26. An electronic device, wherein: The electronic device includes: processor; and, A memory arranged to store computer executable instructions which, when executed, cause the processor to perform a method according to any one of claims 1 to 6 or claims 7 to 12.
27. A computer-readable storage medium, wherein: The computer-readable storage medium stores one or more programs, and when the one or more programs are executed by a processor, the method of any one of claims 1 to 6 or claims 7 to 12 is implemented.
Citation Information
Patent Citations
Method for realizing cross-network segment real-time collection
CN102055814A
Message distribution method and device, server and storage medium
CN108390933A