Exemple #1
0
    def getData(self, options):
        """
        Method: getData

        Gets all information about all memory items

        @type options: dict
        @param options: passed options
        @rtype void
        @see dmidecode
        """

        # we are getting info from dmidecode module (some info which i see in dmidecode
        # are not present in dict...), and filter out results for memory type (17)
        # assign in key - value pair
        for hwinfo in dmidecode.memory().iteritems():
            if hwinfo[1]['dmi_type'] == 17 and type(hwinfo[1]['data']) == dict:
                tmpinfo = {}
                for iteminfo in hwinfo[1]['data'].iteritems():
                    p = re.compile('\s+')
                    key = p.sub('', iteminfo[0])
                    tmpinfo[key] = str(iteminfo[1])

                tmpinfo['toolindex'] = hwinfo[0]
                tmpinfo['handle'] = hwinfo[0]

                self.asset_info.append(tmpinfo)
Exemple #2
0
    def getData(self, options):
        """
        Method: getData

        Gets all information about all memory items

        @type options: dict
        @param options: passed options
        @rtype void
        @see dmidecode
        """

        # we are getting info from dmidecode module (some info which i see in dmidecode
        # are not present in dict...), and filter out results for memory type (17)
        # assign in key - value pair
        for hwinfo in dmidecode.memory().iteritems():
            if hwinfo[1]['dmi_type'] == 17 and type(hwinfo[1]['data']) == dict:
                tmpinfo = {}
                for iteminfo in hwinfo[1]['data'].iteritems():
                    p = re.compile('\s+')
                    key = p.sub('', iteminfo[0])
                    tmpinfo[key] = str(iteminfo[1])

                tmpinfo['toolindex'] = hwinfo[0]
                tmpinfo['handle'] = hwinfo[0]

                self.asset_info.append(tmpinfo)
Exemple #3
0
	def get_phys_mem_info(self):
		total = 0
		for mem in dmidecode.memory().values():
			if 'Form Factor' in mem['data']:
				if mem['data']['Form Factor'] in ['DIMM','SODIMM']:
					if 'Size' in mem['data'] and mem['data']['Size'] is not None:
						parts = mem['data']['Size'].split(' ')
						number = parts[0]
						unit = parts[1]

						# Store size in bytes
						if unit == 'KB' or unit == 'KiB':
							size = int(number) * 1024
						elif unit == 'MB' or unit == 'MiB':
							size = int(number) * 1048576
						elif unit == 'GB' or unit == 'GiB':
							size = int(number) * 1073741824
						elif unit == 'TB' or unit == 'TiB':
							size = int(number) * 1099511627776
						else:
							size = int(number)

						total = total + size

		return {'installed_ram': total}
Exemple #4
0
def meminfo():
    """
    内存信息
    返回格式:128MB * 1
    """
    mem = dmidecode.memory()
    memDict = {}
    for k, v in mem.iteritems():
        try:
            size = v['data']['Size']
            if size != None:
                if len(memDict) == 0:
                    memDict[size] = 1
                else:
                    if memDict.has_key(size):
                        count = memDict[size]
                        memDict[size] = sum([count, 1])
                    else:
                        memDict[size] = 1
        except:
            pass

    m = ""
    for k, v in memDict.iteritems():
        m = m + str(k).replace(" ", "") + "*" + str(v) + " "

    return m.strip().replace(" ", ",")
Exemple #5
0
def meminfo():
    """
    内存信息
    返回格式:128MB * 1
    """
    mem = dmidecode.memory()
    memDict = {}
    for k,v in mem.iteritems():
        try:
            size = v['data']['Size']
            if size != None:
                if len(memDict) == 0:
                    memDict[size] = 1
                else:
                    if memDict.has_key(size):
                        count = memDict[size] 
                        memDict[size] = sum([count,1])
                    else:
                        memDict[size] = 1
        except:
            pass
    
    m = ""
    for k,v in memDict.iteritems(): 
        m = m + str(k).replace(" ","") + "*" + str(v) + " "
            
    return m.strip().replace(" ",",")
Exemple #6
0
    def get_phys_mem_info(self):
        total = 0
        for mem in dmidecode.memory().values():
            if 'Form Factor' in mem['data']:
                if mem['data']['Form Factor'] in ['DIMM', 'SODIMM']:
                    if 'Size' in mem['data'] and mem['data'][
                            'Size'] is not None:
                        parts = mem['data']['Size'].split(' ')
                        number = parts[0]
                        unit = parts[1]

                        # Store size in bytes
                        if unit == 'KB' or unit == 'KiB':
                            size = int(number) * 1024
                        elif unit == 'MB' or unit == 'MiB':
                            size = int(number) * 1048576
                        elif unit == 'GB' or unit == 'GiB':
                            size = int(number) * 1073741824
                        elif unit == 'TB' or unit == 'TiB':
                            size = int(number) * 1099511627776
                        else:
                            size = int(number)

                        total = total + size

        return {'installed_ram': total}
