CMDB is the foundation of operation and maintenance automation, it provides interface function for the operation and maintenance System (ELK,ZABBIX,OPEN-FALCON), such as log system, publishing system, monitoring system, etc.
The first way: Agent method Implementation, the agent can not directly access the database, because the agent can be compromised, after the invasion, hackers can obtain database permissions, resulting in the deletion of the library and other losses, so you have to use the URL method
Of course subprocess cannot be used for CMDB data acquisition because this module is typically used for native
>>> Import subprocess
>>> subprocess.getoutput (' ipconfig ')
' \nwindows IP configuration \n\n\n Wireless LAN Adapter wireless network connection 2:\n\n Media status ....
. . . . . . . . : The media has disconnected \ nthe connection specific DNS suffix .......:\n\n Ethernet
Adapter Bluetooth Network connection: \ n \ nthe media status ............: media is disconnected \
N connection-specific DNS suffix .......:\n\n Ethernet Adapter local connection: \ n \ nthe media-like
State ............: media has disconnected \ nthe connection-specific DNS suffix .....:
\ n \ nthe Wireless LAN adapter wireless network connection: \ n \ nthe connection to a specific DNS suffix ....: \ n
Local Link IPV6 address ... : fe80::e4c6:c03b:e89:a02%11\n IPv4 Address
............:192.168.1.100\n Subnet Mask ............:
255.255.255.0\n Default gateway ............. : 192.168.1.1\n\n Ethernet Adapter
VMware Network Adapter vmnet1:\n\n Connection-specific DNS suffix ...: \ n
Local Link IPV6 address ... : fe80::486e:2200:8997:bcdb%18\n IPv4 Address
............:192.168.65.1\n Subnet Mask ............:2
55.255.255.0\n Default gateway ............. : \ n \ nthe Ethernet Adapter VMware Net
Work Adapter vmnet8:\n\n connection specific DNS suffix ...: \ n Local Link IPv
6 address ..... : fe80::d 851:ee0a:c90a:db52%19\n IPv4 address ....
....: 192.168.117.1\n Subnet Mask ............:255.255.255.0
\ nthe default gateway ............. : \ n \ nthe tunnel adapter isatap.localdomain:\n\n
Media status ............: Media has been disconnected \ nthe connection specific DNS suffix ....
...: \ n \ nthe tunnel adapter ISATAP. {7f17396e-53db-47a4-bd5c-9eaddc5e9fac}:\n\n Media
Body state ............: Media has been disconnected \ nthe connection specific DNS suffix ...
. : \ n \ nthe tunnel adapter Teredo tunneling pseudo-interface:\n\n Connection-specific DNS suffix
....: \ n IPv6 Address ............:2001:0:9d38:6ab8:2882:
ac2:49ed:92f9\n Local link IPv6 address ... : fe80::2882:ac2:49ed:92f9%1
4\n Default gateway ............. ::: \ n \ nthe tunnel adapter ISATAP. {5200d41d-66db
-404b-b054-927048c61572}:\n\n Media status ............: media disconnected \ n
Connect a specific DNS suffix .......:\n\n tunnel adapter isatap. {24e33a31-e0fb-45ff
-b380-39ad751e3a09}:\n\n Media status ............: media is disconnected \ n
The specific DNS suffix .......:\n\n tunnel adapter isatap. {28CBEECB-4F9E-4214-B9CA
-e42439ecc9d4}:\n\n Media status ............: media disconnected \ n Connection Special
DNS suffix .....: '
>>>
>>> Import Requests>>> requests. Get ('http://www.cnblogs.com/wupeiqi/articles/6192986.html') #也可以是POST请求< Response []>>>> ret = requests. Get ('http://www.cnblogs.com/wupeiqi/articles/6192986.html')
>>> ret.text# renders the entire page, which is equivalent to a string
The second way: with the implementation of SSH, with the central control machine to collect assets, the middle part is the central control machine
Many operations tools are packaged in Python-based Paramiko modules, such as Fabric,ansible,saltstack, and the latest ansible is implemented in another way
Third Way: Rely on third-party tools Fabric,ansible,saltstack
Take Saltstack as an example, you can execute commands remotely on Saltstack-master and then use RPC to capture assets
The essence of RPC is to maintain a queue
RPC Way faster than SSH
The fourth way: based on the Puppet method of collection:
Use the first three ways: Change the configuration file to achieve the first three ways of switching (the first three must be, the fourth kind of understanding)
General settings collect data once a day
The CMDB to solve is to automatically collect
CMDB Configuration Resource Management database (understanding)