欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

python如何獲取服務(wù)器硬件信息

 更新時(shí)間:2017年05月11日 08:35:24   作者:zhangjpn  
這篇文章主要為大家詳細(xì)介紹了python獲取服務(wù)器硬件信息的相關(guān)代碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了Android九宮格圖片展示的具體代碼,供大家參考,具體內(nèi)容如下

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import rlcompleter, readline
readline.parse_and_bind('tab: complete')
import dmidecode
import  time
import  os
import  re
system=dmidecode.system()
print "\033[1;36;40m%s\033[0m" %"獲取服務(wù)器硬件信息"
for x,y in system.items():
for i in y['data'].items():
if i[0] == 'Product Name':
print "\033[1;31;40m%s\033[0m" % "-"*10
print 'Server models: %s' %i[1]  
print i
 
print "\033[1;36;40m%s\033[0m" % "獲取服務(wù)器CPU信息"
for x,y in dmidecode.processor().items():
  for m,n in y.items():
  if m=='data':
print "\033[1;31;40m%s\033[0m" % "-"*10
  for x,y in n.items():
    print x,y
print "\033[1;36;40m%s\033[0m" %"獲取服務(wù)器BIOS信息"
for x,y in dmidecode.bios().items():
for m,n in y['data'].items():
  if m.find('Characteristic')!=-1:
    for x,y in n.items():
    print "\033[1;34;40m%s\033[0m" % "-"*10
    print x,y
  else:
    print "\033[1;32;40m%s\033[0m" % "-"*10
    print m,n
print "\033[1;36;40m%s\033[0m" %"獲取服務(wù)器內(nèi)存信息"
for x,y in dmidecode.memory().items():
  for m,n in y['data'].items():
    print "\033[1;34;40m%s\033[0m" % "-"*10
    print m,n
#便于調(diào)試,可以刪除
print "x"*50
print "\033[1;36;40m%s\033[0m" %"獲取服務(wù)器主板信息"
for x,y in dmidecode.baseboard().items():
  #print x,y
  for m,n in y['data'].items():
    print "\033[1;34;40m%s\033[0m" % "-"*10
    print m,n
print "\033[1;36;40m%s\033[0m" %"獲取服務(wù)器主板插槽信息"
for x,y in dmidecode.slot().items():
  for m,n in y['data'].items():
    print "\033[1;34;40m%s\033[0m" % "-"*10
    print m,n
print "\033[1;36;40m%s\033[0m" %"獲取服務(wù)器網(wǎng)卡信息"
"""
安裝linux硬件信息收集工具包
  """
#os.system('yum -y install make wget gcc* ;wget http://ezix.org/software/files/lshw-B.02.14.tar.gz ; tar -zxvf lshw-B.02.14
.tar.gz ;cd lshw-B.02.14 ; make && make install ; cd .. ; rm -rf lshw-B.02.14* ')
netcard=os.popen('lshw -C network  ').read( )
print "產(chǎn)品名稱: %s"     % re.findall('product:.+(?#測(cè)試)',netcard)[0]
print "網(wǎng)卡速度: %s"     % re.findall('size:.+(?#測(cè)試)',netcard)[0]
n=len(re.findall('\*-network:',netcard))
if n==0:
  print "網(wǎng)卡IP地址: %s"     %re.findall('ip=\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}',netcard)[0] 
else:
  for i in range(0,n):
     try:
      print "網(wǎng)卡IP地址: %s" %re.findall('ip=\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}',netcard)[i]
    except IndexError:
      i+=1
      print "第%s塊網(wǎng)卡沒有IP地址" %i 
#print "網(wǎng)卡IP地址: %s"    % re.findall('ip=\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}',netcard)[0]
print "網(wǎng)卡狀態(tài): %s "    % re.findall('link=\w{3}(?#測(cè)試)',netcard)[0]
print "網(wǎng)卡MAC地址: %s "   % re.findall('serial:.+(?#測(cè)試)',netcard)[0]
print "網(wǎng)卡廠家: %s "    % re.findall('vendor:.+(?#測(cè)試)',netcard)[0]
print "網(wǎng)絡(luò)接口名稱: %s"   % re.findall('logical name:.+(?#測(cè)試)',netcard)[0]
"""
獲取系統(tǒng)信息
"""
print "\033[1;36;40m%s\033[0m" %"獲取服務(wù)器操作系統(tǒng)信息"
import platform
print "系統(tǒng)cpu位數(shù): %s " % platform.processor()
print "系統(tǒng)信息: %s "   % platform.system()
print "操作系統(tǒng)類型: %s" % platform.dist()[0]
print "系統(tǒng)主機(jī)名: %s "  % platform.node()

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論