Exemple #7
0
 def __init__ (self):
     if os.getuid():
         return
     try:
         import dmidecode
     except ImportError:
         return
 
     self._Slot = []
     for item in dmidecode.memory().values():
         if item['dmi_type'] == 17:
             info = {}
             info["Size"] = item['data']['Size'] if item['data']['Size'] else '0'
             info["Type"] = "%s" % item['data']['Type']
             info["Clock"] = item['data']['Speed']
             info["Width"] = (item['data']['Total Width'], item['data']['Data Width'])
             try:
                 info["Type"] += " (%s)" % ' '.join(
                                 s for s in item['data']['Type Detail'] if s)
             except TypeError:
                 pass
             self._Slot.append(info)
         elif item['dmi_type'] == 16:
             self._MaxCapacity = item['data']['Maximum Capacity']
             self._NumOfDev = item['data']['Number Of Devices']
Exemple #8
0
def getMemory():
    print_head('Memory Info')
    for v in dmidecode.memory().values():
        if type(v) == dict and v['dmi_type'] == 17:
            Memorydict["Locator"] = str((v['data']['Locator']))
            Memorydict["Serial Number"] = str((v['data']['Serial Number']))
            Memorydict["Manufacturer"] = str((v['data']['Manufacturer']))
            Memorydict["Size"] = str((v['data']['Size']))


            print "Memory Locator: %s" % Memorydict["Locator"] 
            print "Memory Serial Number: %s" % Memorydict["Serial Number"] 
            print "Memory Manufacturer: %s" % Memorydict["Manufacturer"] 
            print "Memory Size: %s" % Memorydict["Size"] 
Exemple #9
0
def GetSysinfo():
	SysDict = {}
	DriveDict= {}
	SysDict["MEMSize"] = 0
	for v in dmidecode.system().values():
		if type(v) == dict and v['dmi_type'] == 1:
            		SysDict["Mfg"] = str((v['data']['Manufacturer']))
			SysDict["Model"] = str((v['data']['Product Name']))
			SysDict["Serial"] = str((v['data']['Serial Number']))
	for x in dmidecode.processor().values():
		if type(x) == dict and x['dmi_type'] == 4:
			#SysDict["CPUMfg"] = str((x['data']['Manufacturer']))
			#SysDict["CPUFam"] = str((x['data']['Family']))
			#SysDict["CPUVer"] = str((x['data']['Version']))
			SysDict["CPUFrq"] = str((x['data']['Current Speed']))
	for x in dmidecode.memory().values():
                if type(x) == dict and x['dmi_type'] == 17:
                        #SysDict["MEMSize"] = str((x['data']['Size']))
                        SysDict["MEMType"] = str((x['data']['Type']))
                        #SysDict["MEMDeta"] = str((x['data']['Type Detail']))
                        SysDict["MEMSpeed"] = str((x['data']['Speed']))

	command = "grep \"model name\" /proc/cpuinfo | uniq | awk -F\" \" {' print $4 $5 \" \" $6 \" \" $8 '} | sed 's/(.\{1,2\})/ /g'"
        SysDict["CPUName"] = subprocess.check_output(command, shell=True).strip()
	command = "MSiz=0; for Size in $(dmidecode -t 17 | grep \"Size:\" | awk {' print $2 '}); do MSiz=$(($MSiz+$Size)); done; echo $MSiz"
        SysDict["MEMSize"] = subprocess.check_output(command, shell=True).strip()
	command = "dmidecode -t 17 | grep \"Type:\" | awk {' print $2 '} | uniq"
        SysDict["MEMType"] = subprocess.check_output(command, shell=True).strip()
	command = "lspci | grep VGA | awk -F: {' print $3 '}"
        SysDict["Video"] = subprocess.check_output(command, shell=True).strip()
	command = "lspci | grep Audio | awk -F: {' print $3 '}"
        SysDict["Audio"] = subprocess.check_output(command, shell=True).strip()
	command = "lspci | grep Ethernet | awk -F: {' print $3 '}"
        SysDict["Network"] = subprocess.check_output(command, shell=True).strip()

	### Read drive info from lshw -C disk
	command = "lshw -C disk"
	CMDOutput = subprocess.check_output(command, shell=True).strip()
	for line in CMDOutput:
		if "*-disk" in line:
			DiskMod = CMDOutput.stdout[line+2]
			DiskDev = CMDOutput.stdout[line+5]
			DiskSer = CMDOutput.stdout[line+7]
			DiskCap = CMDOutput.stdout[line+8]
			print(DiskMod+"\n")
			print(DiskDev+"\n")
			print(DiskSer+"\n")
			print(DiskCap+"\n")	

	return SysDict
