A method of management testing service device and application program
Technical field
The invention belongs to Centralized Monitorings and control technology field, provide a kind of side for managing testing service device and application program
Method.
Background technique
It usually requires to log on to different servers during integration testing, checks the operation shape of various application programs
State starts various application programs using order, shutoff operation.With being continuously increased for Products line, integration testing
The application program of the server and deployment of environment on the server is also more and more, this work also becomes more and more cumbersome.
The present invention develops a kind of management method, manages concentratedly to different server and various applications, can open up in real time
Show the operating status that whether each server starts, shows the application program and application program disposed on each server, and
And it can directly initiate or close each application program.
Summary of the invention
The purpose of the present invention is in view of the deficiencies of the prior art, developing a web-based management platform, a kind of management survey is provided
The method for trying server and application program.
The technical solution adopted by the present invention to solve the technical problems is as follows:
Step 1 stores the essential information of server and application program to database.The essential information of server includes clothes
Be engaged in device id (unique), server ip, user name, password, port, starting state.The essential information of application program includes applying id
(unique), Apply Names, place server id, using path, application type, operating status.By user's operation type, operation pair
As type (server or application program), operation object id, whether need to connect server, operation it is corresponding order, order hold
Row result and actual result corresponding relationship are stored to database.Wherein user's operation type refers to Refresh Servers starting state, brush
The operations such as new application operating status, starting application program, closing application program.
Step 2, user enter web-based management platform, the Servers-all information that load step 1 is safeguarded, and are deployed in clothes
The application list being engaged on device, and default and execute Refresh Servers starting state, refresh application program running state two behaviour
Make.Each server info is provided which " to refresh " movement, triggering " refreshing " movement i.e. progress Refresh Servers starting state.For
Operating status is that the application program of " not running " provides " refreshing ", " starting " movement, and triggering " refreshing ", " starting " movement carry out
Refresh application program running state, starting application program.The application program for being " in operation " for operating status provide " refreshing ",
" starting " movement, triggering " refreshing ", " starting " movement carry out refreshing application program running state, close application program.
Step 3, user trigger corresponding movement in step 2, and server-side obtains user's operation type and operation object id,
According to user's operation type and operation object id inquiry operation object type, whether need to connect server, the corresponding life of operation
It enables, command execution results and actual result corresponding relationship.
For needing to connect the operation of server, corresponding server essential information need to be first obtained.To operation object type
For the operation of server, according to operation object id, i.e. server id query service device essential information.It is to answer to operation object type
With the operation of program, according to operation object id, i.e., server id where being inquired using id, further according to server id query service device
Essential information.Platform service end is managed according to server essential information, connects remote server.After successful connection, then execute behaviour
Make corresponding order.After ordering execution, command execution results are obtained, according to command execution results and actual result corresponding relationship
Actual result is obtained, actual result is fed back into user.
Described " connection remote server " concrete operations are as follows: use the Paramiko module SSHClient class of Python
Connect method connect remote server, the parameter needed be server ip, user name, password, port.
Described " execute and the operate corresponding order " concrete operations are as follows: corresponding to operating according to user's operation type queries
Order, executes the order using the exec_command method of the Paramiko module SSHClient class of Python.
It is illustrated for refreshing the operation of Tomcat application program running state:
User clicks the Refresh button of application program, and server-side obtains user's operation type and operation object id, according to
User's operation type queries operation object type, whether need to connect server, operation it is corresponding order, command execution results and
Actual result corresponding relationship.Wherein Tomcat procedure operation object type be application program, whether need to connect server be yes,
Operate corresponding order for " ps-ef | grep [using path] | grep-v " grep " | grep-v " tail " ", command execution results
With actual result corresponding relationship are as follows: command execution results are not that empty then application program running state is " in operation ", it is on the contrary then
For " not running ".
It is looked into according to the essential information of application id inquiry application according to the server id in application program essential information
Ask the essential information of server.According to the server ip in server essential information, user name, password, port, long-range clothes are connected
Business device.After successful connection, redo corresponding order.After ordering execution, command execution results are obtained, order executes knot
When fruit is not sky, user will be fed back to as actual result " in operation ", on the contrary it is then by " not running " as actual result feedback
To user.
The server is Linux server.
The present invention has the beneficial effect that:
The present invention is the centralized management to testing service device and application program, saves and needs every time using long-range fastening means
And manual input commands come check server and application program state and unlatching, close application program, improve work
Efficiency.
Specific embodiment
Below with reference to embodiment, the invention will be further described.
A method of management testing service device and application program, the specific steps are as follows:
Step 1 stores the essential information of server and application program to database.The essential information of server includes clothes
Be engaged in device id (unique), server ip, user name, password, port, starting state.The essential information of application program includes applying id
(unique), Apply Names, place server id, using path, application type, operating status.By user's operation type, operation pair
As type (server or application program), operation object id, whether need to connect server, operation it is corresponding order, order hold
Row result and actual result corresponding relationship are stored to database.Wherein user's operation type refers to Refresh Servers starting state, brush
The operations such as new application operating status, starting application program, closing application program.
Step 2, user enter web-based management platform, the Servers-all information that load step 1 is safeguarded, and are deployed in clothes
The application list being engaged on device, and default and execute Refresh Servers starting state, refresh application program running state two behaviour
Make.Each server info is provided which " to refresh " movement, triggering " refreshing " movement i.e. progress Refresh Servers starting state.For
Operating status is that the application program of " not running " provides " refreshing ", " starting " movement, and triggering " refreshing ", " starting " movement carry out
Refresh application program running state, starting application program.The application program for being " in operation " for operating status provide " refreshing ",
" starting " movement, triggering " refreshing ", " starting " movement carry out refreshing application program running state, close application program.
Step 3, user trigger corresponding movement in step 2, and server-side obtains user's operation type and operation object id,
According to user's operation type and operation object id inquiry operation object type, whether need to connect server, the corresponding life of operation
It enables, command execution results and actual result corresponding relationship.
For needing to connect the operation of server, corresponding server essential information need to be first obtained.To operation object type
For the operation of server, according to operation object id, i.e. server id query service device essential information.It is to answer to operation object type
With the operation of program, according to operation object id, i.e., server id where being inquired using id, further according to server id query service device
Essential information.Platform service end is managed according to server essential information, connects remote server.After successful connection, then execute behaviour
Make corresponding order.After ordering execution, command execution results are obtained, according to command execution results and actual result corresponding relationship
Actual result is obtained, actual result is fed back into user.
Described " connection remote server " concrete operations are as follows: use the Paramiko module SSHClient class of Python
Connect method connect remote server, the parameter needed be server ip, user name, password, port.
Described " execute and the operate corresponding order " concrete operations are as follows: corresponding to operating according to user's operation type queries
Order, executes the order using the exec_command method of the Paramiko module SSHClient class of Python.
It is illustrated for refreshing the operation of Tomcat application program running state:
User clicks the Refresh button of application program, and server-side obtains user's operation type and operation object id, according to
User's operation type queries operation object type, whether need to connect server, operation it is corresponding order, command execution results and
Actual result corresponding relationship.Wherein Tomcat procedure operation object type be application program, whether need to connect server be yes,
Operate corresponding order for " ps-ef | grep [using path] | grep-v " grep " | grep-v " tail " ", command execution results
With actual result corresponding relationship are as follows: command execution results are not that empty then application program running state is " in operation ", it is on the contrary then
For " not running ".
It is looked into according to the essential information of application id inquiry application according to the server id in application program essential information
Ask the essential information of server.According to the server ip in server essential information, user name, password, port, long-range clothes are connected
Business device.After successful connection, redo corresponding order.After ordering execution, command execution results are obtained, order executes knot
When fruit is not sky, user will be fed back to as actual result " in operation ", on the contrary it is then by " not running " as actual result feedback
To user.
The server is Linux server.