Three ways to implement DAY73-CMDB (Asset Management acquisition)

Source: Internet
Author: User
Tags saltstack

#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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.