Method and device for real-time display of standard output information on terminal page

The standard output information of the background server is obtained in real time through the operation and maintenance tool ANSIBLE and updated to the log information table, which solves the problem that the WEB page cannot display the background execution commands or scripts in real time, and achieves efficient real-time display effect.

CN114547035BActive Publication Date: 2025-09-12BEIJING CHIBO INFORMATION ENG CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210167411.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-02-23
Publication Date
2025-09-12
Estimated Expiration
2042-02-23

AI Technical Summary

Technical Problem

The existing technology cannot achieve real-time display of commands or scripts executed by the backend server on the WEB page, especially when the command or script is called and executed in the background by other programs, the relevant standard output information cannot be viewed, and the real-time performance of the existing method is insufficient.

Method used

Using the pre-set operation and maintenance tool ANSIBLE, by generating a configuration file and establishing a connection with the controlled machine, the operating system information and the standard output information of the executed script are obtained, and updated in real time to the log information table, and finally displayed on the WEB page.

Benefits of technology

It realizes that when the background server runs commands or scripts, the client interface can display the running status and results in real time. It has high applicability and real-time performance, and can display standard output information accurately and efficiently.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114547035B_ABST
    Figure CN114547035B_ABST
Patent Text Reader

Abstract

The present invention provides a method and device for displaying standard output information in real time on a terminal page. The method comprises: generating a configuration file according to a received input instruction, sending the configuration file to an operation and maintenance tool, and updating the task information in the configuration file into a pre-established log information table; obtaining the operating system information of the controlled machine using the operation and maintenance tool according to the address of the controlled machine, and updating the operating system information into the log information table; sending the execution script to the controlled machine using the operation and maintenance tool according to the address of the controlled machine, and obtaining the standard output information generated when the controlled machine executes the script; updating the standard output information generated when the controlled machine executes the script into the log information table, and sending the information in the log information table to a page for real-time display. When a backend server runs various commands or scripts, the present invention enables a client interface to display the running status and results in real time. The method has strong applicability, high real-time performance, and can accurately and efficiently display standard output information.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of standard output information, and in particular to a method and device for displaying standard output information in real time on a terminal page. Background Art

[0002] Currently, there are two main ways to view the standard output log of a command or script running on a server: 1) log in to the server's operating terminal, run the command or script to view the relevant standard output log; 2) redirect the log content output by the command or script to a file, and then view the relevant log file information after the execution is completed.

[0003] Both methods have their drawbacks. While the first method allows real-time viewing of logs, standard output information cannot be viewed if the command or script is executed in the background by other programs. The second method, while preventing the inability to view standard output information when a command or script is executed in the background by other programs, is not very timely. The relevant information can only be viewed in the file after the command or script has completed.

[0004] When viewing the operation information of the managed server, the existing WEB application system generally retrieves the standard output log generated by the background command or script back to the server in the form of a file, processes it, and then displays it on the WEB client. It cannot display the real-time situation when the background server executes the command or script. Summary of the Invention

[0005] In response to the problems existing in the prior art, the main purpose of the embodiments of the present invention is to provide a method and device for displaying standard output information in real time on a terminal page, so as to enable a WEB page to display the standard output information when a backend server executes a command or script in real time.

[0006] To achieve the above-mentioned object, an embodiment of the present invention provides a method for displaying standard output information on a terminal page in real time, the method comprising:

[0007] Generate a configuration file based on the received input instructions, send the configuration file to the operation and maintenance tool, and update the task information in the configuration file to a pre-established log information table; wherein the task information includes the execution script and the controlled machine address;

[0008] According to the controlled machine address, using the operation and maintenance tool to obtain the operating system information of the controlled machine, and updating the operating system information to the log information table;

[0009] According to the controlled machine address, using the operation and maintenance tool, the execution script is sent to the controlled machine, and standard output information generated when the controlled machine executes the execution script is obtained;

[0010] The standard output information generated when the controlled machine executes the execution script is updated to the log information table, and the information in the log information table is sent to the page for real-time display.

[0011] Optionally, in one embodiment of the present invention, generating a configuration file according to the received input instruction includes:

[0012] Generate task information and tasks to be executed corresponding to the task information according to the received input instructions, and execute the tasks to be executed;

[0013] Determine whether there is a task that is the same as the task to be executed and is currently running; if not, generate a configuration file based on the task information.

[0014] Optionally, in an embodiment of the present invention, obtaining the operating system information of the controlled machine using the operation and maintenance tool according to the controlled machine address includes:

[0015] Establishing a connection with the controlled machine using the operation and maintenance tool according to the controlled machine address, and obtaining a connection establishment result;

[0016] If the connection establishment result is a connection failure, the standard output information corresponding to the connection establishment result is updated to the log information table;

[0017] If the connection establishment result is successful, the operating system information of the controlled machine is obtained.

