Building a series of Python software buildings
The company took over a small project, the customer put forward an operation and maintenance requirements, that is, through a command, or a script to obtain the performance of multiple servers.
There is no doubt that I naturally thought of using Python to write a gadget that meets the above needs. The following is the detailed operation procedure.
Build the third-party module paramiko of Python.
See the previous blog for details
Get the IP address, user name and password of all servers you want.
Because this information is needed to execute the paramiko module.
3. Write code.
The code mainly goes through two versions.
Version 1.1.1
# the host ip on which paramiko module is installed is 167. the first version is not written into the code.
Vision 1.1.2
The above code uses localhost to communicate with the native Python module without the need for additional shell commands.
At this point, all the host memory, disk and other information of the project can be obtained by executing a script. Subsequent versions of how to format the output, as well as the use of storage, display in browsers, and even the Cmax S architecture. Come to think of it, ansible was born by integrating all kinds of resources.