A device information acquisition method, apparatus, device, and medium

By sending public key information to the device and verifying the key before logging in, the device information is automatically obtained and a binding relationship is established, which solves the problems of low efficiency and insufficient security in the existing technology for obtaining device information, and realizes efficient and secure device information management.

CN114238934BActive Publication Date: 2026-07-21TENCENT CLOUD COMPUTING (BEIJING) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
TENCENT CLOUD COMPUTING (BEIJING) CO LTD
Filing Date
2021-12-28
Publication Date
2026-07-21

AI Technical Summary

Technical Problem

In existing technologies, obtaining device information from multiple devices is inefficient and not secure enough.

Method used

By sending public key information to the target device, logging into the device after key verification, and sending a device information retrieval command to automatically obtain device information, a binding relationship between device information is established.

Benefits of technology

It improves the efficiency and security of equipment information acquisition, reduces manual operation, and is suitable for the management of large-scale equipment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114238934B_ABST
    Figure CN114238934B_ABST
Patent Text Reader

Abstract

The embodiment of the present specification discloses a device information acquisition method, device, apparatus and medium, the device information acquisition method comprises: determining a target device, sending public key information to each target device, so that the target device stores the public key information; for any target device, verifying the public key information stored by the target device according to the private key information, and logging in the target device after verification; send a device information acquisition command to the target device to acquire the device information of the target device, and display the acquired device information of the target device.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a method, apparatus, device and medium for acquiring device information. Background Technology

[0002] In existing technologies, many situations require the use of multiple or even large numbers of devices to complete business or work, and obtaining the device information of each device is a very important issue.

[0003] Therefore, a more efficient solution for acquiring equipment information is needed. Summary of the Invention

[0004] This specification provides a method, apparatus, device, and medium for acquiring device information, in order to solve the technical problem of how to acquire device information more efficiently.

[0005] To address the aforementioned technical problems, the embodiments in this specification provide the following technical solutions:

[0006] This specification provides an embodiment of a method for obtaining device information, including:

[0007] Identify target devices and send public key information to each target device so that the target device stores the public key information;

[0008] For any target device, verify the public key information stored on the target device based on the private key information, and log in to the target device after successful verification;

[0009] Send a device information retrieval command to the target device to obtain the device information of the target device, and display the obtained device information of the target device.

[0010] Optionally, sending public key information to each target device includes: executing a key distribution script to send public key information to each target device;

[0011] or,

[0012] Identify the target devices and send public key information to each target device, including:

[0013] Determine the IP information of each target device and send public key information to the target device corresponding to each IP information.

[0014] Optionally, identify the target devices and send public key information to each target device, including:

[0015] Construct an IP information list containing the IP information of each target device, and send public key information to the target device corresponding to each IP information in the IP information list in sequence.

[0016] Optionally, sending a device information acquisition command to the target device includes: executing a device information acquisition script to send a device information acquisition command to the target device.

[0017] Optionally, the device information includes IP information and MAC address information.

[0018] Optionally, the method further includes:

[0019] For any target device, after obtaining the device information of the target device, a binding relationship is established between the IP information and the MAC address information of the target device.

[0020] Optionally, the device information of the target device obtained may be displayed, including:

[0021] Based on the binding relationship, display the device information of the target device obtained.

[0022] This specification provides an embodiment of a device for acquiring device information, including:

[0023] The targeting module is used to identify target devices and send public key information to each target device so that the target device stores the public key information.

[0024] The login module is used to verify the public key information stored on any target device based on the private key information, and log in to the target device after successful verification.

[0025] The acquisition module is used to send a device information acquisition command to the target device to obtain the device information of the target device and display the acquired device information.

[0026] This specification provides an embodiment of a device for acquiring device information, including:

[0027] At least one processor;

[0028] as well as,

[0029] A memory that is communicatively connected to the at least one processor;

[0030] in,

[0031] The memory stores instructions that can be executed by the at least one processor, which, when executed by the at least one processor, enables the at least one processor to perform the device information acquisition method described above.