Exemple #10
0
 def linux(self):
     mem_dict={}
     i=1
     for v in dmidecode.memory().values():
         if type(v) == dict and v['dmi_type'] == 17:
             slot = v['data']['Bank Locator']
             manufacturer = v['data']['Manufacturer']
             sn = v['data']['Serial Number']
             size = v['data']['Size']
             mtype = v['data']['Type']
             num = str(i)
             temp = {num:{'manufacture':manufacturer,'sn':sn,'slot':slot,'size':size,'mtype':mtype}}
             mem_dict = dict(mem_dict,**temp)
             i +=1
     mem_dict=dict(memory=mem_dict)
     return mem_dict
Exemple #11
0
    def retrieve(cls):
        ram_modules = []
        for key, value in dmidecode.memory().items():
            module = value['data']
            # exclude empty modules and System ROM (issue #5)
            is_module = (module.get('Size') not in [None, 'None'] and
                         module.get('Form Factor') not in [None, 'Chip'])
            if is_module:
                ram_modules.append(cls(
                    manufacturer=module.get('Manufacturer'),
                    serialNumber=module.get('Serial Number'),
                    size=module.get('Size'),
                    speed=module.get('Speed'),
                ))

        cls.totalSize = sum([module.size for module in ram_modules])
        
        return ram_modules
Exemple #12
0
    def mem_info(self, quantity=False, array=False, sticks=False, i=False):
        mem = []
        arraynum = 1
        memnum = 1
        if i != False:
            i = i-1
            data = {}
            for r in range(self.mem_info(quantity=True)):
                data['Memory Device %s'%(r+1)] = {}
            for h, v in enumerate(dmidecode.memory().values()):
                if v['dmi_type'] == 17: #Memory Device
                    data['Memory Device %s'%(h+1)]['Size'] = v['data']['Size']
                    data['Memory Device %s'%(h+1)]['Form Factor'] = v['data']['Form Factor']
                    data['Memory Device %s'%(h+1)]['Type'] = v['data']['Type']
                    data['Memory Device %s'%(h+1)]['Speed'] = v['data']['Speed']
                    data['Memory Device %s'%(h+1)]['Manufacturer'] = v['data']['Manufacturer']
                    data['Memory Device %s'%(h+1)]['Locator'] = v['data']['Locator']
                    data['Memory Device %s'%(h+1)]['Bank Locator'] = v['data']['Bank Locator']
                    data['Memory Device %s'%(h+1)]['Data Width'] = v['data']['Data Width']
                    data['Memory Device %s'%(h+1)]['Total Width'] = v['data']['Total Width']
                    data['Memory Device %s'%(h+1)]['Serial Number'] = v['data']['Serial Number']
                    data['Memory Device %s'%(h+1)]['Part Number'] = v['data']['Part Number']
                    #~ mem.append("Configured Clock Speed: %s" %(v['data']['Configured Clock Speed']))
                    #~ mem.append("Rank: %s" %(v['data']['Rank']))
                    data['Memory Device %s'%(h+1)]['Type Detail'] = v['data']['Type Detail']

            list_items = []
            for key in data['Memory Device %s'%(i+1)].keys():
                if key == "Type Detail":
                    list_items.append("Type Detail:")
                    for it in data['Memory Device %s'%(i+1)][key]:
                        if it != None:
                            list_items.append("    %s"%it)
                else:
                    if data['Memory Device %s'%(i+1)][key] != "":
                        list_items.append("%s : %s"%(key,data['Memory Device %s'%(i+1)][key]))

            return list_items

        if quantity:
            quantity = 0
            for v in dmidecode.memory().values():
                if v['dmi_type'] == 17 and not array: #Memory Device
                    quantity += 1
            return quantity

        for v in dmidecode.memory().values():
            if v['dmi_type'] == 16 and not sticks: #Physical Memory Array
                if arraynum > 1:
                    mem.append(" ")
                mem.append("Physical Memory Array %s" %arraynum)
                mem.append("Location: %s" %(v['data']['Location']))
                mem.append("Error Correction Type: %s" %(v['data']['Error Correction Type']))
                mem.append("Maximum Capacity: %s" %(v['data']['Maximum Capacity']))
                mem.append("Number Of Devices: %s" %(v['data']['Number Of Devices']))

                arraynum += 1
            if v['dmi_type'] == 17 and not array: #Memory Device
                if memnum > 1:
                    mem.append(" ")
                mem.append("Memory Device %s" %memnum)
                mem.append("Size: %s" %(v['data']['Size']))
                mem.append("Form Factor: %s" %(v['data']['Form Factor']))
                mem.append("Type: %s" %(v['data']['Type']))
                mem.append("Speed: %s" %(v['data']['Speed']))
                mem.append("Manufacturer: %s" %(v['data']['Manufacturer']))
                mem.append("Locator: %s" %(v['data']['Locator']))
                mem.append("Bank Locator: %s" %(v['data']['Bank Locator']))
                mem.append("Data Width: %s" %(v['data']['Data Width']))
                mem.append("Total Width: %s" %(v['data']['Total Width']))
                mem.append("Serial Number: %s" %(v['data']['Serial Number']))
                mem.append("Part Number: %s" %(v['data']['Part Number']))
                #~ mem.append("Configured Clock Speed: %s" %(v['data']['Configured Clock Speed']))
                #~ mem.append("Rank: %s" %(v['data']['Rank']))
                mem.append("Type Detail:")
                typedetail = []
                for x in v['data']['Type Detail']:
                    if not x == None:
                        typedetail.append(x)
                mem.append(typedetail)

                memnum += 1

        return mem
