#Collect DataImportsubprocessImportRequestsret= Subprocess.getoutput ('ipconfig')#print (ret)#regular processing Gets the data you wantData_dict = { 'Nic':{}, 'Disk':{}, 'Mem':{},}#Send Datareq = Requests.post ('https://www.cnblogs.com/wupeiqi/articles/6192986.html', Data=data_dict)Print(Req.text)
1.Agent Mode
#based on Paramikko module, PIP3 install Paramiko#get the host name that is not capturedImportRequestsImportParamikoret= Requests.get ('https://www.cnblogs.com/wupeiqi/articles/6192986.html')#to link a remote server via Paramikko, execute the command#To create an SSH objectSSH =Paramiko. Sshclient ()#allow links to hosts that are not in the Know_hosts fileSsh.connect (hostname='XXX', port=8080,username='XXX', password='XXX')#Execute CommandStdin,stdout,stderr = Ssh.exec_command ('ipconfig')#Get command Resultsres =Stdout.read ()#Close LinkSsh.close ()
2.SSH class Mode
#1. Installing Saltstack#url:https://repo.saltstack.com/#windows#commend:alt-minion-2018.3.0-py2-amd64-setup.exe/s/master=yoursaltmaster/minion-name=yourminionname#Master Preparation:#A. configuration file, listening to native IP#Vim/etx/salt/master#interface: Native IP address#B. Start Master#/etc/init.d/salt-master Start#Slave Preparation:#A. configuration file, which master to connect to#vim/etc/salt/minion#Master: Remote Master Address#b. Start slave#/etc/init.d/salt-minion Start#1. Create a relationship#Master:#Accepted Keys#Denied Keys#unaccepted Keys#c1.com#c2.com#rejected Keys#2. Acceptance of the relationship#3. Execution of Commands#Master:#Salt * cmd.run "ifconfig"#Import Salt.client#local = salt.client.localClient ()#result = Local.cmd (' * ', ' cmd.run ', {' ifconfig '})
3.SaltStack
Three ways to implement DAY73-CMDB (Asset Management acquisition)