[0032] This specification provides a computer-readable storage medium storing computer-executable instructions that, when executed by a processor, implement the device information acquisition method described above.

[0033] The above-described at least one technical solution adopted in the embodiments of this specification can achieve the following beneficial effects:

[0034] The above technical solution logs into the target device after key verification and automatically obtains the device information of each target device through the device information acquisition command, thereby improving the efficiency and security of device information acquisition. Attached Figure Description

[0035] To more clearly illustrate the technical solutions in the embodiments of this specification or the prior art, the drawings used in the description of the embodiments of this specification or the prior art will be briefly introduced below. Obviously, the drawings described below are only some of the drawings that may be involved in the embodiments described in this specification. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0036] Figure 1 This is a schematic diagram of the execution subject of the device information acquisition method in the first embodiment of this specification.

[0037] Figure 2 This is a flowchart illustrating the device information acquisition method in the first embodiment of this specification.

[0038] Figure 3 This is a schematic diagram of the device information acquisition process in the first embodiment of this specification.

[0039] Figure 4 This is a schematic diagram of the device information acquisition device in the second embodiment of this specification. Detailed Implementation

[0040] To enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions of the embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings. Obviously, the embodiments described in this specification are merely some embodiments of this application, and not all embodiments. Based on the embodiments of this specification, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of this application.

[0041] In existing technologies, many situations require the use of multiple or even large numbers of devices to complete business or work, and obtaining the device information of each device is a very important issue.

[0042] The first embodiment of this specification (hereinafter referred to as "Embodiment 1") provides a method for acquiring device information. The executing entity of Embodiment 1 can be a terminal (including but not limited to mobile phones, computers, tablets, and televisions), a server, an operating system, an application, a device information acquisition platform, or a device information acquisition system, etc. That is, the executing entity can be diverse and can be set, used, or changed as needed. Alternatively, a third-party application can assist the executing entity in executing Embodiment 1. For example... Figure 1 As shown, the device information acquisition method in Embodiment 1 can be executed by the server, and a corresponding application can be installed on the terminal (held by the user). Data can be transmitted between the terminal or the application and the server. Data can be collected, input, or output, or pages or information can be processed (to the user) through the terminal or the application, thereby assisting the server in executing the device information acquisition method in Embodiment 1.

[0043] like Figure 2 As shown, the device information acquisition method provided in Embodiment 1 includes:

[0044] S101: (Executing entity) determines the target device and sends public key information to each target device so that the target device stores the public key information;

[0045] The executing entity of Example 1 (e.g.) Figure 3 The admin in the example can identify the target device, which is the device that needs to provide device information to the execution entity of Embodiment 1. The target device can be a server (e.g., a admin server). Figure 3 The target devices can be servers or other types of devices. For example, the executing entity in Embodiment 1 can use various devices used to perform the same service as target devices, or it can use various devices connected to the same network as target devices. Embodiment 1 does not limit the form, number, or method of determining the target devices.

[0046] After identifying each target device, the executing entity in Implementation Example 1 can send its public key information (public key information is information related to the public key, which may be the public key itself) to each target device, that is, send the public key information to each target device so that each target device can obtain and store the public key information.

[0047] The executing entity in Implementation Example 1 can determine each target device, and thus determine the IP information (i.e., IP address information) of each target device. Therefore, determining the target devices and sending public key information to each target device may include: determining the IP information of each target device separately, and sending the public key information to the target device corresponding to each determined IP information. That is, the executing entity in Implementation Example 1 may determine the device name of each target device, and also needs to determine the IP information of each target device, and then send the public key information to the device corresponding to each determined IP information (i.e., each target device).

[0048] Additionally, identifying target devices and sending public key information to each target device can include: constructing an IP information list containing the IP information of each target device (the IP information list is used to define each IP information), and sequentially sending the public key information to the target devices corresponding to each IP information in the IP information list, that is, sending the public key information to the target devices corresponding to each IP information in the order of the IP information in the IP information list. A specific example could be: constructing a hosts.ini file, which contains the IP information list.

