CN111984603A - Method and system for collecting remote container file information - Google Patents

Method and system for collecting remote container file information Download PDF

Info

Publication number
CN111984603A
CN111984603A CN202010645527.5A CN202010645527A CN111984603A CN 111984603 A CN111984603 A CN 111984603A CN 202010645527 A CN202010645527 A CN 202010645527A CN 111984603 A CN111984603 A CN 111984603A
Authority
CN
China
Prior art keywords
container
acquisition
command
file
file information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202010645527.5A
Other languages
Chinese (zh)
Other versions
CN111984603B (en
Inventor
郭申
周诚
张凌彬
姚泽升
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhuhai Seasun Mobile Game Technology Co ltd
Original Assignee
Zhuhai Seasun Mobile Game Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhuhai Seasun Mobile Game Technology Co ltd filed Critical Zhuhai Seasun Mobile Game Technology Co ltd
Priority to CN202010645527.5A priority Critical patent/CN111984603B/en
Priority claimed from CN202010645527.5A external-priority patent/CN111984603B/en
Publication of CN111984603A publication Critical patent/CN111984603A/en
Application granted granted Critical
Publication of CN111984603B publication Critical patent/CN111984603B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/1734Details of monitoring file system events, e.g. by the use of hooks, filter drivers, logs
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • G06F16/162Delete operations
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/548Queue

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Software Systems (AREA)
  • Human Computer Interaction (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a method and a system for collecting remote container file information, which relate to the technical field of computers and are used for realizing the following steps: scheduling, strategies and acquisition are divided into three parts aiming at various acquisition, and remote acquisition is carried out aiming at different containers based on various acquisition strategies. The invention has the beneficial effects that: the method supports the detection and acquisition of all attributes of the files in the container, encapsulates an attribute detection mode into an upper layer method for a program end to call, and does not operate outside in the bottom container. This is very simple for the user and makes for ease of use. In terms of function realization, the method is simple and efficient, and complex container operation is avoided.

Description

Method and system for collecting remote container file information
Technical Field
The invention relates to the technical field of computers, in particular to a method and a system for collecting remote container file information.
Background
With the widespread application of docker technology, a large number of services are deployed by adopting container technology, and with regard to files in a container, attributes of the files need to be acquired outside the container frequently, and since the container is mostly used for distributed services, the requirement for remotely acquiring the attributes of the files in the container is frequently used. But currently docker by itself does not provide a very straightforward and efficient method to obtain. After several implementations are tried, a tool is finally selected to be perfected, so that the remote control can be realized, and a plurality of attributes of the file in the container can be acquired.
Disclosure of Invention
In order to solve at least one of the technical problems in the prior art, the invention aims to provide a method and a system for collecting file information of a remote container.
The first aspect of the technical scheme adopted by the invention to solve the problems is as follows: a method of collecting remote container file information, comprising the steps of: s10, setting an acquisition strategy; s20, generating a corresponding acquisition rule according to the acquisition strategy and the container to be cleaned; s30, generating a corresponding acquisition command according to the acquisition rule; and S40, the container to be collected receives the collection command and executes collection operation.
Has the advantages that: the method supports the detection and acquisition of all attributes of the files in the container, encapsulates an attribute detection mode into an upper layer method for a program end to call, and does not operate outside in the bottom container. This is very simple for the user and makes for ease of use. In terms of function realization, the method is simple and efficient, and complex container operation is avoided.
According to the first aspect of the invention, the purge command includes a remote machine link, a remote container name, and a file path.
According to the first aspect of the present invention, S10 further includes: s11, traversing the container, and determining the container to be collected; and S12, setting corresponding acquisition strategies one by one according to the containers to be cleaned.
According to the first aspect of the present invention, S40 further includes: and S41, acquiring the file attribute of the corresponding file under the specified path according to the acquisition command.
According to the first aspect of the present invention, the file attributes include a read-write attribute, an execution attribute, and a size attribute.
According to the first aspect of the present invention, S20 further includes: and S21, generating parameters according to the command mode and storing the parameters in the corresponding message queue.
According to the first aspect of the present invention, the command modes include a shell command mode, a crontab command mode, and a custom command mode.
The second aspect of the technical scheme adopted by the invention to solve the problems is as follows: a system for collecting remote container file information, comprising: the setting module is used for setting an acquisition strategy; the rule module is used for generating a corresponding acquisition rule according to the acquisition strategy and the container to be acquired; the command module is used for generating a corresponding acquisition command according to the cleaning rule; and the acquisition module is used for the container to be acquired to receive the acquisition command and execute acquisition operation.
Has the advantages that: the method supports the detection and acquisition of all attributes of the files in the container, encapsulates an attribute detection mode into an upper layer method for a program end to call, and does not operate outside in the bottom container. This is very simple for the user and makes for ease of use. In terms of function realization, the method is simple and efficient, and complex container operation is avoided.
According to a second aspect of the invention, the setting module further comprises: the traversing unit is used for traversing the container and determining the container to be collected; and the strategy generating unit is used for setting corresponding acquisition strategies one by one according to the containers to be acquired.
According to a second aspect of the invention, the command module further comprises: and the asynchronous sending unit is used for realizing asynchronization and concurrency according to the parameters generated by the command mode and the corresponding message queues.
Drawings
FIG. 1 is a schematic flow diagram of a method according to an embodiment of the invention;
FIG. 2 is a schematic diagram of a system architecture according to an embodiment of the present invention;
FIG. 3 is a schematic view of a remotely connected container according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of an operation code command according to an embodiment of the present invention.
Detailed Description
The conception, the specific structure and the technical effects of the present invention will be clearly and completely described in conjunction with the embodiments and the accompanying drawings to fully understand the objects, the schemes and the effects of the present invention.
Interpretation of terms:
code language, used to write logic;
dockerpy: for local or remote operation of the associated docker container;
goodtables-py single table structure rule checking;
prettyytable: the beautiful console outputs a result report;
and (getent) realizing asynchronization and concurrency by utilizing the coroutine mode.
Referring to fig. 1, a schematic flow chart of a method according to an embodiment of the present invention includes the following steps:
s10, setting an acquisition strategy;
s20, generating a corresponding acquisition rule according to the acquisition strategy and the container to be cleaned;
s30, generating a corresponding acquisition command according to the acquisition rule;
and S40, the container to be collected receives the collection command and executes the collection operation.
The purge command includes a remote machine link, a remote container name, and a file path.
S10 further includes:
s11, traversing the container, and determining the container to be collected;
and S12, setting corresponding acquisition strategies one by one according to the containers to be cleaned.
S40 further includes:
and S41, acquiring the file attribute of the corresponding file under the specified path according to the acquisition command.
The file attributes include read-write attributes, execution attributes, and size attributes.
S20 further includes:
and S21, generating parameters according to the command mode and storing the parameters in the corresponding message queue.
The command mode comprises a shell command mode, a crontab command mode and a custom command mode.
Referring to fig. 2, a schematic diagram of a system structure according to an embodiment of the present invention includes:
the setting module is used for setting an acquisition strategy;
the rule module is used for generating a corresponding acquisition rule according to the acquisition strategy and the container to be acquired;
the command module is used for generating a corresponding acquisition command according to the cleaning rule;
and the acquisition module is used for the container to be acquired to receive the acquisition command and execute acquisition operation.
The setting module further includes:
the traversing unit is used for traversing the container and determining the container to be collected;
and the strategy generating unit is used for setting corresponding acquisition strategies one by one according to the containers to be acquired.
The command module further includes:
and the asynchronous sending unit is used for realizing asynchronization and concurrency according to the parameters generated by the command mode and the corresponding message queues.
Referring to FIG. 3, a schematic diagram of a remotely connected container according to an embodiment of the present invention;
obtaining various attributes of the file in the container on the appointed remote machine, wherein the basic attributes are as follows:
whether a file exists
Whether the file exists and is readable
File exists and can be written
Whether a file exists and is executable
File size
Document owner
Whether a file exists and is a directory
Whether or not it is a soft chain
Others
The file has various attributes, and all the attributes are acquired and encapsulated to be directly called by the outside so as to realize remote encapsulation. And simultaneously, concurrent calling is supported, and the requirement of acquiring multiple files at the service side is met.
The client program can detect or touch the designated container of the remote server through concurrent call, and can acquire various attributes of the files in each container according to the parameters, such as whether the designated file in the container A exists or not or whether the designated directory in the container C is in soft link or not. These are useful in real business needs.
The method is complicated in that concurrent operation of obtaining the file attributes in the container and the remote container is performed by a machine. The project acquires various attributes of the file by entering a container to execute a related command, and notifies that a getvent framework is adopted to realize asynchronous concurrent requests.
Simple parameter transmission, detection of specified files in the container, wherein the parameter list comprises machines, containers, directory files and the like
Referring to FIG. 4, an operation code command diagram according to an embodiment of the present invention is shown.
In distributed services, due to business requirements, it is necessary to determine whether a specified file exists in a container. This file records the specified errors in the container service. If the file exists, the container is proved to be abnormally thrown in the operation.
After the designated service is deployed or updated, it needs to be determined whether the service is successfully deployed or whether the designated permission is correct.
The two types of requirements at the top are basically requirements that can be realized by acquiring file attributes in the container service. Namely, whether the file exists or not and whether the file has specific authority or not are judged.
The method comprises the following specific steps:
1. list of parameters:
base_url:tcp://10.11.81.136:2375
container:debug_web_1
path:/var/log/server/exception.log
three parameters required by the tool are displayed, a remote machine is connected with url, the name of a remote container, and the path of a file in the container is detected, and the specific explanation is as follows:
the base _ url is the machine where the docker container is located and the open port through which all containers on the machine can be remotely accessed and operated by the dockerpy client
container name, namely the name of the container needing to detect the file attribute
Path the directory in a container, i.e. the file in the container to be probed, needs a full path
2. The main logic is as follows:
main code logic:
1. python client for initializing docker
2. Traversing the designated docker container and establishing connection
3. Client-side concurrent remote execution of commands within a container
4. Obtaining file attributes in a container
5. Summarizing results, returning data
3. The main packaging method comprises the following steps:
exists: whether a file or directory exists
is _ file: whether a document is available
is _ read _ file: readable or unreadable document
is _ write _ file: writable or not writable files
is _ exec _ file: whether to execute a file
is _ socket _ file: socket file
is _ block _ file: whether device Block File
is _ link: whether or not to be a soft chain
File _ last _ time: last update time of file
File _ size: file size
Other methods
4. The file attribute detection mode comprises the following steps:
the tool detects file attributes by adopting a test command in a shell, and the main functions of the command for the operation of the file attributes are shown in FIG. 4:
it can be seen from fig. 4 that test file operations provide a large number of rich file attribute acquisition or judgment modes. By using the operators, different operations can be executed in the program according to the file types, so that various types of attribute information of the files can be obtained.
It should be recognized that embodiments of the present invention can be realized and implemented by computer hardware, a combination of hardware and software, or by computer instructions stored in a non-transitory computer readable memory. The methods may be implemented in a computer program using standard programming techniques, including a non-transitory computer-readable storage medium configured with the computer program, where the storage medium so configured causes a computer to operate in a specific and predefined manner, according to the methods and figures described in the detailed description. Each program may be implemented in a high level procedural or object oriented programming language to communicate with a computer system. However, the program(s) can be implemented in assembly or machine language, if desired. In any case, the language may be a compiled or interpreted language. Furthermore, the program can be run on a programmed application specific integrated circuit for this purpose.
Further, the operations of processes described herein can be performed in any suitable order unless otherwise indicated herein or otherwise clearly contradicted by context. The processes described herein (or variations and/or combinations thereof) may be performed under the control of one or more computer systems configured with executable instructions, and may be implemented as code (e.g., executable instructions, one or more computer programs, or one or more applications) collectively executed on one or more processors, by hardware, or combinations thereof. The computer program includes a plurality of instructions executable by one or more processors.
Further, the method may be implemented in any type of computing platform operatively connected to a suitable interface, including but not limited to a personal computer, mini computer, mainframe, workstation, networked or distributed computing environment, separate or integrated computer platform, or in communication with a charged particle tool or other imaging device, and the like. Aspects of the invention may be embodied in machine-readable code stored on a non-transitory storage medium or device, whether removable or integrated into a computing platform, such as a hard disk, optically read and/or write storage medium, RAM, ROM, or the like, such that it may be read by a programmable computer, which when read by the storage medium or device, is operative to configure and operate the computer to perform the procedures described herein. Further, the machine-readable code, or portions thereof, may be transmitted over a wired or wireless network. The invention described herein includes these and other different types of non-transitory computer-readable storage media when such media include instructions or programs that implement the steps described above in conjunction with a microprocessor or other data processor. The invention also includes the computer itself when programmed according to the methods and techniques described herein.
A computer program can be applied to input data to perform the functions described herein to transform the input data to generate output data that is stored to non-volatile memory. The output information may also be applied to one or more output devices, such as a display. In a preferred embodiment of the invention, the transformed data represents physical and tangible objects, including particular visual depictions of physical and tangible objects produced on a display.
The above description is only a preferred embodiment of the present invention, and the present invention is not limited to the above embodiment, and any modifications, equivalent substitutions, improvements, etc. within the spirit and principle of the present invention should be included in the protection scope of the present invention as long as the technical effects of the present invention are achieved by the same means. The invention is capable of other modifications and variations in its technical solution and/or its implementation, within the scope of protection of the invention.

Claims (10)

1. A method of collecting remote container file information, comprising the steps of:
s10, setting an acquisition strategy;
s20, generating a corresponding acquisition rule according to the acquisition strategy and the container to be cleaned;
s30, generating a corresponding acquisition command according to the acquisition rule;
and S40, the container to be collected receives the collection command and executes collection operation.
2. The method of claim 1, wherein the purge command comprises a remote machine link, a remote container name, and a file path.
3. The method for collecting remote container file information as claimed in claim 1, wherein said S10 further comprises:
s11, traversing the container, and determining the container to be collected;
and S12, setting corresponding acquisition strategies one by one according to the containers to be cleaned.
4. The method for collecting remote container file information as claimed in claim 1, wherein said S40 further comprises:
and S41, acquiring the file attribute of the corresponding file under the specified path according to the acquisition command.
5. The method of claim 4, wherein the file attributes comprise read-write attributes, execution attributes, and size attributes.
6. The method for collecting remote container file information as claimed in claim 1, wherein said S20 further comprises:
and S21, generating parameters according to the command mode and storing the parameters in the corresponding message queue.
7. The method of claim 6, wherein the command modes include a shell command mode, a crontab command mode, and a custom command mode.
8. A system for collecting remote container file information, comprising:
the setting module is used for setting an acquisition strategy;
the rule module is used for generating a corresponding acquisition rule according to the acquisition strategy and the container to be acquired;
the command module is used for generating a corresponding acquisition command according to the cleaning rule;
and the acquisition module is used for the container to be acquired to receive the acquisition command and execute acquisition operation.
9. The system for collecting remote container file information as in claim 8, wherein said setup module further comprises:
the traversing unit is used for traversing the container and determining the container to be collected;
and the strategy generating unit is used for setting corresponding acquisition strategies one by one according to the containers to be acquired.
10. The system for collecting remote container file information as in claim 8, wherein said command module further comprises:
and the asynchronous sending unit is used for realizing asynchronization and concurrency according to the parameters generated by the command mode and the corresponding message queues.
CN202010645527.5A 2020-07-06 Method and system for collecting remote container file information Active CN111984603B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010645527.5A CN111984603B (en) 2020-07-06 Method and system for collecting remote container file information

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010645527.5A CN111984603B (en) 2020-07-06 Method and system for collecting remote container file information

Publications (2)

Publication Number Publication Date
CN111984603A true CN111984603A (en) 2020-11-24
CN111984603B CN111984603B (en) 2024-05-24

Family

ID=

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180336113A1 (en) * 2017-05-16 2018-11-22 Vmware, Inc. Monitoring applications running on containers
CN109446064A (en) * 2018-09-18 2019-03-08 珠海金山网络游戏科技有限公司 A kind of interactive testing method based on browser
CN109871258A (en) * 2019-01-17 2019-06-11 珠海金山网络游戏科技有限公司 The method and device of modification host configuration based on distributed container
CN109901910A (en) * 2019-01-17 2019-06-18 珠海金山网络游戏科技有限公司 File based on distributed container pulls or method for pushing and device
CN110830443A (en) * 2019-10-14 2020-02-21 成都西山居世游科技有限公司 Method and system for remotely monitoring equipment state

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180336113A1 (en) * 2017-05-16 2018-11-22 Vmware, Inc. Monitoring applications running on containers
CN109446064A (en) * 2018-09-18 2019-03-08 珠海金山网络游戏科技有限公司 A kind of interactive testing method based on browser
CN109871258A (en) * 2019-01-17 2019-06-11 珠海金山网络游戏科技有限公司 The method and device of modification host configuration based on distributed container
CN109901910A (en) * 2019-01-17 2019-06-18 珠海金山网络游戏科技有限公司 File based on distributed container pulls or method for pushing and device
CN110830443A (en) * 2019-10-14 2020-02-21 成都西山居世游科技有限公司 Method and system for remotely monitoring equipment state

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
SILENCEMENT: "python如何判断文件是否存在", pages 1, Retrieved from the Internet <URL:《https://www.php.cn/faq/422356.html》> *

Similar Documents

Publication Publication Date Title
CN109302522B (en) Test method, test device, computer system, and computer medium
US7210123B2 (en) Software evaluation system having source code and function unit identification information in stored administration information
US7676816B2 (en) Systems and methods for integrating services
CN110928774A (en) Automatic test system based on node formula
CN103186444B (en) A kind of performance test methods, test platform and test machine
CN101719097A (en) Debug method and system of automation test script and automation application server
TWI566090B (en) Debugging firmware / software to produce tracking systems and methods, recording media and computer program products
CN110196809B (en) Interface testing method and device
KR20200007133A (en) Method and apparatus for dinamically injecting fault for vehicle ecu software test
CN110321275A (en) Program monitoring method, calculates equipment and storage medium at device
US10846212B2 (en) Evidence gathering system and method
US20130198333A1 (en) Method and device for recording and reproducing web operation
WO2019075994A1 (en) Method, device and system for mock data at ios end, and storage medium
CN110502434A (en) A kind of automatic test approach and device
CN109783284A (en) Information acquisition method, system and server, computer readable storage medium
CN115080398A (en) Automatic interface test system and method
CN110471787A (en) Problem catching method, system, device, electronic equipment and storage medium on line
CN112463588A (en) Automatic test system and method, storage medium and computing equipment
CN110011827A (en) Towards doctor conjuncted multi-user&#39;s big data analysis service system and method
CN111984603A (en) Method and system for collecting remote container file information
CN111984603B (en) Method and system for collecting remote container file information
CN101237350A (en) Global variant exception alteration and positioning method for multi-task environment single board machine
CN116244186A (en) Operating system test management method and device and computing equipment
US9354962B1 (en) Memory dump file collection and analysis using analysis server and cloud knowledge base
CN108984238A (en) Gesture processing method, device and the electronic equipment of application program

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information
CB02 Change of applicant information

Address after: 519000 room 402, Room 401, No. 327, Qiandao Ring Road, Tangjiawan Town, high tech Zone, Zhuhai City, Guangdong Province

Applicant after: Zhuhai Xishanju Digital Technology Co.,Ltd.

Address before: 519000 room 402, Room 401, No. 327, Qiandao Ring Road, Tangjiawan Town, high tech Zone, Zhuhai City, Guangdong Province

Applicant before: ZHUHAI SEASUN MOBILE GAME TECHNOLOGY Co.,Ltd.

GR01 Patent grant