Exemple #13
0
    def _getdmi(self):
        from pprint import pprint
        DMI = { }


        # get BIOS Data
        #tmp = dmidecode.bios()
        #pprint(tmp)
        for v  in dmidecode.bios().values():
            if type(v) == dict and v['dmi_type'] == 0:
                DMI['bios',0,'BIOS Revision'] = str((v['data']['BIOS Revision']))
                DMI['bios',0,'ROM Size'] = str((v['data']['ROM Size']))
                try:
                    DMI['bios',0,'Release Date'] = str((v['data']['Relase Date']))
                except (KeyError):
                    DMI['bios',0,'Release Date'] = str((v['data']['Release Date']))

                DMI['bios',0,'Runtime Size'] = str((v['data']['Runtime Size']))
                DMI['bios',0,'Vendor'] = str((v['data']['Vendor']))
                DMI['bios',0,'Version'] = str((v['data']['Version']))

        # get System Data
        #tmp = dmidecode.system()
        #pprint(tmp)
        for v  in dmidecode.system().values():
            if type(v) == dict and v['dmi_type'] == 1:
                DMI['system',0,'Family'] = str((v['data']['Family']))
                DMI['system',0,'Manufacturer'] = str((v['data']['Manufacturer']))
                DMI['system',0,'Product Name'] = str((v['data']['Product Name']))
                DMI['system',0,'SKU Number'] = str((v['data']['SKU Number']))
                DMI['system',0,'Serial Number'] = str((v['data']['Serial Number']))
                DMI['system',0,'UUID'] = str((v['data']['UUID']))
                DMI['system',0,'Version'] = str((v['data']['Version']))
                DMI['system',0,'Wake-Up Type'] = str((v['data']['Wake-Up Type']))

        # get BaseBoard Data
        #tmp = dmidecode.baseboard()
        #pprint(tmp)
        for v  in dmidecode.baseboard().values():
            if type(v) == dict and v['dmi_type'] == 2:
                DMI['baseboard',0,'Manufacturer'] = str((v['data']['Manufacturer']))
                DMI['baseboard',0,'Product Name'] = str((v['data']['Product Name']))
                DMI['baseboard',0,'Serial Number'] = str((v['data']['Serial Number']))
                DMI['baseboard',0,'Version'] = str((v['data']['Version']))


        # get chassis Data
        #tmp = dmidecode.chassis()
        #pprint(tmp)
        for v  in dmidecode.chassis().values():
            if type(v) == dict and v['dmi_type'] == 3:
                DMI['chassis',0,'Asset Tag'] = str((v['data']['Asset Tag']))
                DMI['chassis',0,'Boot-Up State'] = str((v['data']['Boot-Up State']))
                DMI['chassis',0,'Lock'] = str((v['data']['Lock']))
                DMI['chassis',0,'Manufacturer'] = str((v['data']['Manufacturer']))
                DMI['chassis',0,'Power Supply State'] = str((v['data']['Power Supply State']))
                DMI['chassis',0,'Security Status'] = str((v['data']['Security Status']))
                DMI['chassis',0,'Serial Number'] = str((v['data']['Serial Number']))
                DMI['chassis',0,'Thermal State'] = str((v['data']['Thermal State']))
                DMI['chassis',0,'Type'] = str((v['data']['Type']))
                DMI['chassis',0,'Version'] = str((v['data']['Version']))

        # get Processor Data
        #tmp = dmidecode.processor()
        #pprint(tmp)
        i = 0
        for v  in dmidecode.processor().values():
            if type(v) == dict and v['dmi_type'] == 4:
                DMI['processor',i,'Asset Tag'] = str((v['data']['Asset Tag']))
                DMI['processor',i,'Characteristics'] = str((v['data']['Characteristics']))
                DMI['processor',i,'Core Count'] = str((v['data']['Core Count']))
                DMI['processor',i,'Core Enabled'] = str((v['data']['Core Enabled']))
                DMI['processor',i,'Current Speed'] =str((v['data']['Current Speed']))
                DMI['processor',i,'External Clock'] = str((v['data']['External Clock']))
                DMI['processor',i,'Family'] = str((v['data']['Family']))
                DMI['processor',i,'L1 Cache Handle'] = str((v['data']['L1 Cache Handle']))
                DMI['processor',i,'L2 Cache Handle'] = str((v['data']['L2 Cache Handle']))
                DMI['processor',i,'L3 Cache Handle'] = str((v['data']['L3 Cache Handle']))
                DMI['processor',i,'Manufacturer'] = str((v['data']['Manufacturer']['Vendor']))
                DMI['processor',i,'Max Speed'] = str((v['data']['Max Speed']))
                DMI['processor',i,'Part Number'] = str((v['data']['Part Number']))
                DMI['processor',i,'Serial Number'] = str((v['data']['Serial Number']))
                DMI['processor',i,'Socket Designation'] = str((v['data']['Socket Designation']))
                DMI['processor',i,'Status'] = str((v['data']['Status']))
                DMI['processor',i,'Thread Count'] = str((v['data']['Thread Count']))
                DMI['processor',i,'Type'] = str((v['data']['Type']))
                DMI['processor',i,'Upgrade'] = str((v['data']['Upgrade']))
                DMI['processor',i,'Version'] = str((v['data']['Version']))
                DMI['processor',i,'Voltage'] = str((v['data']['Voltage']))
                i += 1


        # get Memory Data
        #tmp = dmidecode.memory()
        #pprint(tmp)
        i = 0
        for v  in dmidecode.memory().values():
            if type(v) == dict and v['dmi_type'] == 17 :
                if str((v['data']['Size'])) != 'None':
                    DMI['memory',i,'Data Width'] = str((v['data']['Data Width']))
                    DMI['memory',i,'Error Information Handle'] = str((v['data']['Error Information Handle']))
                    DMI['memory',i,'Form Factor'] = str((v['data']['Form Factor']))
                    DMI['memory',i,'Bank Locator'] = str((v['data']['Bank Locator']))
                    DMI['memory',i,'Locator'] = str((v['data']['Locator']))
                    DMI['memory',i,'Manufacturer'] = str((v['data']['Manufacturer']))
                    DMI['memory',i,'Part Number'] = str((v['data']['Part Number']))
                    DMI['memory',i,'Serial Number'] = str((v['data']['Serial Number']))
                    DMI['memory',i,'Size'] = str((v['data']['Size']))
                    DMI['memory',i,'Speed'] = str((v['data']['Speed']))
                    DMI['memory',i,'Type'] = str((v['data']['Type']))
                    i += 1

        # get cache Data
        #tmp = dmidecode.cache()
        #pprint(tmp)

        # get connector Data
        #tmp = dmidecode.connector()
        #pprint(tmp)

        # get slot Data
        #tmp = dmidecode.slot()
        #pprint(tmp)

        return DMI