[0049] In Embodiment 1, a key distribution script can be pre-built for the executing entity of Embodiment 1. Sending public key information to each target device can then include executing the key distribution script to send public key information to each target device. A specific example could be that the executing entity of Embodiment 1 can install the Ansible system and build a key distribution script file (e.g., named ssh_key.yml), where the key distribution strategy in the key distribution script file is defined through the authorized_key method. The key distribution script can be built by the executing entity of Embodiment 1, or it can be built by other devices and sent to the executing entity of Embodiment 1. The executing entity of Embodiment 1 executes the key distribution script and sends public key information to each target device according to the key distribution strategy, including sequentially sending public key information to the target devices corresponding to each IP information in the IP information list. This is only an example and is not intended to limit Embodiment 1.

[0050] S103: (Executing entity) For any target device, verify the public key information stored on the target device based on the private key information, and log in to the target device after successful verification;

[0051] For any target device, after the executing entity of Embodiment 1 sends public key information to the target device, the executing entity of Embodiment 1 can perform the login operation on the target device. The login operation includes: the executing entity of Embodiment 1 automatically inputting the login username and password for the target device; and the executing entity of Embodiment 1 verifying the public key information stored by the target device based on its own stored private key information (i.e., verifying whether its own stored private key information matches the public key information stored by the target device); after successful verification (i.e., verification matching), the executing entity of Embodiment 1 logs into the target device. For example, if the target device is a server, after successful verification, the executing entity of Embodiment 1 logs into the server's server system. Specifically, if the verification fails, the executing entity of Embodiment 1 cannot log into the target device, thus ensuring that the entity logging into the target device is indeed the executing entity of Embodiment 1, and also ensuring that the executing entity of Embodiment 1 has logged into the correct target device.

[0052] S105: (Executing entity) sends a device information acquisition command to the target device to obtain the device information of the target device and displays the obtained device information of the target device.

[0053] For any target device, after the execution entity of Implementation Example 1 logs into the target device, it can send a device information retrieval command to the target device.

[0054] In Embodiment 1, a device information acquisition script can be pre-built for the execution entity of Embodiment 1. Sending a device information acquisition command to the target device may include: executing the device information acquisition script to send a device information acquisition command to the target device.

[0055] In Implementation Example 1, device information may include IP information and MAC address information.

[0056] As described above, the Ansible system can be installed on the execution entity of Embodiment 1. A specific example of constructing the device information acquisition script can be: create a new folder, and write an Ansible directory tree in the new folder, containing: roles, groups, and hosts.ini (as described above). Construct a general execution script (for example, using a Mac-ip.yml file to define the general execution script, and the corresponding device information may include IP information and MAC address information) to execute the contents in roles (i.e., roles, representing target devices). Construct a groups variable script env.yml to define global variable information (global variable information can be common characteristics of various target devices, including variables such as target device names), for roles to call. Construct specific information in roles (the specific information can be executed by the target device, for example, the specific information is an instruction for the target device to send its device information to the execution entity of Embodiment 1), and the specific scripts of roles can be stored in the tasks folder under the roles folder. Construct a main.yml under the tasks folder to specify the script that makes the target device provide device information. A script is constructed to obtain IP and MAC address information from the playbook. The execution command is defined using a shell method. After the script sends its device information to the target device, the device information sent by the target device is output to a specified file, for example, named Mac-ip.txt. In summary, the execution order of the device information acquisition script in Embodiment 1 can be ansible-playbook-i hosts.ini Mac-ip.yml. For example... Figure 3 As shown.

[0057] Specifically, for any target device, the executing entity in Embodiment 1 sends a device information retrieval command to the target device to obtain its device information. This can include: after logging into the target device, the executing entity in Embodiment 1 uses a shell method to send the device information retrieval command to the target device. The target device then sends its device information to the executing entity in Embodiment 1, which saves the device information to the designated file.

[0058] The naming of the scripts or folders mentioned above is merely an example and is not intended to limit the scope of Example 1.

[0059] In Embodiment 1, after obtaining the device information of the previous target device, public key information can be sent to the next target device so that the next target device stores the public key information; the public key information stored by the next target device can be verified according to the private key information, and the next target device can be logged in after successful verification; a device information retrieval command can be sent to the next target device to obtain the device information of the next target device.