[0018] Optionally, in an embodiment of the present invention, sending the execution script to the controlled machine using the operation and maintenance tool according to the controlled machine address includes:

[0019] Determining whether the controlled machine can execute the execution script according to the operating system information of the controlled machine;

[0020] If the script cannot be executed, the standard output information corresponding to the failure of the controlled machine to execute the script is updated to the log information table;

[0021] If it can be executed, the operation and maintenance tool is used to send the execution script to the controlled machine.

[0022] An embodiment of the present invention further provides a device for displaying standard output information in real time on a terminal page, the device comprising:

[0023] A configuration file module is used to generate a configuration file based on the received input instructions, send the configuration file to the operation and maintenance tool, and update the task information in the configuration file to a pre-established log information table; wherein the task information includes the execution script and the controlled machine address;

[0024] A system information module, configured to obtain operating system information of the controlled machine using the operation and maintenance tool according to the controlled machine address, and update the operating system information into the log information table;

[0025] an information acquisition module, configured to send the execution script to the controlled machine using the operation and maintenance tool according to the controlled machine address, and to acquire standard output information generated when the controlled machine executes the execution script;

[0026] The information display module is used to update the standard output information generated when the controlled machine executes the execution script to the log information table, and send the information in the log information table to a page for real-time display.

[0027] Optionally, in one embodiment of the present invention, the configuration file module includes:

[0028] A task information unit, configured to generate task information and a task to be executed corresponding to the task information according to a received input instruction, and execute the task to be executed;

[0029] The configuration file unit is used to determine whether there is a task that is the same as the task to be executed and is running. If not, a configuration file is generated according to the task information.

[0030] Optionally, in one embodiment of the present invention, the system information module includes:

[0031] a connection establishing unit, configured to establish a connection with the controlled machine using the operation and maintenance tool according to the controlled machine address, and obtain a connection establishment result;

[0032] a connection failure unit, configured to update the standard output information corresponding to the connection establishment result into the log information table if the connection establishment result is a connection failure;

[0033] The connection success unit is used to obtain the operating system information of the controlled machine if the connection establishment result is a successful connection.

[0034] Optionally, in one embodiment of the present invention, the information acquisition module includes:

[0035] An execution script unit, configured to determine whether the controlled machine can execute the execution script according to the operating system information of the controlled machine;

[0036] an information updating unit, configured to update the standard output information corresponding to the inability of the controlled machine to execute the execution script into the log information table if the execution fails;

[0037] The script sending unit is used to send the execution script to the controlled machine using the operation and maintenance tool if the execution script can be executed.

[0038] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above method when executing the program.

[0039] The present invention also provides a computer-readable storage medium storing a computer program for executing the above method.

[0040] The present invention utilizes pre-set operation and maintenance tools to enable the client interface to display the running status and results in real time when various commands or scripts are run on the background server. It has the advantages of strong applicability, high real-time performance, and can accurately and efficiently display standard output information. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0042] Figure 1 This is a flow chart of a method for displaying standard output information in real time on a terminal page according to an embodiment of the present invention;

[0043] Figure 2 A flowchart of generating a configuration file in an embodiment of the present invention;

[0044] Figure 3 This is a flowchart of obtaining operating system information in an embodiment of the present invention;

[0045] Figure 4 This is a flowchart of sending an execution script in an embodiment of the present invention;

[0046] Figure 5 This is a flow chart of a page displaying standard output information in real time in a specific embodiment of the present invention;

[0047] Figure 6 A typical function call relationship diagram in an embodiment of the present invention;

[0048] Figure 7 This is a schematic structural diagram of a device for displaying standard output information in real time on a terminal page according to an embodiment of the present invention;

[0049] Figure 8 This is a schematic diagram of the structure of a configuration file module in an embodiment of the present invention;

[0050] Figure 9 This is a schematic diagram of the structure of the system information module in an embodiment of the present invention;

[0051] Figure 10 This is a schematic diagram of the structure of the information acquisition module in an embodiment of the present invention;

[0052] Figure 11 A schematic structural diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0053] The embodiment of the present invention provides a method and apparatus for displaying standard output information in real time on a terminal page.

[0054] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.

[0055] like Figure 1 The flowchart of a method for displaying standard output information in real time on a terminal page according to an embodiment of the present invention is shown. The execution subject of the method for displaying standard output information in real time on a terminal page provided by the embodiment of the present invention includes, but is not limited to, a computer, specifically a web page terminal. The method shown in the figure includes:

[0056] Step S1: Generate a configuration file based on the received input command, send the configuration file to the operation and maintenance tool, and update the task information in the configuration file to a pre-established log information table; wherein the task information includes the execution script and the controlled machine address;

[0057] Step S2: Obtain the operating system information of the controlled machine using the operation and maintenance tool according to the controlled machine address, and update the operating system information to the log information table;

