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

首頁 > 編程 > Python > 正文

python如何獲取服務器硬件信息

2019-11-25 16:11:17
字體:
來源:轉載
供稿:網友

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

#!/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" %"獲取服務器硬件信息"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" % "獲取服務器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" %"獲取服務器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" %"獲取服務器內存信息"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#便于調試,可以刪除print "x"*50print "/033[1;36;40m%s/033[0m" %"獲取服務器主板信息"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" %"獲取服務器主板插槽信息"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" %"獲取服務器網卡信息""""安裝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 "產品名稱: %s"     % re.findall('product:.+(?#測試)',netcard)[0]print "網卡速度: %s"     % re.findall('size:.+(?#測試)',netcard)[0]n=len(re.findall('/*-network:',netcard))if n==0:  print "網卡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 "網卡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塊網卡沒有IP地址" %i #print "網卡IP地址: %s"    % re.findall('ip=/d{1,3}/./d{1,3}/./d{1,3}/./d{1,3}',netcard)[0]print "網卡狀態: %s "    % re.findall('link=/w{3}(?#測試)',netcard)[0]print "網卡MAC地址: %s "   % re.findall('serial:.+(?#測試)',netcard)[0]print "網卡廠家: %s "    % re.findall('vendor:.+(?#測試)',netcard)[0]print "網絡接口名稱: %s"   % re.findall('logical name:.+(?#測試)',netcard)[0]"""獲取系統信息"""print "/033[1;36;40m%s/033[0m" %"獲取服務器操作系統信息"import platformprint "系統cpu位數: %s " % platform.processor()print "系統信息: %s "   % platform.system()print "操作系統類型: %s" % platform.dist()[0]print "系統主機名: %s "  % platform.node()

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 大冶市| 余江县| 肇庆市| 临西县| 上杭县| 万源市| 卢龙县| 高淳县| 马龙县| 长武县| 宾川县| 上杭县| 尼木县| 大余县| 孟津县| 达日县| 政和县| 沐川县| 青海省| 南溪县| 河源市| 资讯 | 莎车县| 芮城县| 绥滨县| 登封市| 惠安县| 都昌县| 宁津县| 新绛县| 板桥市| 池州市| 阿合奇县| 象州县| 商城县| 海淀区| 牟定县| 遵义县| 新建县| 富源县| 望谟县|