[0060] For any target device, after the executing entity in Embodiment 1 obtains the device information of the target device, it can establish a binding relationship between the device information of the target device. For example, if the device information includes IP information and MAC address information, then after the executing entity in Embodiment 1 obtains the device information of the target device, it can establish a binding relationship between the IP information and the MAC address information of the target device, that is, the IP information and MAC address information of each target device are a pair of mutually bound device information.

[0061] After acquiring device information for one or more target devices, the execution entity in Embodiment 1 can display the acquired device information. Displaying the acquired device information may include: displaying the acquired device information through the specified file. Alternatively, displaying the acquired device information may include: displaying the acquired device information for each target device according to the binding relationships between their device information. For example, the device information for each target device can be displayed in a list format, and device information with binding relationships can be displayed in a preset format to represent the binding relationships between the device information. For example, each pair of device information with a binding relationship can be displayed in the same row of the device information list.

[0062] In Embodiment 1, the executing entity can add newly acquired device information to the already displayed device information each time it acquires device information for a target device, in order to display the newly acquired device information. For example, each time device information for a target device is acquired, that device information is saved in the designated file for display.

[0063] In Implementation Example 1, login to the target device is performed after key verification, enhancing security. A device information retrieval command causes each target device to automatically send its device information to the execution entity in Implementation Example 1. This allows the execution entity to automatically acquire and display the device information of each target device, improving both the efficiency and security of device information retrieval. Since Implementation Example 1 can automatically acquire the device information of each target device, it eliminates the tedious step of manually checking the device information of each device one by one, effectively reducing labor costs and time consumption.

[0064] As can be seen from the above, Example 1 is particularly suitable for obtaining equipment information of a large number of target devices.

[0065] By acquiring the device information of the target devices, the target devices can be managed. For example, when performing online / offline or other operations on the target devices, the device information may be needed. Therefore, after automatically acquiring the device information of each target device through Embodiment 1, the device information of each target device can be directly used to perform online / offline or other operations on each target device, thereby improving the management efficiency of the target devices.

[0066] like Figure 4 As shown, the second embodiment of this specification provides a device information acquisition apparatus corresponding to the device information acquisition method described in Embodiment 1, comprising:

[0067] The targeting module 202 is used to determine target devices and send public key information to each target device so that the target device stores the public key information;

[0068] The login module 204 is used to verify the public key information stored in any target device based on the private key information, and log in to the target device after successful verification.

[0069] The acquisition module 206 is used to send a device information acquisition command to the target device to obtain the device information of the target device and display the obtained device information of the target device.

[0070] Optionally, sending public key information to each target device includes: executing a key distribution script to send public key information to each target device;

[0071] or,

[0072] Identify the target devices and send public key information to each target device, including:

[0073] Determine the IP information of each target device and send public key information to the target device corresponding to each IP information.

[0074] Optionally, identify the target devices and send public key information to each target device, including:

[0075] Construct an IP information list containing the IP information of each target device, and send public key information to the target device corresponding to each IP information in the IP information list in sequence.

[0076] Optionally, sending a device information acquisition command to the target device includes: executing a device information acquisition script to send a device information acquisition command to the target device.

[0077] Optionally, the device information includes IP information and MAC address information.

[0078] Optionally, the acquisition module 206 is further configured to, after acquiring the device information of any target device, establish a binding relationship between the IP information and the MAC address information of the target device.

[0079] Optionally, the device information of the target device obtained may be displayed, including:

[0080] Based on the binding relationship, display the device information of the target device obtained.

[0081] The third embodiment of this specification provides a device for acquiring device information, including:

[0082] At least one processor;

[0083] as well as,

[0084] A memory that is communicatively connected to the at least one processor;

[0085] in,

[0086] The memory stores instructions that can be executed by the at least one processor, which, when executed by the at least one processor, enables the at least one processor to perform the device information acquisition method described in Embodiment 1.