[0058] Step S3: Send the execution script to the controlled machine using the operation and maintenance tool according to the controlled machine address, and obtain the standard output information generated when the controlled machine executes the execution script;

[0059] Step S4: updating the standard output information generated when the controlled machine executes the execution script to the log information table, and sending the information in the log information table to the page for real-time display.

[0060] The terminal receives a command input by the user, which may be a file backup command. Based on the input command, a task to be executed is created, which includes task information. Specifically, the task information includes the execution script and the controlled address, i.e., the IP information of the controlled machine.

[0061] Furthermore, the terminal generates a configuration file using the task information. The process of generating the configuration file can be a common configuration file generation method. At the same time, the task information is updated in a pre-established log information table. Specifically, the log information table is set in a database, and the terminal can update and read the information in the log information table by accessing the database.

[0062] Furthermore, the terminal sends the generated configuration file to a pre-configured operation and maintenance tool, which parses the configuration file to obtain the execution script and the controlled machine address. Specifically, the configuration file may only include the execution script acquisition address, and the operation and maintenance tool obtains the execution script from the acquisition address.

[0063] The terminal establishes a connection with the controlled machine using an operation and maintenance tool according to the controlled machine address. Specifically, the connection can be established via SSH. The operation and maintenance tool can be ANSIBLE. In the present invention, by pre-defining interfaces, functions, classes, etc. in ANSIBLE, the operation and maintenance tool can obtain standard output information from the background server in real time and update the standard output information to the log information table.

[0064] Specifically, ANSIBLE is an automated operation and maintenance tool developed based on Python. It combines the advantages of many operation and maintenance tools (puppet, cfengine, chef, func, fabric), and realizes functions such as batch system configuration, batch program deployment, and batch command execution.

[0065] Furthermore, after the connection is successful, the terminal obtains the operating system information of the controlled machine from the controlled machine and determines whether the controlled machine can execute the execution script based on the operating system information. If not, the standard output information corresponding to the result of not being able to execute is updated to the log information table.

[0066] Furthermore, if the controlled machine can execute the execution script, the terminal sends the execution script to the controlled machine, which executes the script. When the controlled machine executes the execution script, the standard output information generated during the execution process is updated in real time to the log information table.

[0067] Furthermore, the terminal can display the standard output information in real time by reading the log information table using a web page. This enables the web page to display the standard output information in real time when the backend controlled machine executes the script.

[0068] As an embodiment of the present invention, Figure 2 As shown, generating a configuration file according to the received input instruction includes:

[0069] Step S11: generating task information and tasks to be executed corresponding to the task information according to the received input instruction, and running the tasks to be executed;

[0070] Step S12: determine whether there is a task that is the same as the task to be executed currently running. If not, generate a configuration file based on the task information.

[0071] The terminal receives user input, such as a file backup command. Based on the input command, it creates a pending task, which includes task information. Specifically, the task information includes the execution script and the controlled address, i.e., the IP address of the controlled machine.

[0072] Furthermore, it is determined whether there is a task that is the same as the task to be executed. If so, the task is terminated directly. If not, a configuration file is generated. Specifically, the terminal generates a configuration file using the task information. The process of generating the configuration file can be a common configuration file generation method.

[0073] As an embodiment of the present invention, Figure 3 As shown in the figure, based on the controlled machine address, the operating system information of the controlled machine can be obtained using the operation and maintenance tool, including:

[0074] Step S21: Establish a connection with the controlled machine using the operation and maintenance tool according to the controlled machine address, and obtain a connection establishment result;

[0075] Step S22: If the connection establishment result is a connection failure, the standard output information corresponding to the connection establishment result is updated to the log information table;

[0076] Step S23: If the connection establishment result is successful, the operating system information of the controlled machine is obtained.

[0077] The terminal establishes a connection with the controlled machine using an operation and maintenance tool according to the controlled machine address, and specifically, the connection can be established via SSH. The operation and maintenance tool can be ANSIBLE. In the present invention, by pre-defining interfaces, functions, classes, etc. in ANSIBLE, the operation and maintenance tool can obtain standard output information from the background server in real time and update the standard output information to the log information table.

[0078] Furthermore, if the connection cannot be established, the connection establishment result is obtained as failure, and the standard output information corresponding to the connection establishment failure is updated to the log information table. If the connection establishment result is successful, the operating system information of the controlled machine is obtained through the operation and maintenance tool.

[0079] As an embodiment of the present invention, Figure 4 As shown, according to the controlled machine address, using the operation and maintenance tool to send the execution script to the controlled machine includes:

[0080] Step S31, judging whether the controlled machine can execute the execution script according to the operating system information of the controlled machine;

[0081] Step S32: If the script cannot be executed, the standard output information corresponding to the failure of the controlled machine to execute the script is updated to the log information table;

[0082] Step S33: If it can be executed, the operation and maintenance tool is used to send the execution script to the controlled machine.

