The company took over a small project, the customer proposed an operational requirements, that is, through a command, or a script to obtain the performance of multiple servers.
There is no doubt that I naturally think of using Python to write a gadget that meets the requirements described above. The following is a detailed procedure.
Build Python third-party module Paramiko.
See the previous Blog
Gets the IP address, user name, and password for all servers.
This information is required for executing the Paramiko module.
3. Write the code.
The code is mainly experienced in two versions.
Version 1.1.1
650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M02/06/AF/wKiom1m777TimW3TAADmY2sY1wQ385.jpg-wh_500x0-wm_ 3-wmp_4-s_1290610938.jpg "title=" ui.jpg "alt=" Wkiom1m777timw3taadmy2sy1wq385.jpg-wh_50 "/>
The host IP of the #安装paramiko module is 167, the first version, not written into the code.
Vision 1.1.2
650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M01/06/AF/wKiom1m78XbzV35tAAD6sKZOmdM116.jpg-wh_500x0-wm_ 3-wmp_4-s_1176103116.jpg "title=" u2.jpg "alt=" Wkiom1m78xbzv35taad6skzomdm116.jpg-wh_50 "/>
The code above uses localhost to communicate with the native, without the need for a separate Python module called the shell command.
To this end, all of the project's host's memory, disk and other information are executed in a single script to get it all. The subsequent version is how to format the output, as well as the use of storage, in the browser display, or even the C/s architecture. Think of Ansible is not the integration of various resources of the birth.
This article is from the "12723827" blog, please be sure to keep this source http://jason83.blog.51cto.com/12723827/1965769
Build Python software Building series