Method and device for collecting configuration file
By deploying virtual agents on virtual machines, the virtual machine configuration files are automatically collected, and the problem of low collection efficiency in the existing technology is solved, efficient and accurate configuration file collection is achieved, and the risk of manual operation is reduced.
Patent Information
- Application Number
- CN202510219639.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-26
- Publication Date
- 2025-06-13
AI Technical Summary
In the prior art, the acquisition of virtual machine configuration files is relatively low, relies on manual operations, is inefficient and prone to negligence and errors, which increases security risks and performance overhead.
By deploying the target virtual agent on the target virtual machine, receiving the acquisition instructions of the unified scheduling platform, determining the path of the target configuration file, calling the target script to collect the configuration file, and updating the target mapping relationship when the configuration item changes.
It realizes automatic acquisition of virtual machine configuration files, improves collection efficiency, reduces dependence on manual operations, reduces security risks and performance overhead, and ensures the integrity and accuracy of configuration information.
Smart Images

Figure CN120144206A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of communications, and more particularly, to a method and apparatus for collecting configuration files. Background Art
[0002] In the current context where cloud computing and virtualization technologies are widely used, enterprise data centers often run a large number of virtual machines. The configuration information of these virtual machines is crucial for operation and maintenance tasks such as the stable operation of the system, performance optimization, fault troubleshooting, and compliance auditing.
[0003] Currently, the common operation and maintenance method is for operation and maintenance personnel to manually log in to each virtual machine and use specific commands or tools to search for and view the required configuration files. This method relies on manual operations and has low efficiency. For example, in a large data center with hundreds or thousands of virtual machines, if an operation and maintenance personnel wants to check the settings of a certain configuration item in all virtual machines, it may take several days or even weeks. Moreover, manual operations are prone to negligence and errors, and the operation habits and standards of different operation and maintenance personnel are inconsistent, which may lead to incomplete or inaccurate collection of configuration information. In addition, frequent login operations also bring additional security risks and performance overhead to the virtual machine system.
[0004] In view of the above problems, there is currently no effective solution. Summary of the Invention
[0005] Embodiments of the present invention provide a method and apparatus for collecting configuration files to at least solve the problem of low efficiency in collecting configuration files of virtual machines in related technologies.
[0006] According to an embodiment of the present invention, there is provided a method for collecting configuration files, which is applied to a target virtual agent deployed on a target virtual machine, and includes: receiving a target collection instruction from a unified scheduling platform, where the target collection instruction is used to indicate collecting a target configuration file of the target virtual machine, and the unified scheduling platform is used to instruct virtual agents deployed on different virtual machines to collect each configuration file on the virtual machine; determining a target path of the target configuration file in a target mapping relationship, where the target mapping relationship records paths of each configuration file of the target virtual machine; and calling a target script and collecting the target configuration file according to the target path through the target script, where the target virtual agent includes multiple scripts, and each script is used to collect a corresponding configuration file of the target virtual machine.
[0007] In an exemplary embodiment, the method further includes: updating the target mapping relationship when at least one of the following conditions is satisfied: a configuration item of the target virtual machine changes, or a path of a configuration file of the target virtual machine changes; the target configuration file is a configuration file of a target configuration item of the target virtual machine, and the target mapping relationship records the correspondence between the configuration file of each configuration item of the target virtual machine and the path of the configuration file.
[0008] In an exemplary embodiment, when a configuration item of the target virtual machine changes, updating the target mapping relationship includes: when a first configuration item is newly added to the target virtual machine, obtaining a first configuration file of the first configuration item and a first path of the first configuration file; establishing a correspondence between the first configuration file and the first path and recording it in the target mapping relationship; when a second configuration item of the target virtual machine is deleted, deleting, in the target mapping relationship, the mapping relationship between a second configuration file of the second configuration item and a second path, where the second path is the path of the second configuration file.
[0009] In an exemplary embodiment, when a path of a configuration file of the target virtual machine changes, updating the target mapping relationship includes: when a path of a third configuration file of the target virtual machine changes from a first path to a second path, changing the path of the third configuration file in the target mapping relationship to the second path.
[0010] In an exemplary embodiment, invoking a target script includes: determining an operating system of the target virtual machine as a target operating system; determining, among a plurality of scripts included in the target virtual agent, the target script corresponding to the target operating system and the target configuration file, where the target script is used to collect the target configuration file.
[0011] In an exemplary embodiment, after collecting the target configuration file by the target script according to the target path, the method further includes: naming the target configuration file in a preset format and sending the named target configuration file to the unified scheduling platform.
[0012] According to another embodiment of the present invention, there is provided an apparatus for collecting configuration files, which is applied to a target virtual agent deployed on a target virtual machine, and includes: a receiving module, configured to receive a target collection instruction from a unified scheduling platform, where the target collection instruction is used to indicate collecting a target configuration file of the target virtual machine, and the unified scheduling platform is used to instruct virtual agents deployed on different virtual machines to collect respective configuration files of the virtual machine; a determining module, configured to determine a target path of the target configuration file in a target mapping relationship, where the target mapping relationship records paths of respective configuration files of the target virtual machine; and a calling module, configured to call a target script and collect the target configuration file according to the target path through the target script, where the target virtual agent includes a plurality of scripts, and each of the scripts is used to collect a corresponding configuration file of the target virtual machine.
[0013] According to still another embodiment of the present invention, there is also provided a computer-readable storage medium storing a computer program, where when the computer program is executed by a processor, the steps of the method described in any one of the above are implemented.
[0014] According to still another embodiment of the present invention, there is also provided an electronic device including a memory and a processor, where a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0015] According to still another embodiment of the present invention, there is also provided a computer program product including a computer program, where when the computer program is executed by a processor, the steps of the method described in any one of the above are implemented.
[0016] With the present invention, since a target virtual agent is deployed on the target virtual machine, the target virtual agent receives a target collection instruction from the unified scheduling platform, the target collection instruction is used to indicate collecting the target configuration file of the target virtual machine, and the unified scheduling platform is used to instruct virtual agents deployed on different virtual machines to collect respective configuration files of the virtual machine; determine the target path of the target configuration file in the target mapping relationship, where the target mapping relationship records paths of respective configuration files of the target virtual machine; call the target script and collect the target configuration file according to the target path through the target script, the target virtual agent includes a plurality of scripts, and each of the scripts is used to collect a corresponding configuration file of the target virtual machine. The purpose of automatically collecting the target configuration file on the target virtual machine is achieved, and the effect of improving the efficiency of collecting the configuration file of the virtual machine is achieved. Therefore, the problem of low efficiency in collecting the configuration file of the virtual machine in the related art can be solved, and the effect of improving the efficiency of collecting the configuration file of the virtual machine can be achieved. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 It is a hardware block diagram of a mobile terminal for a method of collecting configuration files according to an embodiment of the present invention;
[0018] Figure 2 It is a flowchart of a method of collecting configuration files according to an embodiment of the present invention;
[0019] Figure 3 It is a schematic diagram of the program structure of a target virtual agent according to an embodiment of the present invention;
[0020] Figure 4 It is a schematic diagram of a configuration item update process according to an embodiment of the present invention;
[0021] Figure 5 It is a block diagram of the structure of a device for collecting configuration files according to an embodiment of the present invention. Specific Embodiments
[0022] In the following, embodiments of the present invention will be described in detail with reference to the accompanying drawings and in conjunction with the embodiments.
[0023] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and do not necessarily have to be used to describe a specific order or sequence.
[0024] The method embodiments provided in the embodiments of the present application can be executed on a mobile terminal, a computer terminal, or a similar computing device. Taking running on a mobile terminal as an example, Figure 1 It is a hardware block diagram of a mobile terminal for a method of collecting configuration files according to an embodiment of the present invention. As Figure 1 shown, the mobile terminal may include one or more ( Figure 1 only one is shown in Figure 1 the processor 102 (the processor 102 may include, but is not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data. Among them, the above-mentioned mobile terminal may further include a transmission device 106 for communication functions and an input / output device 108. Those of ordinary skill in the art can understand that Figure 1 the structure shown in Figure 1 is only schematic and does not limit the structure of the above-mentioned mobile terminal. For example, the mobile terminal may further include more or fewer components than
[0025] The memory 104 can be used to store computer programs, such as software programs and modules of application software, such as the computer program corresponding to the method of collecting configuration files in the embodiments of the present invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, implements the above-mentioned method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memories, or other non-volatile solid-state memories. In some instances, the memory 104 may further include a memory remotely disposed relative to the processor 102, and these remote memories may be connected to the mobile terminal through a network. Examples of the above-mentioned network include but are not limited to the Internet, enterprise intranet, local area network, mobile communication network, and combinations thereof.
[0026] The transmission device 106 is used to receive or send data via a network. Specific examples of the above-mentioned network may include a wireless network provided by a communication provider of the mobile terminal. In one instance, the transmission device 106 includes a network adapter (abbreviated as NIC), which can be connected to other network devices through a base station and thus communicate with the Internet. In one instance, the transmission device 106 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0027] In this embodiment, a method for collecting configuration files running on the above-mentioned mobile terminal is provided. Figure 2 It is a flowchart of the method for collecting configuration files according to the embodiments of the present invention, applied to a target virtual agent deployed on a target virtual machine, as Figure 2 shown, and this process includes the following steps:
[0028] Step S202, receiving a target collection instruction from a unified scheduling platform, where the target collection instruction is used to indicate collecting a target configuration file of the target virtual machine, and the unified scheduling platform is used to instruct virtual agents deployed on different virtual machines to collect various configuration files on this virtual machine;
[0029] Among them, the unified scheduling platform includes a task scheduler, a communication manager, and a data processor. The task scheduler is responsible for setting the time period of the collection task (the collection task refers to the task of collecting configuration files on each virtual machine), for example, starting a full-scale collection task at 2:00 am every day (the full-scale collection refers to the task of collecting configuration files of all virtual machines connected to the unified scheduling platform, and the number of virtual machines connected to the unified scheduling platform can be determined according to the actual situation), and performing an incremental collection task of specific key configuration files (the specific key configuration files can be preset) every hour, etc.
[0030] The communication manager establishes secure communication channels with each virtual machine, such as network connections based on the SSL / TLS protocol, to ensure the security of data transmission. The data processor then performs preliminary processing on the collected data, such as data cleaning, format conversion, etc., and converts it into a unified JSON format. For example, a text-based configuration file collected from a virtual machine is parsed into JSON data in key-value pair form for subsequent storage and processing.
[0031] Step S204, determine the target path of the target configuration file in the target mapping relationship, where the target mapping relationship records the paths of various configuration files of the target virtual machine;
[0032] A virtual agent is deployed on each virtual machine, and a target virtual agent is deployed on the target virtual machine. The target virtual agent receives the collection instructions from the unified scheduling platform. When the virtual machine receives the collection instructions from the platform, it then executes the corresponding collection steps.
[0033] Specifically, according to the configuration file path or rule specified by the platform, find the corresponding file in the local file system of the virtual machine. For example, if the platform requires collecting the network configuration file, the collection program searches for relevant files in the / etc / network directory, and after matching the collection results with a pre-defined model, sends them to the scheduling platform uniformly.
[0034] The target mapping relationship recorded by the configuration file and the corresponding path is recorded in the database, and the target mapping relationship can be read by calling the corresponding program (such as COLL_APP.conf).
[0035] Step S206, call the target script and collect the target configuration file according to the target path through the target script, where the target virtual agent includes multiple scripts, and each script is used to collect the corresponding configuration file of the target virtual machine.
[0036] Among them, different configuration files correspond to different scripts, and the corresponding configuration file of the script can be collected through the corresponding script. As Figure 3 shown is the schematic diagram of the program structure of the target virtual agent, and the program list of the target virtual agent is shown in Table 1 below.
[0037] Table 1
[0038]
[0039]
[0040] In an exemplary embodiment, the method further includes: updating the target mapping relationship when at least one of the following conditions is met: a configuration item of the target virtual machine changes, or a path of a configuration file of the target virtual machine changes; the target configuration file is a configuration file of a target configuration item of the target virtual machine, and the target mapping relationship records the correspondence between the configuration files of each configuration item of the target virtual machine and the path of the configuration file.
[0041] In an exemplary embodiment, when a configuration item of the target virtual machine changes, updating the target mapping relationship includes: when a first configuration item is newly added to the target virtual machine, obtaining a first configuration file of the first configuration item and a first path of the first configuration file; establishing a correspondence between the first configuration file and the first path and recording it in the target mapping relationship; when a second configuration item of the target virtual machine is deleted, deleting, in the target mapping relationship, the mapping relationship between a second configuration file of the second configuration item and a second path, where the second path is the path of the second configuration file.
[0042] In an exemplary embodiment, when a path of a configuration file of the target virtual machine changes, updating the target mapping relationship includes: when a path of a third configuration file of the target virtual machine changes from a first path to a second path, changing the path of the third configuration file in the target mapping relationship to the second path.
[0043] Configuration items in a virtual machine generally include the following:
[0044] 1. CPU and memory: Configure the number of CPU cores and the memory size of the virtual machine to meet the computing resources required for the virtual machine to run.
[0045] 2. Storage: Configure the hard disk space size of the virtual machine, and you can choose to use storage devices such as solid state drives (SSDs) or hard disk drives (HDDs).
[0046] 3. Network: Configure the network connection method of the virtual machine, including network adapter type, IP address, subnet mask, gateway and other network settings.
[0047] 4. Input and output devices: Configure the input and output devices of the virtual machine, such as keyboards, mice, monitors, etc.
[0048] 5. Security settings: Configure the security settings of the virtual machine, including firewalls, access control lists (ACLs), etc.
[0049] 6. Other configuration items: According to needs, other settings of the virtual machine can also be configured, such as functions like time zone, language, clock synchronization, shared folders, etc.
[0050] Generally, the configuration items of the virtual machine will change. For example, new configuration items are added, configuration items are replaced, configuration items are deleted, or the storage path of the configuration items changes. As Figure 4 shown is a schematic diagram of the configuration item update process, including the following steps:
[0051] Unified scheduling platform release management: The unified scheduling platform issues the update target mapping relationship; Virtual machine management: The virtual machine updates the target mapping relationship; Collection management: The virtual machine executes the collection task.
[0052] The writing and maintenance of scripts require certain technical capabilities, and for different types of virtual machines or configuration files, the scripts may need to be continuously modified. For example, the configuration items or the paths of the configuration items change. In this application, the target mapping relationship can be directly updated without modifying the collection script file. This avoids the problems of high complexity and low efficiency caused by modifying the script file.
[0053] Secondly, the data formats collected by the scripts are often not unified and require additional processing to be effectively analyzed and presented. There is a lack of an automated scheduling mechanism, and usually, manual triggering is required to execute the scripts, making it difficult to achieve regular and continuous configuration collection. In this application, different scripts are set for different types of configuration files, avoiding the problem of inconsistent data formats collected by the scripts.
[0054] In an exemplary embodiment, calling the target script includes: determining the operating system of the target virtual machine as the target operating system; among the multiple scripts included in the target virtual agent, determining the target script corresponding to the target operating system and the target configuration file, where the target script is used to collect the target configuration file.
[0055] Since different operating systems collect configuration files in different formats, for the same type of configuration file, in this application, different operating systems correspond to different scripts for collection. For example, in Table 1 above, the COLL_APP.py program can call the corresponding scripts to collect configuration files according to different operating systems.
[0056] In an exemplary embodiment, after collecting the target configuration file by the target script according to the target path, the method further includes: naming the target configuration file according to a preset format and sending the named target configuration file to the unified scheduling platform.
[0057] The naming rule for the temporary result file generated by the collection script is:
[0058] COLL_{File type}_{Model code}_{Large category}_{Small category}_{Instance}_{Output file serial number}.txt, where:
[0059] File type: KV, TB, JSON, corresponding to Key-Value type, Table type, and JSON type respectively;
[0060] Large category, small category: User-defined classification of collection items. If there is no small category, the value of the small category can be the value of the large category;
[0061] Instance: Represents a collection item instance, such as a database instance, a weblogic instance. If there is no instance, the hostname can be used instead;
[0062] Output file serial number: An integer. A collection script can generate multiple files, which are distinguished by this field. All the above fields are required fields.
[0063] In an exemplary embodiment, the unified scheduling platform further includes: A data display module: It consists of a data repository, a model builder, and a visualization renderer. The data repository is used to store the configuration data collected from virtual machines, and a relational database or a distributed storage system such as MySQL or HBase is adopted. The model builder constructs a data model according to the operation and maintenance requirements and the characteristics of the configuration data. For example, for network configuration data, a network configuration model containing attributes such as IP address, subnet mask, and gateway can be constructed. The visualization renderer displays the data to the operation and maintenance personnel in the form of intuitive charts, tables, or graphical interfaces according to the constructed data model. For example, a bar chart is used to display the comparison of memory configuration sizes of different virtual machines, and a table is used to display the disk partition configuration information of virtual machines, etc.
[0064] In this application, the target mapping relationship records the correspondence between the configuration file and the path. In this way, when the configuration item changes, the mapping relationship can be directly modified without modifying the script, avoiding the problem that modifying the script is relatively complex in the prior art. In addition, different scripts are used for collecting different configuration files, avoiding the problem that the data formats of different types of configuration files are different.
[0065] Optionally, the execution entity of the above steps can be a background processor, or other devices with similar processing capabilities, or a machine integrating at least an image acquisition device and a data processing device. Among them, the image acquisition device can include a graphics acquisition module such as a camera, and the data processing device can include terminals such as a computer and a mobile phone, but is not limited thereto.
[0066] The message queue mechanism can be adopted to replace the direct communication between the task scheduler and the virtual machine agent. The unified scheduling platform sends the collected task information to the message queue in the form of messages, such as RabbitMQ or Kafka. The virtual machine agent fetches and executes the tasks from the message queue, which can improve the decoupling and scalability of the system and cope with the performance pressure when dealing with large-scale virtual machine clusters. In the data display module, an open-source data visualization library, such as Echarts or Highcharts, can be adopted to replace the self-developed visualization renderer, so as to reduce the development cost and cycle, and at the same time provide more diverse display effects by using the rich visualization components of these libraries.
[0067] Compared with the prior art, the present application has significant advantages. First, through the automated unified scheduling platform, the dependence on manual operations is reduced, and the efficiency of configuration collection is greatly improved. For example, the large-scale virtual machine configuration collection work that originally took several weeks can be shortened to several hours in the system of the present application. Second, the unified data format processing and data model display enable the operation and maintenance personnel to more conveniently and accurately understand and analyze the configuration information, avoiding analysis errors caused by chaotic data formats. Third, the secure communication mechanism between the virtual machine agent and the unified scheduling platform reduces the security risks brought by frequent logins and ensures the stability and security of the virtual machine system.
[0068] Through the description of the above embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by means of software plus a necessary general hardware platform. Of course, it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. The computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disc), and includes several instructions for causing a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0069] In this embodiment, a device for collecting configuration files is also provided. This device is used to implement the above embodiments and preferred implementation manners, and those that have been described will not be repeated. As used below, the term "module" can be a combination of software and / or hardware that can achieve a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware is also possible and contemplated.
[0070] Figure 5 is a structural block diagram of the device for collecting configuration files according to an embodiment of the present invention, as Figure 5 shown, the device includes:
[0071] A receiving module 52, configured to receive a target collection instruction from a unified scheduling platform, where the target collection instruction is used to instruct to collect a target configuration file of the target virtual machine, and the unified scheduling platform is used to instruct virtual agents deployed on different virtual machines to collect respective configuration files on the virtual machines;
[0072] A determining module 54, configured to determine a target path of the target configuration file in a target mapping relationship, where the target mapping relationship records paths of respective configuration files of the target virtual machine;
[0073] An invoking module 56, configured to invoke a target script and collect the target configuration file according to the target path through the target script, where the target virtual agent includes a plurality of scripts, and each script is used to collect a corresponding configuration file of the target virtual machine.
[0074] In an exemplary embodiment, the above device is further configured to update the target mapping relationship when at least one of the following conditions is met: a configuration item of the target virtual machine changes, or a path of a configuration file of the target virtual machine changes; the target configuration file is a configuration file of a target configuration item of the target virtual machine, and the target mapping relationship records a correspondence between the configuration file of each configuration item of the target virtual machine and the path of the configuration file.
[0075] In an exemplary embodiment, the above device is further configured to, when a first configuration item is newly added to the target virtual machine, obtain a first configuration file of the first configuration item and a first path of the first configuration file; establish a correspondence between the first configuration file and the first path and record it in the target mapping relationship; when a second configuration item of the target virtual machine is deleted, delete a mapping relationship between a second configuration file of the second configuration item and a second path in the target mapping relationship, where the second path is the path of the second configuration file.
[0076] In an exemplary embodiment, the above device is further configured to, when a path of a third configuration file of the target virtual machine changes from a first path to a second path, change the path of the third configuration file in the target mapping relationship to the second path.
[0077] In an exemplary embodiment, the above device is further configured to determine an operating system of the target virtual machine as a target operating system; and determine, among a plurality of scripts included in the target virtual agent, a target script corresponding to the target operating system and the target configuration file, where the target script is used to collect the target configuration file.
[0078] In an exemplary embodiment, the above-mentioned device is further configured to, after collecting the target configuration file according to the target path by means of the target script, name the target configuration file in a preset format and send the named target configuration file to the unified scheduling platform.
[0079] It should be noted that the above-mentioned modules can be implemented by software or hardware. For the latter, it can be achieved in the following ways, but not limited thereto: the above-mentioned modules are all located in the same processor; or, the above-mentioned modules are separately located in different processors in any combination form.
[0080] An embodiment of the present invention also provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the steps of the method described in any one of the above are implemented.
[0081] In an exemplary embodiment, the above-mentioned computer-readable storage medium may include, but is not limited to: various media such as a USB flash drive, a read-only memory (ROM for short), a random access memory (RAM for short), a mobile hard disk, a magnetic disk, or an optical disc that can store a computer program.
[0082] An embodiment of the present invention also provides an electronic device, including a memory and a processor. A computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0083] In an exemplary embodiment, the above-mentioned electronic device may further include a transmission device and an input / output device, where the transmission device is connected to the above-mentioned processor, and the input / output device is connected to the above-mentioned processor.
[0084] Specific examples in this embodiment may refer to the examples described in the above embodiment and the exemplary embodiments, and will not be repeated here.
[0085] An embodiment of the present invention also provides a computer program product, including a computer program. When the computer program is executed by a processor, the steps of the methods described in various embodiments of the present application are implemented.
[0086] Obviously, those skilled in the art should understand that the above-mentioned modules or steps of the present invention can be implemented by a general-purpose computing device. They can be concentrated on a single computing device or distributed on a network composed of multiple computing devices. They can be implemented by program codes executable by the computing device. Thus, they can be stored in a storage device and executed by the computing device. And in some cases, the steps shown or described can be executed in a different order from here, or they can be separately fabricated into individual integrated circuit modules, or multiple modules or steps among them can be fabricated into a single integrated circuit module for implementation. In this way, the present invention is not limited to any specific combination of hardware and software.
[0087] The above are only the preferred embodiments of the present invention and are not used to limit the present invention. For those skilled in the art, the present invention can have various changes and modifications. Any modifications, equivalent replacements, improvements, etc. made within the principle of the present invention shall be included within the protection scope of the present invention.
Claims
1. A method for collecting configuration files, characterized in that: The target virtual agent deployed on the target virtual machine includes: Receive a target collection instruction from a unified scheduling platform, wherein the target collection instruction is used to instruct the collection of a target configuration file of the target virtual machine, and the unified scheduling platform is used to instruct virtual agents deployed on different virtual machines to collect various configuration files on the virtual machine; Determining a target path of the target configuration file in a target mapping relationship, wherein the target mapping relationship records paths of various configuration files of the target virtual machine; The target script is called and the target configuration file is collected according to the target path through the target script, wherein the target virtual agent includes a plurality of scripts, each of which is used to collect a corresponding configuration file of the target virtual machine.
2. The method according to claim 1, characterized in that The method further comprises: When at least one of the following conditions is met, the target mapping relationship is updated: The configuration item of the target virtual machine changes, and the path of the configuration file of the target virtual machine changes; The target configuration file is a configuration file of a target configuration item of the target virtual machine, and the target mapping relationship records a correspondence between a configuration file of each configuration item of the target virtual machine and a path of the configuration file.
3. The method according to claim 2, characterized in that When the configuration item of the target virtual machine changes, the target mapping relationship is updated, including: When a first configuration item is newly added to the target virtual machine, a first configuration file of the first configuration item and a first path of the first configuration file are obtained; a corresponding relationship between the first configuration file and the first path is established, and recorded in the target mapping relationship; In the case of deleting the second configuration item of the target virtual machine, the mapping relationship between the second configuration file of the second configuration item and the second path is deleted in the target mapping relationship, wherein the second path is the path of the second configuration file.
4. The method according to claim 2, characterized in that: When the path of the configuration file of the target virtual machine changes, updating the target mapping relationship includes: When the path of the third configuration file of the target virtual machine is changed from the first path to the second path, the path of the third configuration file in the target mapping relationship is changed to the second path.
5. The method according to claim 1, characterized in that Calling the target script includes: Determine the operating system of the target virtual machine as the target operating system; Among the multiple scripts included in the target virtual agent, the target script corresponding to the target operating system and the target configuration file is determined, and the target script is used to collect the target configuration file.
6. The method according to claim 1, characterized in that After collecting the target configuration file according to the target path by using the target script, the method further includes: The target configuration file is named according to a preset format, and the named target configuration file is sent to the unified scheduling platform.
7. A device for collecting configuration files, characterized in that: The target virtual agent deployed on the target virtual machine includes: A receiving module, used to receive a target collection instruction from a unified scheduling platform, wherein the target collection instruction is used to instruct the collection of a target configuration file of the target virtual machine, and the unified scheduling platform is used to instruct virtual agents deployed on different virtual machines to collect various configuration files on the virtual machine; A determination module, configured to determine a target path of the target configuration file in a target mapping relationship, wherein the target mapping relationship records the paths of the configuration files of the target virtual machine; A calling module is used to call a target script and collect the target configuration file according to the target path through the target script, wherein the target virtual agent includes multiple scripts, each of which is used to collect the corresponding configuration file of the target virtual machine.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program implements the steps of the method described in any one of claims 1 to 6 when executed by a processor.
9. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to run the computer program to perform the method according to any one of claims 1 to 6.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method described in any one of claims 1 to 6 are implemented.