[0083] The operating system information is used to determine whether the controlled machine can execute the execution script. If not, the standard output information corresponding to the result of the inability to execute is updated in the log information table.

[0084] Furthermore, if the controlled machine can execute the execution script, the terminal sends the execution script to the controlled machine, and the controlled machine executes the script.

[0085] In a specific embodiment of the present invention, Figure 5 The page shown displays the standard output information process in real time. Taking file backup as an example, the process specifically includes:

[0086] First, create a task containing the script to be executed and the IP address of the controlled computer. This task is executed and checks whether the same task is already running in the system. If so, it ends the task. If not, it continues executing the task and creates a new record in the tb_info table, which primarily records the task name, IP address, and log information (this field is currently empty). The web page displaying the log information is refreshed every 5 seconds.

[0087] Second, based on the task's information, including the script to be executed and the controlled machine's IP address, a configuration file is generated and sent to the ANSIBLE server. The ANSIBLE server first reads and parses the configuration file. Then, based on the IP address information in the configuration file, it uses SSH to determine whether the ANSIBLE server has successfully connected to the controlled machine. If the SSH connection fails, the standard output information indicating the connection failure is updated to the log information field in the tb_info table, and the program terminates. If the SSH connection is successful, the script is retrieved based on the configuration file information and sent to the controlled machine via the ANSIBLE server. The standard output information of the distribution result is updated to the log information field in the tb_info table.

[0088] Third, the operating system type of the controlled machine is determined. If the command to determine the operating system type fails, the standard output information indicating the failure is obtained and appended to the log information field in the tb_info table. If the command to determine the operating system type succeeds, the standard output information indicating the success is obtained and appended to the log information field in the tb_info table.

[0089] Fourth, determine whether the file system mount was successful. If the script that determines whether the file system mount was successful fails, obtain the standard output information of the script execution failure and append it to the log information field in the tb_info table. If the script that determines whether the file system mount was successful succeeds, obtain the standard output information of the script and append it to the log information field in the tb_info table.

[0090] Fifth, execute the backup script. If the backup script fails, obtain the standard output information of the script execution failure and append it to the log information field in the tb_info table. If the backup script succeeds, obtain the standard output information of the script and append it to the log information field in the tb_info table.

[0091] Finally, end the page refresh every 5 seconds and end the task.

[0092] The typical function call relationship diagram of the present invention is as follows Figure 6 As shown, the calling relationship is specifically as follows:

[0093] First, the main function exec_backup() calls the connMySql() method to connect to the database. Next, it calls the run() method to automatically execute the corresponding script or system command. Simultaneously, the run() method calls the defined v2_runner_on_ok() and v2_runner_on_failed() methods to automatically retrieve the standard output and standard error information of the corresponding script or system command. Finally, the main function exec_backup() calls the update_record() method to append the standard output and standard error information of the script or system command to the loginfo field of the tb_info table and calls the disconnect() method to disconnect the database connection. The main functions of each function are described in Table 1.

[0094] In this embodiment, in order to enable the standard output of relevant commands or scripts to be viewed in real time on the WEB page when the WEB application system calls and executes the background script, the present invention adopts the ANSIBLE operation and maintenance tool. The preset process of the ANSIBLE operation and maintenance tool is described as follows.

[0095] In this embodiment, when a command or script is executed on the backend server, in order to verify the accuracy of the script execution, the command or script will generally print the standard output to the operating terminal. When the web application system calls the relevant command or script, the printed standard output cannot be displayed on the operating terminal. In this case, how to view the output log is currently a common method to write the output log to a file, then retrieve the log file through the web application system, and display it on the web interface after processing.

[0096] Among them, by implementing the v2_runner_on_unreachable, v2_runner_on_start, v2_runner_on_ok, v2_runner_on_failed interfaces provided by ANSIBLE in multiple classes, the required standard output information when executing commands or scripts is obtained in stages (if the above interfaces are not implemented, all standard output information will be automatically returned). At the same time, a custom update_record() method is used to update the required standard output information to the relevant tables in the database. The instructions are as follows:

[0097] First, define the database table structure. The table is named tb_info, which stands for log information. This table primarily contains machine information, task names, and log information. It is primarily used to store log information generated after running commands or scripts. The loginfo field appends log information generated when commands or scripts are run.

[0098] Second, define global variables DB_IP, DB_SID, DB_USER, and DB_PASSWD in the PYTHON file for database connection.