[0087] The fourth embodiment of this specification provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the device information acquisition method described in Embodiment 1.

[0088] The above embodiments can be used in combination, and modules with the same name in different embodiments or within the same embodiment can be the same or different modules.

[0089] The foregoing has described specific embodiments of this specification; other embodiments are within the scope of the appended claims. In some cases, the actions or steps described in the claims may be performed in a different order than those shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily have to follow the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0090] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the embodiments of apparatus, devices, and non-volatile computer-readable storage media are basically similar to the method embodiments, so the descriptions are relatively simple; relevant parts can be referred to the descriptions of the method embodiments.

[0091] The apparatus, device, non-volatile computer-readable storage medium and method provided in the embodiments of this specification are corresponding. Therefore, the apparatus, device and non-volatile computer storage medium also have similar beneficial technical effects as the corresponding method. Since the beneficial technical effects of the method have been described in detail above, the beneficial technical effects of the corresponding apparatus, device and non-volatile computer storage medium will not be repeated here.

[0092] In the 1990s, improvements to a technology could be clearly distinguished as either hardware improvements (e.g., improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to the methodology). However, with technological advancements, many methodological improvements today can be considered direct improvements to the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved methodology into the hardware circuit. Therefore, it cannot be said that a methodological improvement cannot be implemented using hardware physical modules. For example, a Programmable Logic Device (PLD) (such as a Field Programmable Gate Array (FPGA)) is such an integrated circuit whose logic function is determined by the user programming the device. Designers can program and "integrate" a digital system onto a PLD themselves, without needing chip manufacturers to design and manufacture dedicated integrated circuit chips. Furthermore, nowadays, instead of manually manufacturing integrated circuit chips, this programming is mostly implemented using "logic compiler" software. Similar to the software compiler used in program development, the original code before compilation must be written in a specific programming language, called a Hardware Description Language (HDL). There are many HDLs, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, and RHDL (Ruby Hardware Description Language). Currently, the most commonly used are VHDL (Very-High-Speed ​​Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should understand that by simply performing some logic programming on the method flow using one of these hardware description languages ​​and programming it into an integrated circuit, the hardware circuit implementing the logical method flow can be easily obtained.

[0093] The controller can be implemented in any suitable manner. For example, it can take the form of a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro)processor, logic gates, switches, application-specific integrated circuits (ASICs), programmable logic controllers, and embedded microcontrollers. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicon Labs C8051F320. A memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art will also recognize that, in addition to implementing the controller in purely computer-readable program code form, the same functionality can be achieved by logically programming the method steps to make the controller take the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers. Therefore, such a controller can be considered a hardware component, and the means included therein for implementing various functions can also be considered as structures within the hardware component. Alternatively, the means for implementing various functions can be considered as both software modules implementing the method and structures within the hardware component.

[0094] The systems, devices, modules, or units described in the above embodiments can be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, a computer can be, for example, a personal computer, laptop computer, cellular phone, camera phone, smartphone, personal digital assistant, media player, navigation device, email device, game console, tablet computer, wearable device, or any combination of these devices.

[0095] For ease of description, the above devices are described in terms of function, divided into various units. Of course, in implementing this specification, the functions of each unit can be implemented in one or more software and / or hardware components.

[0096] Those skilled in the art will understand that the embodiments of this specification can be provided as methods, systems, or computer program products. Therefore, the embodiments of this specification can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the embodiments of this specification can take the form of a computer program product 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.

[0097] This specification is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this specification. 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 apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create a machine 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.

[0098] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function 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.

[0099] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable 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.

[0100] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0101] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0102] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.

[0103] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus 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 apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0104] This specification can be described in the general context of computer-executable instructions that are executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform a specific task or implement a specific abstract data type. This specification can also be practiced in distributed computing environments, where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.

[0105] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to interchangeably. Each embodiment focuses on describing the differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments.

[0106] The above description is merely an embodiment of this specification and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principle of this application should be included within the scope of the claims of this application.

Claims

