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

首頁 > 編程 > Python > 正文

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

2020-02-16 01:31:04
字體:
來源:轉載
供稿:網友

本文實例為大家分享了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()            
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 鹤庆县| 都昌县| 大埔区| 德安县| 瑞昌市| 五华县| 永新县| 定襄县| 阳东县| 体育| 博白县| 秭归县| 大关县| 江源县| 兴文县| 梁平县| 璧山县| 榕江县| 西宁市| 南城县| 新民市| 阜城县| 体育| 松阳县| 海兴县| 金堂县| 女性| 南华县| 滁州市| 安岳县| 松江区| 东光县| 庐江县| 武定县| 鲁甸县| 拜城县| 甘肃省| 通江县| 北宁市| 宜州市| 尚志市|