[0099] Third, implement the data update class DataRefresh (whose parent class is ANSIBLE's CallbackBase), which mainly includes:

[0100] 1. connMySql() and disconnect() methods mainly implement the database connection and disconnection functions;

[0101] 2. The insert_record() method uses SQL statements to add a new record in the tb_info table of the database when the program starts executing. It mainly records information such as task name, IP address, creation time, and creator;

[0102] 3. The update_record() method updates the newly added records, primarily using SQL statements to update the command or script's running status and the standard output during execution (standard output is appended to the loginfo field in the tb_info table). The update condition requires that the task name and IP address be passed to the method and that the corresponding record be found in the tb_info table.

[0103] Fourth, implement the result processing class A (whose parent class is DataRefresh). The main function of this class is to obtain the standard output of the command related to checking the system type, and write the servers of different operating system types into their respective array variables hosts_aix[] and hosts_linux[]:

[0104] 1. Define the v2_runner_on_unreachable method (ANSIBLE interface) and define a local variable named recode of type dictionary within the method. This variable stores the fields and values ​​in the tb_info table as key-value pairs. Call the update_record(recode) method to update the corresponding record in the tb_info table with the new information. The v2_runner_on_unreachable method primarily updates the loginfo field with the standard output information when a connection to the controlled machine fails.

[0105] 2. Define the v2_runner_on_ok method (ANSIBLE interface). Also within this method, define the dictionary-type local variable recode and call the update_record(recode) method to update the corresponding record in the tb_info table. The v2_runner_on_ok method primarily checks whether the standard output of the uname command (a system command native to AIX or LINUX) contains the AIX or Linux keyword, thereby verifying whether the system type is AIX or Linux. If the check meets the requirements, the standard output of the command is appended to the loginfo field, and the server IP address is written to the array variables hosts_aix[] and hosts_linux[], respectively. If the check does not meet the requirements, as in the case of Windows operating systems, a fixed prompt message is appended to the loginfo field.

[0106] 3. Define the v2_runner_on_failed method (ANSIBLE interface). Also within this method, define the dictionary-type local variable recode and call the update_record(recode) method to update the corresponding record in the tb_info table. The v2_runner_on_failed method primarily appends the command's standard output error information to the loginfo field if the system-type uname command fails to execute for some reason.

[0107] Fifth, implement the result processing class B (whose parent class is DataRefresh). The main function of this class is to obtain the standard output of the script to determine whether the specified file system to be backed up is mounted normally:

[0108] 1. Define the v2_runner_on_ok method (ANSIBLE interface). Also define the dictionary-type local variable recode in this method, call the update_record(recode) method, and update the corresponding record in the tb_info table. The main function of the v2_runner_on_ok method is to determine whether the standard output of the script that checks whether the file system is mounted normally contains the SUCC: keyword, and update the standard output of the script to the loginfo field in an appended form; if it contains the FAIL: keyword, the task status is changed to a non-running state, and the relevant standard output is updated to the loginfo field in an appended form.

[0109] 2. Define the v2_runner_on_failed method (ANSIBLE interface). Also within this method, define the local variable recode of the dictionary type and call the update_record(recode) method to update the corresponding record in the tb_info table. The v2_runner_on_failed method primarily appends the script's standard output error information to the loginfo field if the script that determines whether the specified file system is mounted properly fails to start and run for some reason.

[0110] Sixth, implement the result processing class C (whose parent class is DataRefresh). The main function of this class is to obtain the standard output to determine whether the backup script is executed normally:

[0111] 1. Define the v2_runner_on_ok method (ANSIBLE interface). Also within this method, define the local variable recode of the dictionary type and call the update_record(recode) method to update the corresponding record in the tb_info table. The v2_runner_on_ok method primarily retrieves the various standard output information defined in the backup script and appends it to the loginfo field.

[0112] 2. Define the v2_runner_on_failed method (ANSIBLE interface). Also within this method, define the dictionary-type local variable recode and call the update_record(recode) method to update the corresponding record in the tb_info table. The v2_runner_on_failed method appends the script's standard output error information to the loginfo field if the backup script fails to start and run properly for some reason.

[0113] Seventh, implement the run class RunTask (whose parent class is ANSIBLE's CallbackBase). The main functions of this class are to determine the system type, check whether the specified file system exists, and execute the backup script.

[0114] 1. Define the check_os method:

[0115] 1) In this method, create an instance object result1 of class A, call the database connection method through the result1 object to connect to the database, that is, result1.connMySql();

[0116] 2) Pass the uname command and the result1 object as parameters to ANSIBLE's run() method. The run() method automatically executes the uname command and automatically obtains relevant standard output information based on the v2_runner_on_unreachable(), v2_runner_on_ok(), and v2_runner_on_failed() methods defined in the result1 object. It then appends the information to the loginfo field of the tb_info table using the update_record() method in result1. Finally, the web page displays the information by accessing the tb_info table in the database.

[0117] 3) Call the method to disconnect the database connection through the result1 object to disconnect the database connection, that is, result1.disconnect().

[0118] 2. Define the check_file_system method:

[0119] 1) In this method, create an instance object result2 of class B, call the database connection method through the result2 object to connect to the database, that is, result2.connMySql();

