国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

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

2020-01-04 17:09:28
字體:
供稿:網(wǎng)友

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

#!/usr/bin/env python# -*- coding: utf-8 -*-import rlcompleter, readlinereadline.parse_and_bind('tab: complete')import dmidecodeimport  timeimport  osimport  resystem=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" % "-"*10print '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,yprint "/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,nprint "/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"*50print "/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,nprint "/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,nprint "/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:.+(?#測試)',netcard)[0]print "網(wǎng)卡速度: %s"     % re.findall('size:.+(?#測試)',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}(?#測試)',netcard)[0]print "網(wǎng)卡MAC地址: %s "   % re.findall('serial:.+(?#測試)',netcard)[0]print "網(wǎng)卡廠家: %s "    % re.findall('vendor:.+(?#測試)',netcard)[0]print "網(wǎng)絡(luò)接口名稱: %s"   % re.findall('logical name:.+(?#測試)',netcard)[0]"""獲取系統(tǒng)信息"""print "/033[1;36;40m%s/033[0m" %"獲取服務(wù)器操作系統(tǒng)信息"import platformprint "系統(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()

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持VEVB武林網(wǎng)。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 天峨县| 张家界市| 玛多县| 宜川县| 平邑县| 牟定县| 温州市| 祁阳县| 枝江市| 昆明市| 多伦县| 禹城市| 开江县| 藁城市| 苗栗市| 富川| 乐都县| 邵阳县| 文水县| 广德县| 太仓市| 阳信县| 江永县| 普安县| 郁南县| 宜宾市| 高台县| 新巴尔虎左旗| 泾阳县| 建始县| 喀什市| 曲阳县| 濉溪县| 灵寿县| 乐业县| 喀喇沁旗| 奎屯市| 井冈山市| 桐梓县| 龙游县| 葵青区|