Exemple #14
0
#!/usr/bin/env python
#_*_ coding:utf-8 _*_
'''
Created on '2017/9/21 18:10'
Email: [email protected]
@author: Redheat
'''
import dmidecode
import netifaces
info = dmidecode.system()  #SN,服务器型号
info_keys = info.keys()
dmidecode.memory()  #内存信息
dmidecode.processor()  #处理器信息

for i in range(len(info_keys)):
    if info[info_keys[i]]['dmi_type'] == 1:
        print info[info_keys[i]]['data']['Manufacturer']
        print info[info_keys[i]]['data']['Product Name']

netifaces.interfaces()
netifaces.ifaddresses('eno1')  #IP信息
Exemple #15
0
	def __init__(self):
		#Get all required system info
		for v in dmidecode.system().values():
                	if type(v) == dict and v['dmi_type'] == 1:
                        	self.Mfg = str((v['data']['Manufacturer']))
                        	self.Model = str((v['data']['Product Name']))
                        	self.Serial = str((v['data']['Serial Number']))
		for x in dmidecode.chassis().values():
                        if type(x) == dict and x['dmi_type'] == 3:
				self.FFactor = str((x['data']['Type']))
        	for x in dmidecode.processor().values():
                	if type(x) == dict and x['dmi_type'] == 4:
                        	self.CPUMfg = str((x['data']['Manufacturer']))
                        	self.CPUFam = str((x['data']['Family']))
                        	self.CPUVer = str((x['data']['Version']))
                        	self.CPUFrq = str((x['data']['Current Speed']))
        	for x in dmidecode.memory().values():
                	if type(x) == dict and x['dmi_type'] == 17:
                        	self.MEMSize = str((x['data']['Size']))
                        	self.MEMType = str((x['data']['Type']))
                        	self.MEMDeta = str((x['data']['Type Detail']))
                        	self.MEMSpeed = str((x['data']['Speed']))
		for x in dmidecode.baseboard().values():
                        if type(x) == dict and x['dmi_type'] == 10:
				if str((x['data']['dmi_on_board_devices'][0]['Type'])) == "Video":
					self.Video = str((x['data']['dmi_on_board_devices'][0]['Description']))
				if str((x['data']['dmi_on_board_devices'][0]['Type'])) == "Sound":
                                        self.Audio = str((x['data']['dmi_on_board_devices'][0]['Description']))
				if str((x['data']['dmi_on_board_devices'][0]['Type'])) == "Ethernet":
                                        self.Network = str((x['data']['dmi_on_board_devices'][0]['Description'])) 
		### Workarounds for things python-dmidecode doesn't do
        	command = "grep \"model name\" /proc/cpuinfo | uniq | awk -F\" \" {' print $4 $5 \" \" $6 \" \" $8 '} | sed 's/(.\{1,2\})/ /g'"
	        self.CPUName = subprocess.check_output(command, shell=True).strip()
	        command = "MSiz=0; for Size in $(dmidecode -t 17 | grep \"Size:\" | awk {' print $2 '}); do MSiz=$(($MSiz+$Size)); done; echo $MSiz"
	        self.MEMSize = subprocess.check_output(command, shell=True).strip()
	        command = "dmidecode -t 17 | grep \"Type:\" | awk {' print $2 '} | uniq"
	        self.MEMType = subprocess.check_output(command, shell=True).strip()
		if self.Video is None:
	        	command = "lspci | grep VGA | awk -F: {' print $3 '}"
	        	self.Video = subprocess.check_output(command, shell=True).strip()
		if self.Audio is None:
	        	command = "lspci | grep Audio | awk -F: {' print $3 '}"
	        	self.Audio = subprocess.check_output(command, shell=True).strip()
		if self.Network is None:
	        	command = "lspci | grep Ethernet | awk -F: {' print $3 '}"
	        	self.Network = subprocess.check_output(command, shell=True).strip()
		command = "lspci | grep 802.11 | awk -F: {' print $3 '}"
                self.WiFi = subprocess.check_output(command, shell=True).strip()
		command = "echo \"Not Yet Implemented\""
                self.Battery = subprocess.check_output(command, shell=True).strip()
		### Get hard drive info
		self.Drive = []
		command = "lshw -C disk"
		CMDOutput = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
		Type = None
		Model = None
		Vendor = None
		Device = None
		Serial = None
		Size = 0
		SectSize = 0
		for line in CMDOutput.stdout:
			if "*-" in line:
				#print("Found: "+line)
				Line = line.split('-', 1)
				Type = Line[1].strip()
			if "product:" in line:
				#print("Found: "+line)
				Line = line.split(':', 1)
				Model = Line[1].strip()
			if "vendor:" in line:
				#print("Found: "+line)
				Line = line.split(':', 1)
				Vendor = Line[1].strip()
			if "logical name:" in line:
				#print("Found: "+line)
				Line = line.split(':', 1)
				Device = Line[1].strip()
			if "serial:" in line:
				#print("Found: "+line)
				Line = line.split(':', 1)
				Serial = Line[1].strip()
			if "size:" in line:
				command = "fdisk -l /dev/sda | grep \""+Device+":\" | awk {' print $5 '}"
				Size = subprocess.check_output(command, shell=True).strip()
				#print("Size: "+Size)
				command = "fdisk -l /dev/sda | grep \"Sector\" | awk {' print $4 '}"
				SectSize = subprocess.check_output(command, shell=True).strip()
				#print("SectSize: "+SectSize)
			if "configuration:" in line:
				Dev = Device.split('/', 2)
				if (Type == "cdrom"):
					self.Optical = Vendor+" "+Model
				else:
					if Vendor is None:
						Line = Model.split(' ', 1)
						Vendor = Line[0].strip()
						Model = Line[1].strip()
					self.Drive.append(self.Disk(Type, Model, Vendor, Device, Serial, Size, SectSize))
				Type = None
				Model = None
				Vendor = None
				Device = None
				Serial = None
				Size = 0
				SectSize = 0