[0120] 2) The script's execution command, which checks whether the file system to be backed up is mounted properly, and the result2 object are passed as parameters to ANSIBLE's run() method. The run() method automatically executes the corresponding script's execution command and, using the v2_runner_on_ok() and v2_runner_on_failed() methods defined in the result2 object, automatically obtains the standard output of the relevant script. The update_record() method in result2 appends the information to the loginfo field of the tb_info table. Finally, the web page is displayed by accessing the tb_info table in the database.

[0121] 3) Call the method to disconnect the database connection through the result2 object to disconnect the database connection, that is, result2.disconnect().

[0122] 3. Define the exec_backup method:

[0123] 1) In this method, create an instance object result3 of class C, call the database connection method through the result3 object to connect to the database, that is, result3.connMySql();

[0124] 2) Pass the backup script's execution command and the result3 object as parameters to ANSIBLE's run() method. The run() method automatically executes the corresponding script's execution command and automatically obtains the standard output information of the relevant script based on the v2_runner_on_start, v2_runner_on_ok(), and v2_runner_on_failed() methods defined in the result3 object. It then appends the information to the loginfo field of the tb_info table using the update_record() method in result3. Finally, the web page is displayed by accessing the tb_info table in the database.

[0125] 3) Call the method to disconnect the database connection through the result3 object to disconnect the database connection, that is, result3.disconnect().

[0126] The definitions of the English abbreviations involved in the above process are shown in Table 1.

[0127] Table 1

[0128]

[0129]

[0130] The present invention utilizes pre-set operation and maintenance tools to enable the client interface to display the running status and results in real time when various commands or scripts are run on the background server. It has the advantages of strong applicability, high real-time performance, and can accurately and efficiently display standard output information.

[0131] like Figure 7 FIG2 is a schematic diagram showing the structure of a device for displaying standard output information in real time on a terminal page according to an embodiment of the present invention. The device shown in the figure includes:

[0132] The configuration file module 10 is used to generate a configuration file based on the received input instructions, send the configuration file to the operation and maintenance tool, and update the task information in the configuration file to a pre-established log information table; wherein the task information includes the execution script and the controlled machine address;

[0133] The system information module 20 is used to obtain the operating system information of the controlled machine using the operation and maintenance tool according to the controlled machine address, and update the operating system information to the log information table;

[0134] The information acquisition module 30 is used to send the execution script to the controlled machine using the operation and maintenance tool according to the controlled machine address, and obtain the standard output information generated when the controlled machine executes the execution script;

[0135] The information display module 40 is used to update the standard output information generated when the controlled machine executes the execution script to the log information table, and send the information in the log information table to the page for real-time display.

[0136] As an embodiment of the present invention, Figure 8 As shown, the configuration file module 10 includes:

[0137] The task information unit 11 is used to generate task information and the to-be-executed task corresponding to the task information according to the received input instruction, and run the to-be-executed task;

[0138] The configuration file unit 12 is used to determine whether there is a task that is the same as the task to be executed and is running. If not, a configuration file is generated according to the task information.

[0139] As an embodiment of the present invention, Figure 9 As shown, the system information module 20 includes:

[0140] The connection establishment unit 21 is used to establish a connection with the controlled machine using the operation and maintenance tool according to the controlled machine address and obtain a connection establishment result;

[0141] The connection failure unit 22 is configured to update the standard output information corresponding to the connection establishment result into the log information table if the connection establishment result is a connection failure;

[0142] The connection success unit 23 is configured to obtain the operating system information of the controlled machine if the connection establishment result is successful.

[0143] As an embodiment of the present invention, Figure 10 As shown, the information acquisition module 30 includes:

[0144] The script execution unit 31 is used to determine whether the controlled machine can execute the execution script according to the operating system information of the controlled machine;

[0145] The information updating unit 32 is used to update the standard output information corresponding to the controlled machine being unable to execute the execution script into the log information table if the execution cannot be performed;

[0146] The script sending unit 33 is used to send the execution script to the controlled machine using the operation and maintenance tool if the script can be executed.

[0147] Based on the same application concept as the aforementioned method for displaying standard output information on a terminal page in real time, the present invention also provides a device for displaying standard output information on a terminal page in real time. Because the principles underlying the device for displaying standard output information on a terminal page in real time are similar to those of the method for displaying standard output information on a terminal page in real time, the implementation of the device for displaying standard output information on a terminal page in real time can be referenced to the implementation of the method for displaying standard output information on a terminal page in real time, and any repetitions will not be repeated.

[0148] The present invention utilizes pre-set operation and maintenance tools to enable the client interface to display the running status and results in real time when various commands or scripts are run on the background server. It has the advantages of strong applicability, high real-time performance, and can accurately and efficiently display standard output information.

[0149] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above method when executing the program.

[0150] The present invention also provides a computer-readable storage medium storing a computer program for executing the above method.

