CMDB Project
Demand:
1.ip Address
2.mac Address
3.
1. View basic Linux hardware information
1. View CPU Cat/proc/cpuinfo
(1) Processor: A unique identifier that includes this logical processor.
(2) Physical ID: includes a unique identifier for each physical package.
(3) Core ID: holds a unique identifier for each core.
(4) Siblings: Lists the number of logical processors in the same physical package.
(5) CPU cores: Contains the number of cores in the same physical package.
(6) If the processor is an Intel processor, the string in the vendor ID entry is Genuineintel.
(9) Model NAME:CPU models
2. Number of logical CPUs
Cat/proc/cpuinfo | grep ' Processor ' | Wc-l
3. Number of physical CPUs (CPU slots)
Cat/proc/cpuinfo | grep ' Physical ID ' | Sort | Uniq | Wc-l
3. See if the CPU supports 64bit
Cat/proc/cpuinfo | grep Flags | grep ' LM ' | Wc-l
Results greater than 0, indicating support for 64bit computing
4. View the CPU model
Cat/proc/cpuinfo | grep ' model name ' | Awk-f ': ' {print $} '
5.ip Address:
6.mac Address:
2.python
1. Modules used
Commands
Commands.getstatusoutput (CMD) returns two elements (status, results);
Commands.getoutput (cmd) returns results
Urllib
Urllib.urlopen (Url,date,proxies,context)
Urllib2
The URLLIB2 module defines features and classes that facilitate the opening of URLs (primarily HTTP) in a complex world-basic and Digest authentication, redirection, cookies, etc.
Urllib2.urlopen (Url,data,timeout)
Paramiko
What do the delegates mean?
def __xxx (self):
def _xxx (self):
Hasattr (object, name) built-in function
The arguments is an object and a string. The result is True if the string is the name of the one of the object ' s attributes, False if not. (This was implemented by calling GetAttr (object, name) and seeing whether it raises a attributeerror or not.)
GetAttr (object, name[, default])
Return the value of the named attribute of object. Name must is a string. The If the string is the name of the one of the object ' s attributes, and the result is the value of this attribute. For example, GetAttr (x, ' Foobar ') are equivalent to X.foobar. If the named attribute does not exist, the default is returned if provided, and otherwise attributeerror is raised.
2.data={}
{' CPU ': {' cpumodename ': ' Intel (R) Core (TM) i5-5200u CPU @ 2.20GHz ', ' processor ': ' 1 '}, ' hostname ': ' Kevin ', ' asset ': {' Wak ' e-up Type ': ' Power Switch ', ' UUID ': ' e4144d56-8399-ae0e-f1d1-5c01911b965c ', ' Serial number ': ' VMware-56 4d e4 0e AE-F1 D1 5c 1b 5c ', ' manufacturer ': ' VMware, Inc. ', ' Product Name ': ' VMware Virtual Platform '}, ' network ': {' maca DD ': ' 00:0c:29:1b:96:5c ', ' netmask ': ' 255.255.255.0 ', ' IP ': ' 10.1.6.153 ', ' Gateway ': ' 10.1.6.255 '}}
3. Name = models. Charfield (max_length=64, Unique=true)
SN = models. Charfield (max_length=64, Unique=true)
Network = models. Genericipaddressfield (Null=true, Blank=true)
#asset = models. Onetoonefield (' Asset ')
IP = models. Genericipaddressfield (Null=true, Blank=true)
Mac = models. Charfield (MAX_LENGTH=50)
hostname = models. Charfield (MAX_LENGTH=50)
Processor=models. Booleanfield (default = 5)
Physicalid=models. Booleanfield (default = 5)
#是否支持64位
Support=models. Booleanfield (default = 5)
Models_name=models. Charfield (MAX_LENGTH=50)
3.myql
IP address, MAC address,
CPU--Number of CPUs, CPU slots, see if CPU supports 64bit, view CPU model ...
4.Client send data to determine whether the same as the previous data?
5. Problems encountered:
1.django Erro
2. A piece of data from the client, how to determine whether it is Updata or Create??
A: New insert: Through the analysis of other people's Code over and over again, others switch ideas, create a new asset approval library in MySQL, and then insert the new data into the library .... Pending processing
When a piece of data is transmitted, determine whether the data has the same SN, if there is an update, none is new, and then create in the new asset approval library, and then in the management staff on the Web page to confirm.
3. Flowchart: https://www.processon.com/view/link/59b54c84e4b00e6de914c04a
CMDB Project 1