Exemple #16
0
#. This does not print any decoded info.  If the call fails, either a warning will
#. be issued or an exception will be raised.  This test is now only used to check
#. for presence of the legacy API, which "under the hood" uses
#. dmidecode.QuerySection(name), where name can be 'bios', 'system', etc.
if root_user:
        print("*** bios ***\n");      dmidecode.bios()
        print_warnings()
        print("*** system ***\n");    dmidecode.system()
        print_warnings()
        print("*** baseboard ***\n"); dmidecode.baseboard()
        print_warnings()
        print("*** chassis ***\n");   dmidecode.chassis()
        print_warnings()
        print("*** processor ***\n"); dmidecode.processor()
        print_warnings()
        print("*** memory ***\n");    dmidecode.memory()
        print_warnings()
        print("*** cache ***\n");     dmidecode.cache()
        print_warnings()
        print("*** connector ***\n"); dmidecode.connector()
        print_warnings()
        print("*** slot ***\n");      dmidecode.slot()
        print_warnings()


#. Now test get/set of memory device file...
print("*** get_dev()")
print(dmidecode.get_dev())
print_warnings()
print("*** set_dev('dmidata.dump')")
print(dmidecode.set_dev("dmidata.dump"));
Exemple #17
0
""" Report the capacity of each stick of installed memory. Must be run as root
or with sudo.
"""