[0151] like Figure 11As shown, the electronic device 600 may further include: a communication module 110, an input unit 120, an audio processing unit 130, a display 160, and a power supply 170. It is worth noting that the electronic device 600 does not necessarily have to include Figure 11 In addition, the electronic device 600 may also include all components shown in Figure 11 For components not shown, reference may be made to the prior art.

[0152] like Figure 11 As shown, the central processing unit 100 is sometimes also referred to as a controller or an operation control unit, and may include a microprocessor or other processor device and / or logic device. The central processing unit 100 receives inputs and controls the operations of various components of the electronic device 600 .

[0153] Memory 140 may be, for example, one or more of a cache, flash memory, hard drive, removable media, volatile memory, non-volatile memory, or other suitable devices. It may store the aforementioned failure-related information and may also store programs that execute the relevant information. The CPU 100 may execute the programs stored in memory 140 to implement information storage or processing.

[0154] The input unit 120 provides input to the CPU 100. The input unit 120 may be, for example, a keypad or touch input device. The power supply 170 is used to provide power to the electronic device 600. The display 160 is used to display objects such as images and text. The display may be, for example, an LCD display, but is not limited thereto.

[0155] The memory 140 may be a solid-state memory, such as a read-only memory (ROM), a random access memory (RAM), or a SIM card. Alternatively, it may be a memory that retains information even when power is off, can be selectively erased, and is provided with more data. Examples of such memory are sometimes referred to as EPROMs. The memory 140 may also be some other type of device. The memory 140 includes a buffer memory 141 (sometimes referred to as a buffer). The memory 140 may include an application / function storage unit 142 for storing application programs and function programs or processes for executing the operations of the electronic device 600 via the central processing unit 100.

[0156] The memory 140 may also include a data storage unit 143 for storing data, such as contacts, digital data, pictures, sounds, and / or any other data used by the electronic device. The driver storage unit 144 of the memory 140 may include various driver programs for communication functions of the electronic device and / or for executing other functions of the electronic device (such as messaging applications, address book applications, etc.).

[0157] The communication module 110 is a transmitter / receiver 110 that transmits and receives signals via an antenna 111. The communication module (transmitter / receiver) 110 is coupled to the central processor 100 to provide input signals and receive output signals, which may be the same as in a conventional mobile communication terminal.

[0158] Based on different communication technologies, multiple communication modules 110 may be provided in the same electronic device, such as a cellular network module, a Bluetooth module, and / or a wireless local area network module. The communication module (transmitter / receiver) 110 is also coupled to a speaker 131 and a microphone 132 via an audio processor 130 to provide audio output via the speaker 131 and receive audio input from the microphone 132, thereby implementing common telecommunication functions. The audio processor 130 may include any suitable buffer, decoder, amplifier, etc. Furthermore, the audio processor 130 is also coupled to the central processing unit 100, enabling local recording via the microphone 132 and playback of stored audio via the speaker 131.

[0159] It will be understood by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Thus, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0160] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowcharts and / or block diagrams, as well as combinations of processes and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowcharts and / or block diagrams. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0161] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0162] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0163] Specific embodiments are used in the present invention to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core ideas. At the same time, for those skilled in the art, according to the ideas of the present invention, there may be changes in the specific implementation methods and application scopes. In summary, the contents of this specification should not be understood as limiting the present invention.

Claims

1. A method for displaying standard output information in real time on a terminal page, characterized in that: The method comprises: Generate a configuration file based on the received input instructions, send the configuration file to the operation and maintenance tool, and update the task information in the configuration file to a pre-established log information table; wherein the task information includes the execution script and the controlled machine address; According to the controlled machine address, using the operation and maintenance tool to obtain the operating system information of the controlled machine, and updating the operating system information to the log information table; According to the controlled machine address, using the operation and maintenance tool, the execution script is sent to the controlled machine, and standard output information generated when the controlled machine executes the execution script is obtained; Updating the standard output information generated when the controlled machine executes the execution script to the log information table, and sending the information in the log information table to the page for real-time display; The method is executed based on the function call relationship, which is specifically: First, the main calling function exec_backup() calls the connMySql() method to connect to the database. Secondly, it calls the run() method to automatically execute the corresponding script or system command. At the same time, the run() method calls the defined v2_runner_on_ok() and v2_runner_on_failed() methods to automatically obtain the standard output information and standard error output information of the corresponding script or system command. Finally, the connMySql() method calls the update_record() method to append the standard output information and standard error output information of the script or system command to the loginfo field of the tb_info table and calls the disconnect() method to disconnect the database connection. The sending the execution script to the controlled machine by using the operation and maintenance tool according to the controlled machine address includes: Determining whether the controlled machine can execute the execution script according to the operating system information of the controlled machine; If the script cannot be executed, the standard output information corresponding to the failure of the controlled machine to execute the script is updated to the log information table; If it can be executed, the operation and maintenance tool is used to send the execution script to the controlled machine; The method for displaying standard output information in real time on the terminal page also includes: Determine whether the file system is mounted successfully; if the script that determines whether the file system is mounted successfully fails, obtain the standard output information of the script execution failure and update it to the log information field in the tb_info table in an appended form; if the script that determines whether the file system is mounted successfully executes successfully, obtain the standard output information output by the script and update it to the log information field in the tb_info table in an appended form; Execute the backup script; if the backup script fails, obtain the standard output information of the script execution failure and update it to the log information field in the tb_info table in appended form; if the backup script is successfully executed, obtain the standard output information output by the script and update it to the log information field in the tb_info table in appended form.