1. A method for obtaining device information, wherein the execution entity of the method has an Ansible system installed, and a newly created folder contains an Ansible directory tree, including roles, groups, and hosts.ini; the method includes: The target device and its IP information are determined, and public key information is sent to the target device corresponding to each determined IP information so that the target device stores the public key information; The process of determining the target devices and their IP information, and sending public key information to the target devices corresponding to the determined IP information, includes: constructing a hosts.ini file containing a list of IP information for each target device; executing a key distribution script to send public key information to the target devices corresponding to each IP information in the IP information list in sequence according to the key distribution strategy; and defining the key distribution strategy in the key distribution script file using the authorized_key method. For any target device, the system automatically inputs the login username and password of the target device, verifies the public key information stored in the target device based on its own stored private key information, and logs in to the target device after successful verification. A device information retrieval script is executed to send a device information retrieval command to the target device to obtain its device information, including IP information and MAC address information. The method for constructing the device information retrieval script includes: writing a Mac-ip.yml file to define a general execution script to execute the content in the roles, where roles are the target devices; constructing a groups variable script env.yml to define global variable information, which are common characteristics of all target devices and are called by roles; constructing specific information in roles, which is executed by the target device and is an instruction for the target device to send its device information to the execution entity; storing the roles script in a tasks folder under the roles folder; constructing a main.yml file under the tasks folder to specify the script that causes the target device to provide IP and MAC address information; constructing a playbook script to retrieve IP and MAC address information, defining the execution command using a shell method, and outputting the device information sent by the target device to a specified file after the target device executes the script that sends its device information. After obtaining the device information of the target device, establish a binding relationship between the IP information and the MAC address information of the target device; Based on the binding relationship, display the device information of the target device obtained.

2. A device information acquisition apparatus, wherein the execution entity on which the apparatus is applied has the Ansible system installed, and a newly created folder contains an Ansible directory tree, including roles, groups, and hosts.ini, the apparatus comprising: The targeting module is used to determine the target device and the IP information of each target device, and send public key information to the target device corresponding to each determined IP information, so that the target device stores the public key information; The process of determining the target devices and their IP information, and sending public key information to the target devices corresponding to the determined IP information, includes: constructing a hosts.ini file containing a list of IP information for each target device; executing a key distribution script to send public key information to the target devices corresponding to each IP information in the IP information list in sequence according to the key distribution strategy; and defining the key distribution strategy in the key distribution script file using the authorized_key method. The login module is used to automatically input the login username and password of any target device, verify the public key information stored in the target device based on its own stored private key information, and log in to the target device after successful verification. The acquisition module is used to execute a device information acquisition script, send a device information acquisition command to the target device to obtain the device information of the target device, which includes IP information and MAC address information; after obtaining the device information of the target device, establish a binding relationship between the IP information and the MAC address information of the target device; and display the acquired device information of the target device according to the binding relationship. The method for constructing the device information acquisition script includes: writing a Mac-ip.yml file to define a general execution script to execute the content of the roles, where the roles are the target devices; and constructing the groups variable script env. The `.yml` file is used to define global variable information, which are common characteristics of all target devices and are called by `roles`. Specific information is constructed within `roles`, which is executed by the target device and is an instruction for the target device to send its device information to the executing entity. The `roles` scripts are stored in the `tasks` folder under the `roles` folder. A `main.yml` file is constructed in the `tasks` folder to specify the script that causes the target device to provide IP and MAC address information. A script is constructed for the playbook to obtain IP and MAC address information, using a shell method to define the execution command. After the target device executes the script that sends its device information, the device information sent by the target device is output to a specified file.

3. A device for acquiring device information, comprising: At least one processor; as well as, A memory that is communicatively connected to the at least one processor; in, The memory stores instructions that can be executed by the at least one processor, which, when executed by the at least one processor, enables the at least one processor to perform the device information acquisition method of claim 1.

4. A computer-readable storage medium storing computer-executable instructions that, when executed by a processor, implement the device information acquisition method of claim 1.

5. A computer program product comprising computer instructions stored in a computer-readable storage medium, wherein a processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions to cause the computer device to perform the device information acquisition method as described in claim 1.