Tomcat instance, Tomcat instance configuration information acquisition method and system, electronic equipment and storage medium
By issuing scripts to the host to filter the Tomcat process and collecting configuration information, the problems of low accuracy and omission in the collection of Tomcat instances in the prior art are solved, and high-accuracy configuration information collection is achieved.
Patent Information
- Application Number
- CN202411888296.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-20
- Publication Date
- 2025-03-28
AI Technical Summary
The existing software scanning tools have low accuracy when collecting Tomcat middleware instances and configuration information, and often have collection omissions.
By issuing scripts to all hosts, filter out the Tomcat process and store its corresponding Tomcat instance in the database. Then, the instance to be collected is determined from all Tomcat instances under the target host, and determine whether the configuration information collection conditions are met. If so, its configuration information is collected and a data model is generated.
Accurate collection of Tomcat instances and their configuration information is achieved, avoiding collection omissions and improving collection accuracy.
Smart Images

Figure CN119718355A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and more specifically, to a Tomcat instance and a configuration information collection method, system, electronic device and storage medium thereof. Background Art
[0002] The information infrastructure of large commercial banks is generally large in scale, with complex system architecture and a wide variety of services. Under the background of independent control, the old information system management system and management methods will change. This is mainly reflected in the automatic operation and maintenance tools, monitoring, asset management libraries, etc. designed and developed for traditional imported software, which need to be transformed to adapt to more and more open source and domestic software.
[0003] However, the process of transforming imported software into localized software and open source software is prone to difficulties in asset sorting and configuration management. Therefore, it is generally necessary to collect the running Tomcat middleware instances (Tomcat instances for short) and their configuration information, and store the collected Tomcat middleware instances and their configuration information in a database corresponding to the values to form a unified asset view, which is convenient for subsequent operation and maintenance management.
[0004] In the prior art, the running Tomcat middleware instances and their configuration information are collected through existing software scanning tools. However, due to the low accuracy of existing software scanning tools, the Tomcat middleware instances and their configuration information cannot be accurately discovered, and the problem of collection omissions often occurs. Summary of the invention
[0005] In view of this, the present application provides a Tomcat instance and its configuration information collection method, system, electronic device and storage medium, so as to accurately collect Tomcat instances and their configuration information and avoid collection omissions.
[0006] The first aspect of the present application provides a Tomcat instance and a method for collecting configuration information thereof, the method comprising:
[0007] Sending corresponding scripts to all hosts, so as to filter out at least one Tomcat process from various processes maintained on the hosts through the scripts;
[0008] For each of the Tomcat processes, the Tomcat instance corresponding to the Tomcat process is stored in a database, and the host to which the Tomcat process corresponding to the Tomcat instance belongs is marked;
[0009] Determine the Tomcat instance to be collected from all Tomcat instances under the target host, and judge whether the Tomcat instance to be collected meets the configuration information collection condition; wherein the target host is a marked host;
[0010] If the Tomcat instance to be collected meets the configuration information collection condition, the structure of the Tomcat instance to be collected is initialized to obtain the data structure of the Tomcat instance to be collected;
[0011] Collecting the configuration information of the Tomcat instance to be collected from the target host to which the Tomcat instance to be collected belongs, and generating a Tomcat configuration information data model according to the configuration information and data structure of the Tomcat instance to be collected;
[0012] The Tomcat configuration information data model of the Tomcat instance to be collected is stored in the database, and the step of determining the Tomcat instance to be collected from all Tomcat instances under the target host is returned to execute until the Tomcat instance to be collected does not exist in the Tomcat instances under the target host.
[0013] Optionally, sending corresponding scripts to all hosts to filter out at least one Tomcat process from various processes on the hosts through the scripts includes:
[0014] For each host, send a corresponding script to the host;
[0015] Acquire a handle table maintained on the host through the script; wherein the handle table includes a plurality of handles maintained on the host;
[0016] Querying the handles having Tomcat features from the respective handles through the script, and determining the handles having the Tomcat features as Tomcat handles;
[0017] Obtaining a process table maintained on the host through the script, and identifying the Tomcat process to which the Tomcat handle belongs from each process in the process table;
[0018] The script is used to filter out the Tomcat process from each of the other processes according to each of the files under each of the other processes; wherein the other processes are processes other than the Tomcat process to which the Tomcat handle belongs and the preset process.
[0019] Optionally, filtering out the Tomcat process from each of the other processes by the script according to each of the files under each of the other processes includes:
[0020] For each other process, obtain all files under the other process, and unpack and parse each file under the other process in turn to determine whether there is a Tomcat core file in each file under the other process;
[0021] If there is a Tomcat core file in each file under the other process, the other process is determined as a Tomcat process.
[0022] Optionally, the collecting the configuration information of the Tomcat instance to be collected from the target host to which the Tomcat instance to be collected belongs includes:
[0023] According to the Tomcat handle of the Tomcat process belonging to the Tomcat instance to be collected, obtaining the installation directory of the Tomcat instance to be collected from the target host to which the Tomcat instance to be collected belongs;
[0024] According to the preset startup command line, obtain the location and version of the corresponding Java main program from the target host to which the Tomcat instance to be collected belongs;
[0025] According to the preset command line, obtain the corresponding jmx port from the target host to which the Tomcat instance to be collected belongs;
[0026] According to a preset application service port collection method, corresponding application service port information is collected from a target host to which the Tomcat instance to be collected belongs;
[0027] Obtain the process startup user and the complete startup command line from the target host to which the Tomcat instance to be collected belongs;
[0028] Obtaining the version number of the Tomcat instance to be collected from the target host to which the Tomcat instance to be collected belongs;
[0029] The configuration information of the Tomcat instance to be collected is generated according to the basic information of the Tomcat instance to be collected, the installation directory, the location and version of the java main program, the jmx port, the application service port information, the process startup user and the complete startup command line and the version number of the Tomcat instance to be collected.
[0030] Optionally, determining the Tomcat instance to be collected from all Tomcat instances under the target host, and judging whether the Tomcat instance to be collected meets the configuration information collection condition includes:
[0031] Determine the Tomcat instance to be collected from all Tomcat instances under the target host;
[0032] Determine whether the Tomcat process corresponding to the Tomcat instance to be collected is a specific application process started by Tomcat;
[0033] If the Tomcat process corresponding to the Tomcat instance to be collected is a specific application process started by Tomcat, it is determined that the Tomcat instance to be collected does not meet the configuration information collection condition;
[0034] If the Tomcat process corresponding to the Tomcat instance to be collected is not a specific application process started by Tomcat, it is determined that the Tomcat instance to be collected meets the configuration information collection condition.
[0035] A second aspect of the present application provides a Tomcat instance and a method for collecting configuration information thereof, the method comprising:
[0036] A screening unit, used to send corresponding scripts to all hosts, so as to screen out at least one Tomcat process from various processes maintained on the hosts through the script;
[0037] A first storage unit is used to store, for each Tomcat process, a Tomcat instance corresponding to the Tomcat process in a database, and mark a host to which the Tomcat process corresponding to the Tomcat instance belongs;
[0038] The first judgment unit is used to determine the Tomcat instance to be collected from all Tomcat instances under the target host, and judge whether the Tomcat instance to be collected meets the configuration information collection condition; wherein the target host is a marked host;
[0039] A structure initialization unit, used for initializing the structure of the Tomcat instance to be collected if the Tomcat instance to be collected meets the configuration information collection condition, so as to obtain the data structure of the Tomcat instance to be collected;
[0040] A configuration information collection unit, used to collect the configuration information of the Tomcat instance to be collected from the target host to which the Tomcat instance to be collected belongs, and generate a Tomcat configuration information data model according to the configuration information and data structure of the Tomcat instance to be collected;
[0041] The second storage unit is used to store the Tomcat configuration information data model of the Tomcat instance to be collected in the database, and return to execute the first judgment unit until the Tomcat instance to be collected does not exist in each Tomcat instance under the target host.
[0042] Optionally, the screening unit comprises:
[0043] A script sending unit, used for sending a corresponding script to each host;
[0044] A handle table acquisition unit, used to acquire a handle table maintained on the host through the script; wherein the handle table includes a plurality of handles maintained on the host;
[0045] A first determining unit, configured to query the handles having Tomcat features from the respective handles through the script, and determine the handles having the Tomcat features as Tomcat handles;
[0046] an identification unit, configured to obtain a process table maintained on the host through the script, and identify the Tomcat process to which the Tomcat handle belongs from each process in the process table;
[0047] The screening subunit is used to screen out the Tomcat process from each of the other processes according to each file under each of the other processes through the script; wherein the other processes are processes other than the Tomcat process to which the Tomcat handle belongs and the preset process.
[0048] Optionally, the screening subunit includes:
[0049] The unpacking and parsing unit is used to obtain all files under each other process, and unpack and parse each file under the other process in turn to determine whether there is a Tomcat core file in each file under the other process;
[0050] The second determining unit is used to determine the other process as a Tomcat process if there is a Tomcat core file in each file under the other process.
[0051] The third aspect of the present application provides an electronic device, comprising: a processor and a memory, wherein the processor and the memory are connected via a communication bus; wherein the processor is used to call and execute a program stored in the memory; and the memory is used to store a program, wherein the program is used to implement a Tomcat instance and a configuration information collection method thereof as provided in the first aspect of the present application.
[0052] The fourth aspect of the present application provides a storage medium, in which computer executable instructions are stored, and the computer executable instructions are used to execute a Tomcat instance and a configuration information collection method thereof provided in the first aspect of the present application.
[0053] The present application provides a Tomcat instance and a configuration information collection method, system, electronic device and storage medium thereof. By issuing corresponding scripts to all hosts, the Tomcat process is accurately screened out from various processes maintained on the host through the script, thereby accurately identifying the corresponding Tomcat instance, and this identification method can also be widely applied to various scenarios; after identifying the Tomcat instance, in order to avoid omissions in configuration information collection and optimize corresponding business applications, the host with the Tomcat instance can be marked as a target host; in the process of collecting configuration information, the Tomcat instance to be collected can be determined from all Tomcat instances under the target host, and when the Tomcat instance to be collected meets the configuration information collection conditions, the configuration information of the Tomcat instance to be collected is collected from the target host, thereby improving the accuracy of the configuration information collection of the Tomcat instance. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0055] Figure 1 A schematic diagram of a Tomcat instance and a method for collecting configuration information thereof provided in an embodiment of the present application;
[0056] Figure 2 An example diagram of a Tomcat process screening method provided in an embodiment of the present application;
[0057] Figure 3 An example diagram of a method for collecting and storing configuration information of a Tomcat instance to be collected provided in an embodiment of the present application;
[0058] Figure 4 An example diagram of a Tomcat configuration information data model provided in an embodiment of the present application;
[0059] Figure 5 A schematic diagram of a Tomcat instance and its configuration information collection system provided in an embodiment of the present application
[0060] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0061] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0062] In this application, relational terms such as first and second, etc. are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.
[0063] In order to better understand this application, the technical names involved in this application are explained below:
[0064] Tomcat middleware: Tomcat server is a free and open source lightweight Web application server. It can process HTML page related requests, but its main function is Servlet and JSP container, which is used for the dynamic request processing in Web services.
[0065] Instance: A process or runtime that measures the entity of a service program.
[0066] Configuration information: A collection of key parameters or configurations that affect the process or runtime, used to define and describe the program's running status and behavior.
[0067] See also Figure 1, shows a flow chart of a data collection method provided in an embodiment of the present application, the data collection method specifically comprises the following steps:
[0068] S101: Send corresponding scripts to all hosts, so as to filter out at least one Tomcat process from various processes maintained on the hosts through the scripts.
[0069] In the process of performing step S101, a script for analyzing the characteristics of the Tomcat process can be pre-set to find the Tomcat process using the script; specifically, the corresponding script is sent to all hosts to call the script to determine the Tomcat handle from the various handles maintained on each host, and the Tomcat handle is used to filter out at least one Tomcat process from the various processes maintained on the host, and finally at least one Tomcat process can be further filtered out from various other processes. Among them, the other processes are processes other than the Tomcat process and the preset process filtered out using the Tomcat handle among the various processes maintained on the host, that is, processes other than the Tomcat process and the preset process to which the Tomcat handle belongs.
[0070] Optionally, the process of sending corresponding scripts to all hosts and filtering out at least one Tomcat process from various processes on the host through the script can be specifically as follows: for each host, sending the corresponding script to the host; obtaining the handle table maintained on the host through the script; wherein the handle table includes multiple handles maintained on the host; querying the handles with Tomcat characteristics from each handle through the script, and determining the handles with Tomcat characteristics as Tomcat handles; obtaining the process table maintained on the host through the script, and identifying the Tomcat process to which the Tomcat handle belongs from each process in the process table; filtering out the Tomcat process with Tomcat core files from various other processes through the script; wherein other processes are processes other than the Tomcat process to which the Tomcat handle belongs and the preset process in each process.
[0071] In the embodiment of the present application, for independently deployed Tomcat or Spring Boot applications packaged in WAR (Web Application Archive), a Tomcat handle containing catalina.jar or tomcat-embed-core-xxx.jar can be found during runtime. The Tomcat handle contains the core code of the Tomcat container operation, that is, the core code such as catalina.jar or tomcat-embed-core-xxx.jar that must exist when the Tomcat container is started. Therefore, the core code such as catalina.jar or tomcat-embed-core-xxx.jar can be set as a Tomcat feature, so the Tomcat handle can be identified from each handle maintained on the host through the Tomcat feature, and the Tomcat process to which the Tomcat handle belongs can be identified from each process maintained on the host, so that the identified Tomcat process can be used to check the non-encapsulated Tomcat instance later, and the process information such as the process number of each Tomcat process can also be recorded. Among them, the tomcat-embed-core-xxx.jar here represents the core code of the Tomcat container operation.
[0072] It should be noted that handles refer to objects managed by the operating system deployed on the host. In Linux, all objects are files, so they can also be called open files. The running of a process will include various objects, which constitute the necessary data set when the process is running. In the Linux operating system, all handles can be listed through the lsof command, that is, all handles maintained on the host can be obtained by calling the corresponding script according to the lsof command.
[0073] It should also be noted that the preset process can be a special java process in the form of jar. The applicant has found through research that, since the application service encapsulated in the form of jar is also applicable to the Tomcat container, the handle seen in the operating system is usually a single file, not like the Tomcat process to which the Tomcat handle belongs, there will be multiple files, and these files often have no obvious identification. Therefore, each file under each process can only be unpacked and parsed to find the Tomcat core file tomcat-embed-core-xxx.jar, and the process with the Tomcat core file is determined as the Tomcat process.
[0074] Furthermore, in an embodiment of the present application, after identifying at least one Tomcat process to which the Tomcat handle belongs from each process, the determined Tomcat process and the preset process can be excluded from each process to obtain multiple other processes; for each other process, all files under the other process are obtained, and each file under the other process is unpacked and parsed in turn to determine whether there is a Tomcat core file in each file under the other process; if there is a Tomcat core file in each file under the other process, the other process is determined to be a Tomcat process; otherwise, it is determined that the other process is not a Tomcat process.
[0075] In actual application, the preset process is a special Java process in the form of jar, and the core code such as catalina.jar or tomcat-embed-core-xxx.jar is set as the Tonmcat feature, and the second Tomcat feature is tomcat-embed-core-xxx.jar; the tomcat-embed-core-xxx.jar file is set as the Tomcat core file; see Figure 2 , by sending a script to the host, calling the script to obtain all handles maintained on the host according to the lsof command, and saving all handles to a temporary file; judging whether there is a Tomcat handle containing Tomcat features in each handle; if so, identifying the Tomcat process to which the Tomcat handle belongs from each process maintained on the host, and recording the process information of the Tomcat process; excluding the determined Tomcat process and a special java process in the form of a jar from each process, and obtaining multiple other processes, if not, determining the processes other than the special java process in the form of a jar as other processes; screening out all jar files under other processes, and unpacking and parsing each jar file under the other process in turn, to judge whether there is a Tmocat core file under the other process, if so, it can be determined that the other process has started a Tomcat container, that is, it can be determined that the other process is a Tomcat process, and the process information of the Tomcat process is recorded; otherwise, it is determined that the other process is not a Tomcat process.
[0076] It should be noted that since Tomact instances exist in various forms and are not easy to start, the Tomcat process is identified through the above method, and then the corresponding Tomcat instance is determined based on the identified Tomcat process. This is not only applicable to various scenarios, but also can accurately identify the Tomcat process, thereby accurately obtaining the corresponding Tomcat instance.
[0077] S102: For each Tomcat process, the Tomcat instance corresponding to the Tomcat process is stored in a database, and the host to which the Tomcat process corresponding to the Tomcat instance belongs is marked.
[0078] In the process of specifically executing step S102, for each host, after scanning at least one Tomcat process from each process maintained on the host, for each Tomcat process, a Tomcat instance corresponding to the Tomcat process can be further obtained; the Tomcat instance is stored in the database, and at the same time, the host to which the Tomcat process belongs can be marked, that is, the host to which the Tomcat process belongs is marked as the target host.
[0079] S103: Determine the Tomcat instance to be collected from all Tomcat instances under the target host, and determine whether the Tomcat instance to be collected meets the configuration information collection condition. If the Tomcat instance to be collected meets the configuration information collection condition, execute step S104.
[0080] In the embodiment of the present application, in order to optimize the business banking of the bank, the specific application process started by Tomcat can be excluded, that is, after scanning out the various Tomcat instances marked under each host, and marking the host to which the Tomcat process corresponding to the Tomcat instance belongs as the target host, the various Tomcat instances under each target host with the mark can be further scanned, and the Tomcat instances whose Tomcat processes are specific applications started by Tomcat are excluded from the scanned Tomcat instances, that is, the configuration information is not collected for the Tomcat instances whose Tomcat processes are specific applications started by Tomcat. It can be seen that the corresponding configuration information collection conditions are set, and the configuration information is collected for the Tomcat instance when the Tomcat instance meets the configuration information collection conditions, otherwise, the configuration information is not collected for the Tomcat instance. Among them, the configuration information collection conditions indicate that the Tomcat process corresponding to the Tomcat instance is not a Tomcat instance of a specific application started by Tomcat.
[0081] Optionally, the process of determining the Tomcat instance to be collected from all Tomcat instances under the target host and judging whether the Tomcat instance to be collected meets the configuration information collection condition can be specifically as follows: determining the Tomcat instance to be collected from all Tomcat instances under the target host; judging whether the Tomcat process corresponding to the Tomcat instance to be collected is a specific application process started by Tomcat; if the Tomcat process corresponding to the Tomcat instance to be collected is a specific application process started by Tomcat, it is determined that the Tomcat instance to be collected does not meet the configuration information collection condition, and the Tomcat instance to be collected can be excluded from each Tomcat instance of the target host, and the Tomcat instance to be collected can be re-determined from all Tomcat instances under the host until the location of the Tomcat instance to be collected does not exist in each Tomcat instance under the target host; if the Tomcat process corresponding to the Tomcat instance to be collected is not a specific application process started by Tomcat, it is determined that the Tomcat instance to be collected meets the configuration information collection condition.
[0082] S104: Initialize the structure of the Tomcat instance to be collected to obtain the data structure of the Tomcat instance to be collected.
[0083] In the process of executing step S104, since the database has certain data structure storage requirements for the stored data, when it is determined that the Tomcat instance to be collected meets the configuration information collection, the structure of the Tocmat instance to be collected can be initialized according to the data structure pre-set in the database to obtain the data structure of the Tomcat instance to be collected, so that after the corresponding configuration information is collected, the collected configuration information can be filled into the data structure of the Tomcat instance to be collected to obtain a Tomcat configuration information data model that meets the storage requirements of the database.
[0084] S105: Collecting configuration information of the Tomcat instance to be collected from the target host to which the Tomcat instance to be collected belongs, and generating a Tomcat configuration information data model according to the configuration information and data structure of the Tomcat instance to be collected.
[0085] In the process of specifically executing step S105, a pre-configured automated tool system can be used to obtain the installation directory of the Tomcat instance to be collected, the location and version of the java main program, the application service port information, the process startup user and the complete startup command line, and the version number of the Tomcat instance to be collected from the target host to which the Tomcat instance to be collected belongs. Finally, according to the basic information, installation directory, the location and version of the java main program, the jmx port, the application service port information, the process startup user and the complete startup command line, and the version number of the Tomcat instance to be collected, the configuration information of the Tomcat instance to be collected is generated, and the collected configuration information of the Tomcat instance is filled into the corresponding data structure to obtain the Tomcat configuration information data model of the Tomcat instance to be collected.
[0086] It should be noted that the corresponding configuration information is collected through a pre-configured automated tool system without the need to install an additional client agent on the target host. Not only does the collection process have a low resource usage rate, but it is also non-intrusive and has no impact on other application software and programs on the target host, thereby improving the accuracy and speed of configuration information collection.
[0087] Optionally, the process of collecting the configuration information of the Tomcat instance to be collected from the target host to which the Tomcat instance to be collected belongs may specifically be as follows: according to the Tomcat handle of the Tomcat process belonging to the Tomcat instance to be collected, obtaining the installation directory of the Tomcat instance to be collected from the target host to which the Tomcat instance to be collected belongs; according to a preset startup command line, obtaining the location and version of the corresponding java main program from the target host to which the Tomcat instance to be collected belongs; according to a preset command line, obtaining the corresponding jmx port from the target host to which the Tomcat instance to be collected belongs; according to a preset command line, obtaining the corresponding jmx port from the target host to which the Tomcat instance to be collected belongs; according to a preset command line, obtaining the corresponding jmx port from the target host to which the Tomcat instance to be collected belongs. According to the application service port collection method set, the corresponding application service port information is collected from the target host to which the Tomcat instance to be collected belongs; the process startup user and the complete startup command line are obtained from the target host to which the Tomcat instance to be collected belongs; the version number of the Tomcat instance to be collected is obtained from the target host to which the Tomcat instance to be collected belongs; the configuration information of the Tomcat instance to be collected is generated according to the basic information of the Tomcat instance to be collected, the installation directory, the location and version of the java main program, the jmx port, the application service port information, the process startup user and the complete startup command line and the version number of the Tomcat instance to be collected.
[0088] In an embodiment of the present application, the pre-set application service port collection method may include a pre-set command line, application log, the number of sockets established in the monitoring, etc., which is not limited in the embodiment of the present application.
[0089] It should also be noted that, due to the different configuration methods of service ports in various situations, it is impossible to accurately find each service port, resulting in collection omissions; therefore, this application sets a unified application service port collection method for each service port, so as to accurately find each application service port from the host according to the application service port collection method. Among them, the application service port information includes each application service port, and each application service port includes the server.port keyword, the port keyword in the Connector, the -nio- keyword, the active port with the maximum number of connections, etc., which are not limited in this embodiment of the application.
[0090] Specifically, you can find the server.port keyword by parsing the corresponding command line, that is, find the server.port keyword from the process startup command line; find the port keyword in the Connector from the configuration file . / conf / server.xml; find the -nio- keyword by scanning the log, that is, find the -nio- keyword from the server startup log or operation log; scan the Socket connection to determine the active port with the largest number of connections, that is, find the active port with the largest number of connections through the number of connections of the process listening port (the number of connections of the listened ports can be merged and sorted, and the port with the most connections can be confirmed as the possible listening port).
[0091] In some embodiments, since the collected application service ports may be empty or inconsistent during the application service port collection process, it can be determined whether each collected application service port meets the port election rules. If so, each application service port can be recorded; if not, each application service port can be set to empty.
[0092] In some embodiments, it can be determined whether the Tomcat instance to be collected is an independent instance or an embedded instance based on the condition that the Tomcat handle of the Tomcat process of the Tomcat instance to be collected contains the tomcat keyword but does not contain tomcat-embed-core; if it is an independent instance, the Tomcat instance to be collected is marked and the corresponding special information acquisition method is executed to obtain the version number of the Tomcat instance to be collected.
[0093] In actual application, see Figure 3, determine the Tomcat instance to be collected from all Tomcat instances under the target host; initialize the structure of the Tocmat instance to be collected according to the data structure pre-set in the database to obtain the data structure of the Tomcat instance to be collected; determine whether the Tomcat process corresponding to the Tomcat instance to be collected is a specific application process started by Tomcat; if so, the Tomcat instance to be collected can be excluded, and a new Tomcat to be collected can be re-determined from the various Tomcat instances under the target host; if not, the Tomcat handle of the Tomcat process of the Tomcat instance to be collected can be used to obtain the installation directory (Tomcat installation path and software version) of the Tomcat instance to be collected from the target host; according to the pre-set startup command line, obtain the corresponding java main program from the target host. The location and version (Java installation path and software version) of the target host are obtained through the preset command line. The corresponding jmx port is obtained from the target host. According to the preset application service port collection method, each application service port is collected from the target host, and it is determined whether each collected application service port meets the port election rule. If it meets the rule, each application service port (Tomcat service port) is recorded. If it does not meet the rule, each application service port is set to empty. The process startup user and the complete startup command line (Tomcat startup user and Tomcat startup command line) are obtained from the target host. The version number of the Tomcat instance to be collected (whether it is an embedded instance) is obtained from the target host to complete the collection of the configuration information of the Tomcat instance to be collected and obtain the corresponding configuration information. According to the configuration information and data structure of the Tomcat instance to be collected, a Tomcat configuration information data model is generated, such as Figure 4 As shown; the Tomcat configuration information data model of the Tomcat instance to be collected is stored in the database; it is determined whether there are any Tomcat instances to be collected among all the Tomcat instances under the target host; if so, it is determined again whether there are any Tomcat instances to be collected among all the Tomcat instances under the target host; otherwise, the corresponding configuration information collection process is terminated.
[0094] It should be noted that from Figure 4 It can be seen that the basic information of the Tomcat instance to be collected may include: instance retrieval name, host name of the target host, IP address of the target host, whether it is valid, etc.
[0095] It should also be noted that, as can be seen from the above content, this application uses a combination of multiple configuration information collection methods. When multiple different parameter values (multiple application service ports) are collected, port election rules are used for automatic judgment, which can ensure a high information recognition accuracy rate in extreme cases.
[0096] S106: storing the Tomcat configuration information data model of the Tomcat instance to be collected in the database.
[0097] In the process of specifically executing step S106, after obtaining the Tomcat configuration information data model of the Tomcat instance to be collected, the Tomcat configuration information data model of the Tomcat instance to be collected can be directly stored in the database, and at the same time, the Tomcat instance to be collected can be excluded from the various Tomcat instances in the corresponding host, that is, the Tomcat instance to be collected is marked as collected; determine whether there are Tomcat instances to be collected in the various Tomcat instances of the target host; if so, return to execute to determine the Tomcat instance to be collected from all Tomcat instances under the target host, that is, return to execute step S103 until there are no Tomcat instances to be collected in the various Tomcat instances under the target host.
[0098] The present application provides a Tomcat instance and a configuration information collection method thereof. The corresponding script is sent to all hosts, so that the Tomcat process is accurately screened out from various processes maintained on the host through the script, thereby accurately identifying the corresponding Tomcat instance, and this identification method can also be widely applied to various scenarios; after identifying the Tomcat instance, in order to avoid omissions in configuration information collection and optimize corresponding business applications, the host where the Tomcat instance exists can be marked as a target host; in the process of collecting configuration information, the Tomcat instance to be collected can be determined from all Tomcat instances under the target host, and when the Tomcat instance to be collected meets the configuration information collection conditions, the configuration information of the Tomcat instance to be collected is collected from the target host, thereby improving the accuracy of the configuration information collection of the Tomcat instance.
[0099] Based on the Tomcat instance and configuration information collection method provided in the above embodiment of the present application, correspondingly, the embodiment of the present application also provides a Tomcat instance and configuration information collection system, such as Figure 5 As shown, the Tomcat instance and its configuration information collection system include:
[0100] A screening unit 51 is used to send corresponding scripts to all hosts, so as to screen out at least one Tomcat process from various processes maintained on the host through the script;
[0101] The first storage unit 52 is used to store the Tomcat instance corresponding to each Tomcat process in the database, and mark the host to which the Tomcat process corresponding to the Tomcat instance belongs;
[0102] The first judgment unit 53 is used to determine the Tomcat instance to be collected from all Tomcat instances under the target host, and judge whether the Tomcat instance to be collected meets the configuration information collection condition; wherein the target host is a host with a mark;
[0103] A structure initialization unit 54 is used to initialize the structure of the Tomcat instance to be collected if the Tomcat instance to be collected meets the configuration information collection condition, so as to obtain the data structure of the Tomcat instance to be collected;
[0104] The configuration information collection unit 55 is used to collect the configuration information of the Tomcat instance to be collected from the target host to which the Tomcat instance to be collected belongs, and generate a Tomcat configuration information data model according to the configuration information and data structure of the Tomcat instance to be collected;
[0105] The second storage unit 56 is used to store the Tomcat configuration information data model of the Tomcat instance to be collected in the database, and return to execute the first judgment unit until the Tomcat instance to be collected does not exist in each Tomcat instance under the target host.
[0106] The specific principles and execution processes of each unit in the Tomcat instance and its configuration information collection system disclosed in the above-mentioned embodiment of the present application are the same as the Tomcat instance and its configuration information collection method disclosed in the above-mentioned embodiment of the present application. Please refer to the corresponding parts of the Tomcat instance and its configuration information collection method disclosed in the above-mentioned embodiment of the present application, and no further details will be given here.
[0107] The present application provides a Tomcat instance and a configuration information collection system thereof. By issuing a corresponding script to all hosts, the Tomcat process is accurately screened out from various processes maintained on the host through the script, thereby accurately identifying the corresponding Tomcat instance, and this identification method can also be widely applied to various scenarios; after identifying the Tomcat instance, in order to avoid omissions in configuration information collection and optimize corresponding business applications, the host where the Tomcat instance exists can be marked as a target host; in the process of collecting configuration information, the Tomcat instance to be collected can be determined from all Tomcat instances under the target host, and when the Tomcat instance to be collected meets the configuration information collection conditions, the configuration information of the Tomcat instance to be collected is collected from the target host, thereby improving the accuracy of the configuration information collection of the Tomcat instance.
[0108] Optional, screening unit, including:
[0109] A script delivery unit is used to deliver a corresponding script to each host;
[0110] A handle table acquisition unit, used to acquire a handle table maintained on the host through a script; wherein the handle table includes a plurality of handles maintained on the host;
[0111] A first determining unit, configured to query a handle having a Tomcat feature from each handle through a script, and determine the handle having the Tomcat feature as a Tomcat handle;
[0112] An identification unit, used for obtaining a process table maintained on a host through a script, and identifying a Tomcat process to which a Tomcat handle belongs from various processes in the process table;
[0113] The screening subunit is used to screen out the Tomcat process from various other processes according to various files under various other processes through a script; wherein the other processes are processes other than the Tomcat process to which the Tomcat handle belongs and the preset process.
[0114] Optionally, screening subunits, including:
[0115] The unpacking and parsing unit is used to obtain all files under each other process, and unpack and parse each file under the other process in turn to determine whether there is a Tomcat core file in each file under the other process;
[0116] The second determining unit is used to determine the other process as a Tomcat process if the Tomcat core file exists in each file under the other process.
[0117] Optionally, an information collection unit is configured, including:
[0118] An installation directory acquisition unit, used to acquire the installation directory of the Tomcat instance to be collected from the target host to which the Tomcat instance to be collected belongs according to the Tomcat handle of the Tomcat process belonging to the Tomcat instance to be collected;
[0119] A location and version acquisition unit, used to acquire the location and version of the corresponding Java main program from the target host to which the Tomcat instance to be collected belongs according to a preset startup command line;
[0120] The port acquisition unit is used to acquire the corresponding jmx port from the target host to which the Tomcat instance to be collected belongs according to a preset command line;
[0121] The application service port collection unit is used to collect corresponding application service port information from the target host to which the Tomcat instance to be collected belongs according to a preset application service port collection method;
[0122] A process startup user and complete startup command line acquisition unit is used to acquire the process startup user and complete startup command line from the target host to which the Tomcat instance to be collected belongs;
[0123] A Tomcat instance version number acquisition unit, used to acquire the version number of the Tomcat instance to be collected from a target host to which the Tomcat instance to be collected belongs;
[0124] The configuration information generation unit is used to generate the configuration information of the Tomcat instance to be collected based on the basic information of the Tomcat instance to be collected, the installation directory, the location and version of the java main program, the jmx port, the application service port information, the process startup user and the complete startup command line and the version number of the Tomcat instance to be collected.
[0125] Optionally, the first judging unit includes:
[0126] The third determining unit is used to determine the Tomcat instance to be collected from all Tomcat instances under the target host;
[0127] The second judgment unit is used to judge whether the Tomcat process corresponding to the Tomcat instance to be collected is a specific application process started by Tomcat;
[0128] A third determining unit is used to determine that the Tomcat instance to be collected does not meet the configuration information collection condition if the Tomcat process corresponding to the Tomcat instance to be collected is a specific application process started by Tomcat;
[0129] The fourth determining unit is used to determine whether the Tomcat instance to be collected meets the configuration information collection condition if the Tomcat process corresponding to the Tomcat instance to be collected is not a specific application process started by Tomcat.
[0130] The present application also provides a storage medium, which stores computer-executable instructions. When the computer-readable instructions are loaded and executed by a processor, any of the above-mentioned Tomcat instances and configuration information collection method embodiments are implemented.
[0131] The present application also provides an electronic device, such as Figure 6 As shown, the electronic device includes a processor 601 and a memory 602; the memory stores a program; the processor calls the program in the memory to execute any one of the above-mentioned Tomcat instances and configuration information collection method embodiments.
[0132] The processor in the present application may be a CPU of a terminal, or an MCU integrated in the terminal, or a combination of a CPU and an MCU. Moreover, the processor includes a kernel, which retrieves a corresponding program from a memory, and one or more kernels may be provided.
[0133] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0134] For the aforementioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the order of the actions described, because according to the present application, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
[0135] It should be noted that each embodiment in this specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the embodiments can be referred to each other. For the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0136] The steps in the methods of the embodiments of the present application can be adjusted in order, combined, and deleted according to actual needs.
[0137] The modules and sub-modules in the devices and terminals in the embodiments of the present application can be combined, divided and deleted according to actual needs.
[0138] In the several embodiments provided in the present application, it should be understood that the disclosed terminals, devices and methods can be implemented in other ways. For example, the terminal embodiments described above are only schematic, for example, the division of modules or submodules is only a logical function division, and there may be other division methods in actual implementation, for example, multiple submodules or modules can be combined or integrated into another module, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or modules, which can be electrical, mechanical or other forms.
[0139] The modules or submodules described as separate components may or may not be physically separated, and the components of the modules or submodules may or may not be physical modules or submodules, that is, they may be located in one place, or they may be distributed on multiple network modules or submodules. Some or all of the modules or submodules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0140] In addition, each functional module or submodule in each embodiment of the present application may be integrated into one processing module, or each module or submodule may exist physically separately, or two or more modules or submodules may be integrated into one module. The above-mentioned integrated modules or submodules may be implemented in the form of hardware or in the form of software functional modules or submodules.
[0141] Finally, it should be noted that, in this application, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0142] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined in the present application may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown in the present application, but will conform to the widest scope consistent with the principles and novel features disclosed in the present application.
[0143] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A Tomcat instance and a method for collecting configuration information thereof, characterized in that: The method comprises: Sending corresponding scripts to all hosts, so as to filter out at least one Tomcat process from various processes maintained on the hosts through the scripts; For each of the Tomcat processes, the Tomcat instance corresponding to the Tomcat process is stored in a database, and the host to which the Tomcat process corresponding to the Tomcat instance belongs is marked; Determine the Tomcat instance to be collected from all Tomcat instances under the target host, and judge whether the Tomcat instance to be collected meets the configuration information collection condition; wherein the target host is a marked host; If the Tomcat instance to be collected meets the configuration information collection condition, the structure of the Tomcat instance to be collected is initialized to obtain the data structure of the Tomcat instance to be collected; Collecting the configuration information of the Tomcat instance to be collected from the target host to which the Tomcat instance to be collected belongs, and generating a Tomcat configuration information data model according to the configuration information and data structure of the Tomcat instance to be collected; The Tomcat configuration information data model of the Tomcat instance to be collected is stored in the database, and the step of determining the Tomcat instance to be collected from all Tomcat instances under the target host is returned to execute until the Tomcat instance to be collected does not exist in the Tomcat instances under the target host.
2. The method according to claim 1, characterized in that The sending of the corresponding script to all hosts, so as to filter out at least one Tomcat process from various processes on the hosts through the script, includes: For each host, send a corresponding script to the host; Acquire a handle table maintained on the host through the script; wherein the handle table includes a plurality of handles maintained on the host; Querying the handles having Tomcat features from the respective handles through the script, and determining the handles having the Tomcat features as Tomcat handles; Obtaining a process table maintained on the host through the script, and identifying the Tomcat process to which the Tomcat handle belongs from each process in the process table; The script is used to filter out the Tomcat process from each of the other processes according to each of the files under each of the other processes; wherein the other processes are processes other than the Tomcat process to which the Tomcat handle belongs and the preset process.
3. The method according to claim 2, characterized in that The method of filtering out the Tomcat process from the other processes according to the files under the other processes by the script includes: For each other process, obtain all files under the other process, and unpack and parse each file under the other process in turn to determine whether there is a Tomcat core file in each file under the other process; If there is a Tomcat core file in each file under the other process, the other process is determined as a Tomcat process.
4. The method according to claim 2, characterized in that: The collecting the configuration information of the Tomcat instance to be collected from the target host to which the Tomcat instance to be collected belongs includes: According to the Tomcat handle of the Tomcat process belonging to the Tomcat instance to be collected, obtaining the installation directory of the Tomcat instance to be collected from the target host to which the Tomcat instance to be collected belongs; According to the preset startup command line, obtain the location and version of the corresponding Java main program from the target host to which the Tomcat instance to be collected belongs; According to the preset command line, obtain the corresponding jmx port from the target host to which the Tomcat instance to be collected belongs; According to a preset application service port collection method, corresponding application service port information is collected from a target host to which the Tomcat instance to be collected belongs; Obtain the process startup user and the complete startup command line from the target host to which the Tomcat instance to be collected belongs; Obtaining the version number of the Tomcat instance to be collected from the target host to which the Tomcat instance to be collected belongs; The configuration information of the Tomcat instance to be collected is generated according to the basic information of the Tomcat instance to be collected, the installation directory, the location and version of the java main program, the jmx port, the application service port information, the process startup user and the complete startup command line and the version number of the Tomcat instance to be collected.
5. The method according to claim 1, characterized in that The determining the Tomcat instance to be collected from all Tomcat instances under the target host, and judging whether the Tomcat instance to be collected meets the configuration information collection condition, includes: Determine the Tomcat instance to be collected from all Tomcat instances under the target host; Determine whether the Tomcat process corresponding to the Tomcat instance to be collected is a specific application process started by Tomcat; If the Tomcat process corresponding to the Tomcat instance to be collected is a specific application process started by Tomcat, it is determined that the Tomcat instance to be collected does not meet the configuration information collection condition; If the Tomcat process corresponding to the Tomcat instance to be collected is not a specific application process started by Tomcat, it is determined that the Tomcat instance to be collected meets the configuration information collection condition.
6. A Tomcat instance and its configuration information collection system, characterized in that: The system comprises: A screening unit, used to send corresponding scripts to all hosts, so as to screen out at least one Tomcat process from various processes maintained on the hosts through the script; A first storage unit is used to store, for each Tomcat process, a Tomcat instance corresponding to the Tomcat process in a database, and mark a host to which the Tomcat process corresponding to the Tomcat instance belongs; The first judgment unit is used to determine the Tomcat instance to be collected from all Tomcat instances under the target host, and judge whether the Tomcat instance to be collected meets the configuration information collection condition; wherein the target host is a marked host; A structure initialization unit, used for initializing the structure of the Tomcat instance to be collected if the Tomcat instance to be collected meets the configuration information collection condition, so as to obtain the data structure of the Tomcat instance to be collected; A configuration information collection unit, used to collect the configuration information of the Tomcat instance to be collected from the target host to which the Tomcat instance to be collected belongs, and generate a Tomcat configuration information data model according to the configuration information and data structure of the Tomcat instance to be collected; The second storage unit is used to store the Tomcat configuration information data model of the Tomcat instance to be collected in the database, and return to execute the first judgment unit until the Tomcat instance to be collected does not exist in each Tomcat instance under the target host.
7. The system according to claim 6, characterized in that The screening unit comprises: A script sending unit, used for sending a corresponding script to each host; A handle table acquisition unit, used to acquire a handle table maintained on the host through the script; wherein the handle table includes a plurality of handles maintained on the host; A first determining unit, configured to query the handles having Tomcat features from the respective handles through the script, and determine the handles having the Tomcat features as Tomcat handles; an identification unit, configured to obtain a process table maintained on the host through the script, and identify the Tomcat process to which the Tomcat handle belongs from each process in the process table; The screening subunit is used to screen out the Tomcat process from each of the other processes according to each file under each of the other processes through the script; wherein the other processes are processes other than the Tomcat process to which the Tomcat handle belongs and the preset process.
8. The system according to claim 7, characterized in that The screening subunit comprises: The unpacking and parsing unit is used to obtain all files under each other process, and unpack and parse each file under the other process in turn to determine whether there is a Tomcat core file in each file under the other process; The second determining unit is used to determine the other process as a Tomcat process if there is a Tomcat core file in each file under the other process.
9. An electronic device, characterized in that: include: A processor and a memory, wherein the processor and the memory are connected via a communication bus; wherein the processor is used to call and execute a program stored in the memory; The memory is used to store a program, and the program is used to implement a Tomcat instance and a configuration information collection method thereof as described in any one of claims 1 to 5.
10. A storage medium, characterized in that: The storage medium stores computer-executable instructions, and the computer-executable instructions are used to execute a Tomcat instance and a method for collecting configuration information thereof as described in any one of claims 1 to 5.