2. The method according to claim 1, characterized in that Generating a configuration file according to the received input instruction includes: Generate task information and tasks to be executed corresponding to the task information according to the received input instructions, and execute the tasks to be executed; Determine whether there is a task that is the same as the task to be executed and is currently running; if not, generate a configuration file based on the task information.

3. The method according to claim 1, characterized in that The acquiring of the operating system information of the controlled machine by using the operation and maintenance tool according to the controlled machine address includes: Establishing a connection with the controlled machine using the operation and maintenance tool according to the controlled machine address, and obtaining a connection establishment result; If the connection establishment result is a connection failure, the standard output information corresponding to the connection establishment result is updated to the log information table; If the connection establishment result is successful, the operating system information of the controlled machine is obtained.

4. A device for displaying standard output information in real time on a terminal page, characterized in that: The device comprises: A configuration file module is used to generate a configuration file based on the received input instructions, send the configuration file to the operation and maintenance tool, and update the task information in the configuration file to a pre-established log information table; wherein the task information includes the execution script and the controlled machine address; A system information module, configured to obtain operating system information of the controlled machine using the operation and maintenance tool according to the controlled machine address, and update the operating system information into the log information table; an information acquisition module, configured to send the execution script to the controlled machine using the operation and maintenance tool according to the controlled machine address, and to acquire standard output information generated when the controlled machine executes the execution script; An information display module, configured to update the standard output information generated when the controlled machine executes the execution script to the log information table, and send the information in the log information table to a page for real-time display; The device is executed based on the function call relationship, and the function call relationship is specifically: First, the main calling function exec_backup() calls the connMySql() method to connect to the database. Secondly, it calls the run() method to automatically execute the corresponding script or system command. At the same time, the run() method calls the defined v2_runner_on_ok() and v2_runner_on_failed() methods to automatically obtain the standard output information and standard error output information of the corresponding script or system command. Finally, the connMySql() method calls the update_record() method to append the standard output information and standard error output information of the script or system command to the loginfo field of the tb_info table and calls the disconnect() method to disconnect the database connection. The information acquisition module includes: An execution script unit, configured to determine whether the controlled machine can execute the execution script according to the operating system information of the controlled machine; an information updating unit, configured to update the standard output information corresponding to the inability of the controlled machine to execute the execution script into the log information table if the execution fails; a script sending unit, configured to send the execution script to the controlled machine using the operation and maintenance tool if the script can be executed; The device for displaying standard output information in real time on the terminal page is also used for: Determine whether the file system is mounted successfully; if the script that determines whether the file system is mounted successfully fails, obtain the standard output information of the script execution failure and update it to the log information field in the tb_info table in an appended form; if the script that determines whether the file system is mounted successfully executes successfully, obtain the standard output information output by the script and update it to the log information field in the tb_info table in an appended form; Execute the backup script; if the backup script fails, obtain the standard output information of the script execution failure and update it to the log information field in the tb_info table in appended form; if the backup script is successfully executed, obtain the standard output information output by the script and update it to the log information field in the tb_info table in appended form.

5. The device according to claim 4, characterized in that The configuration file module includes: A task information unit, configured to generate task information and a to-be-executed task corresponding to the task information according to a received input instruction, and to execute the to-be-executed task; The configuration file unit is used to determine whether there is a task that is the same as the task to be executed and is running. If not, a configuration file is generated according to the task information.

6. The device according to claim 4, characterized in that The system information module includes: a connection establishing unit, configured to establish a connection with the controlled machine using the operation and maintenance tool according to the controlled machine address, and obtain a connection establishment result; a connection failure unit, configured to update the standard output information corresponding to the connection establishment result into the log information table if the connection establishment result is a connection failure; The connection success unit is used to obtain the operating system information of the controlled machine if the connection establishment result is a successful connection.

7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the method according to any one of claims 1 to 3 is implemented.

8. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program for executing the method according to any one of claims 1 to 3.

Citation Information

Patent Citations

  • Operation and maintenance task execution method and device, operation and maintenance server and computer storage medium

    CN112651514A

  • Mail processing method, device, equipment and medium

    CN112651705A