# python-dmidecode is in debian and RedHat distros
import dmidecode
import os
import sys

if os.geteuid() != 0:

    sys.stderr.write(__doc__)
    # by continuing here, we get to keep the nice warnings that the dmidecode
    # library produces.

m = dmidecode.memory()

count = 0
for x in m.iteritems():
    size = None
    try:
        size = x[1]['data']['Size']
        count += 1
    except KeyError:
        pass
    if size is None:
        pass
    else:
        print (size)
print('{} sticks in total.'.format(count))
Exemple #18
0
    def _getdmi(self):
        from pprint import pprint
        DMI = {}

        # get BIOS Data
        #tmp = dmidecode.bios()
        #pprint(tmp)
        for v in dmidecode.bios().values():
            if type(v) == dict and v['dmi_type'] == 0:
                DMI['bios', 0, 'BIOS Revision'] = str(
                    (v['data']['BIOS Revision']))
                DMI['bios', 0, 'ROM Size'] = str((v['data']['ROM Size']))
                try:
                    DMI['bios', 0, 'Release Date'] = str(
                        (v['data']['Relase Date']))
                except (KeyError):
                    DMI['bios', 0, 'Release Date'] = str(
                        (v['data']['Release Date']))

                DMI['bios', 0, 'Runtime Size'] = str(
                    (v['data']['Runtime Size']))
                DMI['bios', 0, 'Vendor'] = str((v['data']['Vendor']))
                DMI['bios', 0, 'Version'] = str((v['data']['Version']))

        # get System Data
        #tmp = dmidecode.system()
        #pprint(tmp)
        for v in dmidecode.system().values():
            if type(v) == dict and v['dmi_type'] == 1:
                DMI['system', 0, 'Family'] = str((v['data']['Family']))
                DMI['system', 0, 'Manufacturer'] = str(
                    (v['data']['Manufacturer']))
                DMI['system', 0, 'Product Name'] = str(
                    (v['data']['Product Name']))
                DMI['system', 0, 'SKU Number'] = str((v['data']['SKU Number']))
                DMI['system', 0, 'Serial Number'] = str(
                    (v['data']['Serial Number']))
                DMI['system', 0, 'UUID'] = str((v['data']['UUID']))
                DMI['system', 0, 'Version'] = str((v['data']['Version']))
                DMI['system', 0, 'Wake-Up Type'] = str(
                    (v['data']['Wake-Up Type']))

        # get BaseBoard Data
        #tmp = dmidecode.baseboard()
        #pprint(tmp)
        for v in dmidecode.baseboard().values():
            if type(v) == dict and v['dmi_type'] == 2:
                DMI['baseboard', 0, 'Manufacturer'] = str(
                    (v['data']['Manufacturer']))
                DMI['baseboard', 0, 'Product Name'] = str(
                    (v['data']['Product Name']))
                DMI['baseboard', 0, 'Serial Number'] = str(
                    (v['data']['Serial Number']))
                DMI['baseboard', 0, 'Version'] = str((v['data']['Version']))

        # get chassis Data
        #tmp = dmidecode.chassis()
        #pprint(tmp)
        for v in dmidecode.chassis().values():
            if type(v) == dict and v['dmi_type'] == 3:
                DMI['chassis', 0, 'Asset Tag'] = str((v['data']['Asset Tag']))
                DMI['chassis', 0, 'Boot-Up State'] = str(
                    (v['data']['Boot-Up State']))
                DMI['chassis', 0, 'Lock'] = str((v['data']['Lock']))
                DMI['chassis', 0, 'Manufacturer'] = str(
                    (v['data']['Manufacturer']))
                DMI['chassis', 0, 'Power Supply State'] = str(
                    (v['data']['Power Supply State']))
                DMI['chassis', 0, 'Security Status'] = str(
                    (v['data']['Security Status']))
                DMI['chassis', 0, 'Serial Number'] = str(
                    (v['data']['Serial Number']))
                DMI['chassis', 0, 'Thermal State'] = str(
                    (v['data']['Thermal State']))
                DMI['chassis', 0, 'Type'] = str((v['data']['Type']))
                DMI['chassis', 0, 'Version'] = str((v['data']['Version']))

        # get Processor Data
        #tmp = dmidecode.processor()
        #pprint(tmp)
        i = 0
        for v in dmidecode.processor().values():
            if type(v) == dict and v['dmi_type'] == 4:
                DMI['processor', i, 'Asset Tag'] = str(
                    (v['data']['Asset Tag']))
                DMI['processor', i, 'Characteristics'] = str(
                    (v['data']['Characteristics']))
                DMI['processor', i, 'Core Count'] = str(
                    (v['data']['Core Count']))
                DMI['processor', i, 'Core Enabled'] = str(
                    (v['data']['Core Enabled']))
                DMI['processor', i, 'Current Speed'] = str(
                    (v['data']['Current Speed']))
                DMI['processor', i, 'External Clock'] = str(
                    (v['data']['External Clock']))
                DMI['processor', i, 'Family'] = str((v['data']['Family']))
                DMI['processor', i, 'L1 Cache Handle'] = str(
                    (v['data']['L1 Cache Handle']))
                DMI['processor', i, 'L2 Cache Handle'] = str(
                    (v['data']['L2 Cache Handle']))
                DMI['processor', i, 'L3 Cache Handle'] = str(
                    (v['data']['L3 Cache Handle']))
                DMI['processor', i, 'Manufacturer'] = str(
                    (v['data']['Manufacturer']['Vendor']))
                DMI['processor', i, 'Max Speed'] = str(
                    (v['data']['Max Speed']))
                DMI['processor', i, 'Part Number'] = str(
                    (v['data']['Part Number']))
                DMI['processor', i, 'Serial Number'] = str(
                    (v['data']['Serial Number']))
                DMI['processor', i, 'Socket Designation'] = str(
                    (v['data']['Socket Designation']))
                DMI['processor', i, 'Status'] = str((v['data']['Status']))
                DMI['processor', i, 'Thread Count'] = str(
                    (v['data']['Thread Count']))
                DMI['processor', i, 'Type'] = str((v['data']['Type']))
                DMI['processor', i, 'Upgrade'] = str((v['data']['Upgrade']))
                DMI['processor', i, 'Version'] = str((v['data']['Version']))
                DMI['processor', i, 'Voltage'] = str((v['data']['Voltage']))
                i += 1

        # get Memory Data
        #tmp = dmidecode.memory()
        #pprint(tmp)
        i = 0
        for v in dmidecode.memory().values():
            if type(v) == dict and v['dmi_type'] == 17:
                if str((v['data']['Size'])) != 'None':
                    DMI['memory', i, 'Data Width'] = str(
                        (v['data']['Data Width']))
                    DMI['memory', i, 'Error Information Handle'] = str(
                        (v['data']['Error Information Handle']))
                    DMI['memory', i, 'Form Factor'] = str(
                        (v['data']['Form Factor']))
                    DMI['memory', i, 'Bank Locator'] = str(
                        (v['data']['Bank Locator']))
                    DMI['memory', i, 'Locator'] = str((v['data']['Locator']))
                    DMI['memory', i, 'Manufacturer'] = str(
                        (v['data']['Manufacturer']))
                    DMI['memory', i, 'Part Number'] = str(
                        (v['data']['Part Number']))
                    DMI['memory', i, 'Serial Number'] = str(
                        (v['data']['Serial Number']))
                    DMI['memory', i, 'Size'] = str((v['data']['Size']))
                    DMI['memory', i, 'Speed'] = str((v['data']['Speed']))
                    DMI['memory', i, 'Type'] = str((v['data']['Type']))
                    i += 1

        # get cache Data
        #tmp = dmidecode.cache()
        #pprint(tmp)

        # get connector Data
        #tmp = dmidecode.connector()
        #pprint(tmp)

        # get slot Data
        #tmp = dmidecode.slot()
        #pprint(tmp)

        return DMI