A hard disk command monitoring method and device, electronic equipment and storage medium
By sending commands to the hard drive through monitoring devices, obtaining time information and execution counts, determining the number of timeouts, and recording statistical information, this technology solves the problem of inaccurate hard drive performance detection in existing technologies, and achieves comprehensive monitoring and evaluation of hard drive performance.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- INSPUR SUZHOU INTELLIGENT TECH CO LTD
- Filing Date
- 2023-03-28
- Publication Date
- 2026-06-12
AI Technical Summary
Existing technologies cannot accurately observe the latency distribution of individual commands on a solid-state drive at the host end, making it impossible to fully detect the performance status of the hard drive.
The monitoring device sends commands to the hard drive to obtain the time information and number of times each command is executed. The number of timeouts is determined according to the preset time threshold, and the statistical information of the hard drive's command execution is recorded, including the command information, timestamp, number of executions, and number of timeouts for each command.
It enables comprehensive monitoring of hard drive commands, accurately assesses hard drive performance, and provides more precise performance monitoring results by using timeout counts as an important performance evaluation indicator.
Smart Images

Figure CN116450479B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of hard disk technology, and in particular to a hard disk command detection method, a hard disk command detection device, an electronic device, and a computer-readable storage medium. Background Technology
[0002] With the development of demand for various remote data services such as cloud storage and cloud computing, data storage is increasingly being deployed on remote servers. Consequently, the requirements for data storage response speed are also increasing, along with demands for cost control and functionality. In this context, solid-state drives (SSDs) have been invented to adapt to these technological advancements, and their ultra-fast response speed and large import / export capacity offer significant advantages over traditional hard disk drives (HDDs).
[0003] The speed at which a solid-state drive (SSD) processes commands also determines its performance. Current technology typically uses stress testing tools to perform read and write tests on SSDs, observing the submission latency, completion latency, total latency, and latency distribution of I / O (Input / Output) commands on the host machine. However, this method can only observe I / O commands on the host machine and cannot observe the latency distribution of individual commands. Summary of the Invention
[0004] In view of the above problems, embodiments of the present invention are proposed to provide a hard disk command detection method, a hard disk command detection device, an electronic device, and a computer-readable storage medium that overcome or at least partially solve the above problems.
[0005] In a first aspect, embodiments of the present invention disclose a hard disk command monitoring method, the method being applied to a monitoring device; the monitoring device is connected to a hard disk, and the method includes:
[0006] Send at least one command to the hard disk;
[0007] Obtain the time information and execution number of each time the hard disk executes the command; the time information includes a first timestamp of each time the hard disk obtains the command, and a second timestamp of each time the hard disk completes the execution of the command;
[0008] Based on the time information and the preset time threshold corresponding to the command, determine the number of times the command will time out.
[0009] The system records statistical information on the hard disk executing the commands; the statistical information includes: command information for each command, the first timestamp and the second timestamp corresponding to each command, the preset time threshold, the number of executions, and the number of timeouts.
[0010] Optionally, determining the number of timeouts for executing the command based on the time information and a preset time threshold corresponding to the command includes:
[0011] The difference between the second timestamp and the first timestamp is used as the first execution time for each execution of the command;
[0012] The number of timeouts for executing the command is determined based on the first execution time of each execution of the command and the preset time threshold corresponding to the command.
[0013] Optionally, determining the number of timeouts for executing the command based on the first execution time of each execution of the command and a preset time threshold corresponding to the command includes:
[0014] The first execution time of each execution of the command is compared with the preset time threshold corresponding to the command;
[0015] A first number of commands whose execution time is greater than the preset time threshold is determined from the commands, and the first number is used as the timeout number for executing the commands.
[0016] Optionally, determining the number of timeouts for executing the command based on the time information and a preset time threshold corresponding to the command includes:
[0017] Determine a second number of commands that are currently being executed and have timed out on the hard disk;
[0018] Based on the time information and the preset time threshold corresponding to the command, determine the number of timeouts that the command has been successfully executed;
[0019] The sum of the number of the second command and the number of timeouts for successfully executing the command is taken as the timeout number for the hard disk to execute the command.
[0020] Optionally, determining the second number of commands that are being executed and have timed out on the hard disk includes:
[0021] Detect commands being executed on the hard drive;
[0022] Determine the first timestamp and the current time corresponding to each of the commands being executed;
[0023] The difference between the current time and the first timestamp corresponding to each of the currently executing commands is used as the second execution time of each of the currently executing commands;
[0024] The second execution time of each of the currently executing commands is compared with a preset time threshold corresponding to each of the currently executing commands;
[0025] From the commands being executed, determine a second number of commands whose second execution time is greater than the preset time threshold.
[0026] Optionally, sending at least one command to the hard disk includes:
[0027] Write at least one command to the commit queue of the hard disk so that the hard disk retrieves the command from the commit queue.
[0028] Optionally, the statistical information of the commands executed by the hard disk is recorded; the statistical information includes: command information for each command, the first timestamp corresponding to each command, the second timestamp, the preset time threshold, the number of executions, and the number of timeouts, and further includes:
[0029] A statistical table is generated according to a preset format based on the statistical information, and then output and / or saved.
[0030] Secondly, embodiments of the present invention disclose a hard disk command monitoring device, which is applied to a monitoring device; the monitoring device is connected to a hard disk, and the device includes:
[0031] The sending module is used to send at least one command to the hard disk;
[0032] The acquisition module is used to acquire the time information and the number of times the hard disk executes the command each time; the time information includes a first timestamp of the hard disk acquiring the command each time, and a second timestamp of the hard disk completing the execution of the command each time;
[0033] The determining module is used to determine the number of timeouts for executing the command based on the time information and a preset time threshold corresponding to the command;
[0034] The recording module is used to record statistical information of the hard disk executing the commands; the statistical information includes: command information for each command, the first timestamp and the second timestamp corresponding to each command, the preset time threshold, the number of executions and the number of timeouts.
[0035] Optionally, the determining module includes:
[0036] The first determining submodule is used to take the difference between the second timestamp and the first timestamp as the first execution time for each execution of the command;
[0037] The second determining submodule is used to determine the number of timeouts for executing the command based on the first execution time of each execution of the command and the preset time threshold corresponding to the command.
[0038] Optionally, the second determining submodule includes:
[0039] The comparison unit is used to compare the first execution time of each execution of the command with a preset time threshold corresponding to the command;
[0040] The first determining unit is configured to determine a first number of commands whose first execution time is greater than the preset time threshold from the commands, and to use the first number as the timeout number for executing the commands.
[0041] Optionally, the determined module includes:
[0042] The third determining submodule is used to determine a second number of commands that are being executed and have timed out in the hard disk;
[0043] The fourth determining submodule is used to determine the number of timeouts that the command has been successfully executed based on the time information and the preset time threshold corresponding to the command;
[0044] The fifth determining submodule is used to take the sum of the number of the second commands and the number of timeouts of the commands that have been successfully executed as the timeout number of the commands executed by the hard disk.
[0045] Optionally, the third determining submodule includes:
[0046] A detection unit is used to detect commands being executed on the hard disk;
[0047] The second determining subunit is used to determine the first timestamp and the current time corresponding to each of the commands being executed;
[0048] The third determining subunit is used to take the difference between the current time and the first timestamp corresponding to each of the currently executing commands as the second execution time of each of the currently executing commands;
[0049] The comparison subunit is used to compare the second execution time of each of the currently executing commands with a preset time threshold corresponding to each of the currently executing commands;
[0050] The fourth determining subunit is used to determine, from the commands being executed, a second number of commands whose second execution time is greater than the preset time threshold.
[0051] Optionally, the sending module includes:
[0052] A sending submodule is configured to write at least one command to the commit queue of the hard disk, so that the hard disk retrieves the command from the commit queue.
[0053] Optionally, the device further includes:
[0054] The generation module is used to generate a statistical table according to a preset format based on the statistical information, and then output and / or save it.
[0055] Thirdly, the present invention discloses an electronic device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the above-described hard disk command monitoring method.
[0056] Fourthly, the present invention discloses a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the above-described hard disk command monitoring method.
[0057] The embodiments of the present invention have the following advantages:
[0058] This invention sends at least one command to a hard drive via a monitoring device, obtains the time information and execution count of each command, and determines the number of timeouts based on the time information and a preset time threshold corresponding to the command. It also records statistical information about the hard drive's command execution, including: command information for each command, a first timestamp, a second timestamp, a preset time threshold, the number of executions, and the number of timeouts. Because the commands sent to the hard drive by the monitoring device are not limited to specific commands, compared to existing technologies, this invention can monitor not only the execution status of I / O commands but also the execution status of other commands. This allows for a more comprehensive detection of the hard drive's command execution, and thus, based on the statistical information of the hard drive's command execution, a more accurate monitoring of the hard drive's performance. Attached Figure Description
[0059] Figure 1 This is a flowchart illustrating the steps of a hard disk command monitoring method provided in an embodiment of the present invention;
[0060] Figure 2 This is a structural block diagram of a hard disk command monitoring device provided in an embodiment of the present invention;
[0061] Figure 3 This is a structural block diagram of an electronic device provided in an embodiment of the present invention;
[0062] Figure 4 This is a structural block diagram of a computer-readable storage medium provided in an embodiment of the present invention. Detailed Implementation
[0063] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0064] Existing technologies typically use hard drive stress testing tools to perform read and write tests on solid-state drives (SSDs). However, this method only observes I / O commands on the host side and cannot observe the latency distribution of individual commands, thus failing to fully assess the hard drive's performance. To address this problem, this invention acquires the time information and execution count of each command executed by the hard drive. Based on the time information and a preset time threshold corresponding to the command, it determines the number of timeouts for each command and records statistical information about the hard drive's command execution. This allows for monitoring the number of timeouts for each command processed by the hard drive, enabling a more accurate assessment of the hard drive's performance.
[0065] Reference Figure 1 The diagram illustrates a flowchart of a hard disk command monitoring method according to an embodiment of the present invention. The method is applied to a monitoring device connected to a hard disk, and the method may specifically include the following steps:
[0066] Step 101: Send at least one command to the hard disk.
[0067] In this embodiment of the invention, the performance status of a hard drive can be monitored using a monitoring device. The monitoring device is connected to the hard drive, which can be a solid-state drive (SSD) or other types or models of hard drives; this invention does not impose specific limitations on this. When monitoring the hard drive, the monitoring device can send at least one command to the hard drive. After receiving the command, the hard drive executes the corresponding command and sends the execution result back to the monitoring device, thereby checking the hard drive. The monitoring device can be a host device or other devices; this invention does not impose specific limitations on this either. In this invention, the attributes of the commands sent by the monitoring device to the hard drive can be I / O commands or other commands. To more accurately monitor the performance status of the hard drive, the more attributes corresponding to the commands executed by the hard drive, the more accurate the monitoring results will be. This invention does not impose specific limitations on the attributes of the commands sent by the monitoring device to the hard drive.
[0068] In one embodiment, the monitoring device can write at least one command to the submission list of the hard disk, so that the hard disk can retrieve the command from the submission list. After the hard disk retrieves the command, it can execute the retrieved command. After the hard disk completes the execution of the retrieved command, it can write the execution result to the completion queue. The monitoring device can retrieve the execution result corresponding to the command from the completion queue. The execution result can include a first timestamp of each time the hard disk retrieves the command from the submission list, and a second timestamp of each time the hard disk completes the execution of the command and writes it to the completion queue. Each command has a corresponding first timestamp and second timestamp. For example, if a monitoring device writes three commands, A, B, and C, to the submission list on a hard drive, then the first timestamp will also have three values: A1, B1, and C1. First timestamp A1 is the time when the hard drive retrieves command A from the submission list, first timestamp B1 is the time when the hard drive retrieves command B from the submission list, and first timestamp C1 is the time when the hard drive retrieves command C from the submission list. The second timestamp will also have three values: A2, B2, and C3. Second timestamp A2 is the time when the hard drive writes the command A to the completion queue after execution, second timestamp B2 is the time when the hard drive writes the command B to the completion queue after execution, and second timestamp C2 is the time when the hard drive writes the command C to the completion queue after execution.
[0069] Step 102: Obtain the time information and execution number of each time the command is executed by the hard disk.
[0070] In this embodiment of the invention, after the monitoring device sends at least one command to the hard drive, it can obtain the time information and execution number of each command execution. In this invention, the hard drive can execute each command multiple times. Each time a command is executed, the monitoring device can obtain the time information and execution number of the hard drive's command execution. The time information can include a first timestamp for each command acquisition and a second timestamp for each command execution completion. For example, if the monitoring device sends a command A to the hard drive, and the hard drive executes command A twice, the monitoring device can obtain the first timestamp A1 for the first acquisition of command A, and the second timestamp A11 for the completion of command A corresponding to the first acquisition of command A; and the first timestamp A2 for the second acquisition of command A, and the second timestamp A22 for the completion of command A corresponding to the first acquisition of command A. The first and second timestamps correspond to the same command execution.
[0071] Step 103: Determine the number of timeouts for executing the command based on the time information and the preset time threshold corresponding to the command.
[0072] In this embodiment of the invention, after the monitoring device obtains the time information and number of times each command is executed by the hard disk, it can determine the number of timeouts for executing the command based on the time information and the preset time threshold corresponding to the command. The preset time threshold can be set according to actual needs, and the preset time threshold corresponding to each command can be different. The specific setting value and method are not specifically limited in this invention.
[0073] In one embodiment, the number of timeouts for executing commands in this invention can be determined as follows: the difference between the second timestamp and the first timestamp is used as the first execution time for each command; the number of timeouts for each command is determined based on the first execution time and the preset time threshold corresponding to the command. For example: if the time of first acquisition of command A is A1, i.e., the first timestamp of the first execution of command A is A1, and the completion time corresponding to the first acquisition of command A is A2, i.e., the second timestamp of the first execution of command A is A2, then subtracting the first timestamp A1 from the second timestamp A2 yields the first execution time D1 corresponding to the first execution of command A. The first execution time D1 corresponding to the first execution of command A, combined with the preset time threshold corresponding to command A, can be used to determine whether the first execution of command A timed out. Similarly, this can be used to determine whether the hard disk times out each time it executes a command, and to determine the number of timeouts for each command.
[0074] In one embodiment, the number of timeouts for each command execution is determined based on the first execution time of each command and the corresponding preset time threshold. This can be done as follows: compare the first execution time of each command execution with the corresponding preset time threshold; determine the first number of commands whose first execution time is greater than the preset time threshold, and use this first number as the number of timeouts for the command execution. For example, if the hard drive executes three commands: two commands A and one command B, the first execution time of the first command A is D1, the first execution time of the second command A is D2, and the first execution time of the first command B is D3. The preset time thresholds for command A and command B are E1 and E2, respectively. Compare D1 and D2 with E1, and compare D3 with E2. We find that D1 and D2 are both less than E1, and D3 is greater than E2. Therefore, the number of commands whose first execution time is greater than the preset time threshold can be determined to be 1, meaning the hard drive timed out once during the three command executions, specifically during the execution of command B.
[0075] In this embodiment of the invention, the hard drive receives a command and has been executing it. However, due to some factor, the command has not been executed successfully and remains in the "in execution" state. In reality, the hard drive has timed out while executing the command. In this case, because the timestamp of the command's completion is not obtained, it is impossible to determine whether the command has timed out, which may lead to errors in determining the number of timeouts for the hard drive's command execution. To make the determination of the number of timeouts for command execution more accurate, this invention can determine the number of timeouts for the hard drive's command execution as follows: determine a second number of commands currently executing on the hard drive that have timed out; determine the number of timeouts for successfully executing the command based on time information and a preset time threshold corresponding to the command; and take the sum of the second number of commands and the number of timeouts for successfully executed commands as the total number of timeouts for the hard drive's command execution. For example: if the second number of commands currently executing on the hard drive that have timed out is determined to be 3, and the number of timeouts for successfully executed commands is determined to be 2 based on time information and a preset time threshold corresponding to the command, then the sum of the second number of commands (3) and the number of timeouts for successfully executed commands (2) is taken as the total number of timeouts for the hard drive's command execution (5).
[0076] In one embodiment, determining the second number of commands that are currently being executed and have timed out on the hard disk can be achieved by: detecting commands currently being executed on the hard disk; determining a first timestamp and the current time corresponding to each command being executed; using the difference between the current time and the first timestamp corresponding to each command being executed as the second execution time of each command being executed; comparing the second execution time of each command being executed with a preset time threshold corresponding to each command being executed; and determining the second number of commands whose second execution time is greater than the preset time threshold from the commands being executed.
[0077] For example: If commands A1, A2, and A3 are detected being executed on the hard drive, these three commands can be the same command, meaning the same command is being executed three times, or they can be different commands, meaning different commands are being executed once each. Taking the case where the three commands are the same command, we can determine the first timestamps corresponding to commands A1, A2, and A3 as B1, B2, and B3, respectively, and the current time as C. The differences between the current time C and the first timestamps B1, B2, and B3 are D1, D2, and D3, respectively. Therefore, the second execution times corresponding to commands A1, A2, and A3 are D1, D2, and D3, respectively. Comparing these second execution times D1, D2, and D3 with a preset time threshold E, we find that second execution times D1 and D2 are less than the preset time threshold E, while second execution time D3 is greater than the preset time threshold E. Therefore, we can determine that the second number of commands among commands A1, A2, and A3 whose second execution time is greater than the preset time threshold is 1, and that command A3 timed out.
[0078] Step 104: Record the statistical information of the hard disk executing the command.
[0079] In this embodiment of the invention, after determining the number of timeouts for executing commands, the monitoring device can record statistical information about the hard drive's command execution and determine the hard drive's performance status based on this statistical information. The statistical information may include: command information for each command, a first timestamp, a second timestamp corresponding to each command, a preset time threshold, the number of executions, and the number of timeouts. When the ratio of the number of timeouts to the total number of command executions is less than a preset reference value, it indicates that the hard drive's performance status is excellent. For example, if the total number of command executions is 100, the number of timeouts is 2, and the preset reference value is 5%, then the ratio of the number of timeouts to the total number of command executions is 2%, which is less than the preset reference value of 5%, indicating that the hard drive monitored by the monitoring device has excellent performance.
[0080] In one embodiment, after recording statistical information of commands executed by the hard disk, the monitoring device can generate a statistical table according to a preset format based on the statistical information, and then output and / or save it. For example, the monitoring device can generate a statistical table according to the table format shown in Table 1 below.
[0081]
[0082] Table 1
[0083] After generating the statistical table, it can be output to the user, allowing them to intuitively understand the status of the hard drives monitored by the monitoring equipment. The table can also be saved to the monitoring equipment's memory or the corresponding database so that users can check the hard drive monitoring status at any time.
[0084] In this invention, the statistical tables generated by the monitoring device can be customized by deleting or adding items as needed, based on actual requirements. For example, if only the number of commands executed and the number of timeouts need to be counted in the aforementioned statistical table, the number of commands executed by the hard drive and the number of timeouts can be directly counted. See Table 2 below:
[0085] serial number Order Execution count Number of timeouts 1 A 3 1 2 B 1 0 3 C 1 1 ... ... ... ...
[0086] Table 2
[0087] For example, when the ratio of timeouts to the total number of commands executed is less than a preset reference value, it indicates that the hard drive's performance is excellent. Therefore, by directly counting the total number of commands executed and the total number of timeouts, the hard drive's performance status can be monitored. Based on the statistical information of the hard drive's command execution, a statistical table can be generated as shown in Table 3 below:
[0088] Total number of times the command was executed Total number of timeouts for executing commands 5 2
[0089] Table 3
[0090] In this invention, a statistical table is generated according to a preset format based on statistical information. The preset format can be set according to actual needs, and this invention does not impose any specific limitations on it.
[0091] In this embodiment, at least one command is sent to the hard drive through a monitoring device; the time information and execution count of each command execution by the hard drive are obtained; the time information includes a first timestamp for each command acquisition and a second timestamp for each command completion; based on the time information and a preset time threshold corresponding to the command, the number of timeouts for command execution is determined; and statistical information of command execution by the hard drive is recorded; the statistical information includes: command information for each command, a first timestamp, a second timestamp corresponding to each command, a preset time threshold, the number of executions, and the number of timeouts. This allows for monitoring of the timeout status of each command execution by the hard drive, without being limited by command attributes, and a more accurate assessment of the hard drive's performance status based on the number of timeouts.
[0092] It should be noted that, for the sake of simplicity, the method embodiments are all described as a series of actions. However, those skilled in the art should understand that the embodiments of the present invention are not limited to the described order of actions, because according to the embodiments of the present invention, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions involved are not necessarily essential to the embodiments of the present invention.
[0093] Reference Figure 2 The diagram illustrates a structural block diagram of a hard disk command monitoring device according to an embodiment of the present invention. The device is applied to a monitoring device connected to a hard disk, and the device may specifically include the following modules:
[0094] Sending module 201 is used to send at least one command to the hard disk;
[0095] The acquisition module 202 is used to acquire the time information and the number of times the hard disk executes the command each time; the time information includes a first timestamp of the hard disk acquiring the command each time, and a second timestamp of the hard disk completing the execution of the command each time;
[0096] The determining module 203 is used to determine the number of timeouts for executing the command based on the time information and a preset time threshold corresponding to the command;
[0097] The recording module 204 is used to record statistical information of the hard disk executing the command; the statistical information includes: command information of each command, the first timestamp and the second timestamp corresponding to each command, the preset time threshold, the number of executions and the number of timeouts.
[0098] Optionally, the determining module 203 includes:
[0099] The first determining submodule is used to take the difference between the second timestamp and the first timestamp as the first execution time for each execution of the command;
[0100] The second determining submodule is used to determine the number of timeouts for executing the command based on the first execution time of each execution of the command and the preset time threshold corresponding to the command.
[0101] Optionally, the second determining submodule includes:
[0102] The comparison unit is used to compare the first execution time of each execution of the command with a preset time threshold corresponding to the command;
[0103] The first determining unit is configured to determine a first number of commands whose first execution time is greater than the preset time threshold from the commands, and to use the first number as the timeout number for executing the commands.
[0104] Optionally, the determining module 203 includes:
[0105] The third determining submodule is used to determine a second number of commands that are being executed and have timed out in the hard disk;
[0106] The fourth determining submodule is used to determine the number of timeouts that the command has been successfully executed based on the time information and the preset time threshold corresponding to the command;
[0107] The fifth determining submodule is used to take the sum of the number of the second commands and the number of timeouts of the commands that have been successfully executed as the timeout number of the commands executed by the hard disk.
[0108] Optionally, the third determining submodule includes:
[0109] A detection unit is used to detect commands being executed on the hard disk;
[0110] The second determining subunit is used to determine the first timestamp and the current time corresponding to each of the commands being executed;
[0111] The third determining subunit is used to take the difference between the current time and the first timestamp corresponding to each of the currently executing commands as the second execution time of each of the currently executing commands;
[0112] The comparison subunit is used to compare the second execution time of each of the currently executing commands with a preset time threshold corresponding to each of the currently executing commands;
[0113] The fourth determining subunit is used to determine, from the commands being executed, a second number of commands whose second execution time is greater than the preset time threshold.
[0114] Optionally, the sending module 201 includes:
[0115] A sending submodule is configured to write at least one command to the commit queue of the hard disk, so that the hard disk retrieves the command from the commit queue.
[0116] Optionally, the device further includes:
[0117] The generation module is used to generate a statistical table according to a preset format based on the statistical information, and then output and / or save it.
[0118] In this embodiment, a sending module is used to send at least one command to the hard drive; an acquisition module is used to acquire the time information and execution count of each command executed by the hard drive; the time information includes a first timestamp for each command acquisition and a second timestamp for each command execution completion; a determination module is used to determine the number of timeouts for command execution based on the time information and a preset time threshold corresponding to the command; and a recording module is used to record statistical information of command execution by the hard drive; the statistical information includes: command information for each command, a first timestamp, a second timestamp corresponding to each command, a preset time threshold, the number of executions, and the number of timeouts. This allows for monitoring of the timeout status of each command execution by the hard drive, without being limited by command attributes, and a more accurate assessment of the hard drive's performance status based on the number of timeouts.
[0119] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.
[0120] like Figure 3 The diagram illustrates a structural block diagram of an electronic device provided in an embodiment of the present invention, comprising:
[0121] It includes a processor, a memory, and a computer program stored in the memory and capable of running on the processor. When the computer program is executed by the processor, it implements the various processes of the above-described hard disk command monitoring method embodiments and achieves the same technical effect. To avoid repetition, it will not be described again here.
[0122] like Figure 4 The diagram illustrates a structural block diagram of a computer-readable storage medium provided in this embodiment of the invention. The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the various processes of the above-described hard disk command monitoring method embodiment and achieves the same technical effect. To avoid repetition, it will not be described again here.
[0123] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.
[0124] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, apparatus, or computer program products. Therefore, embodiments of the present invention can take the form of entirely hardware embodiments, entirely software embodiments, or embodiments combining software and hardware aspects. Furthermore, embodiments of the present invention can take the form of computer program products implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0125] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0126] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing terminal device to operate in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0127] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal equipment, causing a series of operational steps to be performed on the computer or other programmable terminal equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable terminal equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0128] Although preferred embodiments of the present invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the embodiments of the present invention.
[0129] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal device. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or terminal device that includes said element.
[0130] The above provides a detailed description of the hard disk command monitoring method, apparatus, electronic device, and storage medium provided by the present invention. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A method for monitoring hard disk commands, characterized in that, The method is applied to monitoring equipment; The monitoring device is connected to a hard disk, and the method includes: Send at least one command to the hard disk; Obtain the time information and execution number of each time the hard disk executes the command; the time information includes a first timestamp of each time the hard disk obtains the command, and a second timestamp of each time the hard disk completes the execution of the command; Based on the time information and the preset time threshold corresponding to the command, determine the number of times the command will time out. The system records statistical information about the commands executed by the hard disk; the statistical information includes: command information for each command, the first timestamp and the second timestamp corresponding to each command, the preset time threshold, the number of executions, and the number of timeouts. The step of determining the number of timeouts for executing the command based on the time information and a preset time threshold corresponding to the command includes: The difference between the second timestamp and the first timestamp is used as the first execution time for each execution of the command; The number of timeouts for executing the command is determined based on the first execution time of each execution of the command and the preset time threshold corresponding to the command; The step of determining the number of timeouts for executing the command based on the time information and a preset time threshold corresponding to the command includes: Detect commands being executed on the hard drive; Determine the first timestamp and the current time corresponding to each of the commands being executed; The difference between the current time and the first timestamp corresponding to each of the currently executing commands is used as the second execution time of each of the currently executing commands; The second execution time of each of the currently executing commands is compared with a preset time threshold corresponding to each of the currently executing commands; From the commands being executed, determine a second number of commands whose second execution time is greater than the preset time threshold; Based on the time information and the preset time threshold corresponding to the command, determine the number of timeouts that the command has been successfully executed; The sum of the second quantity and the number of timeouts for successfully executing the command is taken as the timeout number for the hard disk to execute the command.
2. The hard disk command monitoring method according to claim 1, characterized in that, The step of determining the number of timeouts for executing the command based on the first execution time of each execution of the command and the preset time threshold corresponding to the command includes: The first execution time of each execution of the command is compared with the preset time threshold corresponding to the command; A first number of commands whose execution time is greater than the preset time threshold is determined from the commands, and the first number is used as the timeout number for executing the commands.
3. The hard disk command monitoring method according to claim 1, characterized in that, Sending at least one command to the hard disk includes: Write at least one command to the commit queue of the hard disk so that the hard disk retrieves the command from the commit queue.
4. The hard disk command monitoring method according to claim 1, characterized in that, The record contains statistical information about the commands executed by the hard disk; the statistical information includes: command information for each command, a first timestamp corresponding to each command, a second timestamp, a preset time threshold, the number of executions, and the number of timeouts, and further includes: A statistical table is generated according to a preset format based on the statistical information, and then output and / or saved.
5. A hard disk command monitoring device, characterized in that, The device is used in monitoring equipment; The monitoring device is connected to a hard disk, and the device includes: The sending module is used to send at least one command to the hard disk; The acquisition module is used to acquire the time information and the number of times the hard disk executes the command each time; the time information includes a first timestamp of the hard disk acquiring the command each time, and a second timestamp of the hard disk completing the execution of the command each time; The determining module is used to determine the number of timeouts for executing the command based on the time information and a preset time threshold corresponding to the command; A recording module is used to record statistical information of the commands executed by the hard disk; the statistical information includes: command information for each command, a first timestamp corresponding to each command, a second timestamp, a preset time threshold, the number of executions, and the number of timeouts; The determining module includes: The first determining submodule is used to take the difference between the second timestamp and the first timestamp as the first execution time for each execution of the command; The second determining submodule is used to determine the number of timeouts for executing the command based on the first execution time of each execution of the command and the preset time threshold corresponding to the command; The determining module includes: The third determining submodule is used to detect commands being executed on the hard disk; determine a first timestamp and the current time corresponding to each command being executed; take the difference between the current time and the first timestamp corresponding to each command being executed as the second execution time of each command being executed; compare the second execution time of each command being executed with a preset time threshold corresponding to each command being executed; and determine a second number of commands whose second execution time is greater than the preset time threshold from the commands being executed. The fourth determining submodule is used to determine the number of timeouts that the command has been successfully executed based on the time information and the preset time threshold corresponding to the command; The fifth determining submodule is used to take the sum of the second quantity and the number of timeouts in which the command has been successfully executed as the number of timeouts in which the hard disk executes the command.
6. An electronic device, characterized in that, include: A processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program, when executed by the processor, implements the steps of the hard disk command monitoring method as described in any one of claims 1-4.
7. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, which, when executed by a processor, implements the steps of the hard disk command monitoring method as described in any one of claims 1-4.