In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Dell R740 server acquires cpu, memory, and hard disk parameter information. With the redfish protocol, all parameters can be obtained by using only one total URL of system.
Import requestsimport jsonrequests.packages.urllib3.disable_warnings () # # use a total URL of system to get cpu, memory and storage url. Therefore, you can only modify the URL of system. # # sel log can use URL to obtain class GetHostInfo (object): def _ init__ (self,ipaddr,username,password): self.URLprefix=' https://'+ipaddr.strip() self.username=username.strip () self.password=password.strip () global token # there are 4-5 token links at the same time, and each token link time is 5 minutes, which can be set by yourself. Token=0 tokenurl=self.URLprefix+'/redfish/v1/Sessions' # # dell gets the ID print (tokenurl) data= of token {"UserName": self.username, "Password": self.password} header= {"Content-Type": "application/json"} re1=requests.post (tokenurl,json.dumps (data), headers=header Verify=False) # re1=requests.post (tokenurl,auth= (self.username,self.password), headers=header Verify=False) print (re1.status_code) if re1.status_code = 201,201: # print (re1.json ()) # print (re1.headers) print (re1.headers ['XmurAuthToken']) token=re1.headers [' XmurAuthToken'] else: pass def GetInfo (self,URL_suffix): # defines the total acquisition function Pass the second half of the parameter url. For example,'/ redfish/v1/Systems/1/Memory' urlset=self.URLprefix+URL_suffix if token! = 0: header = {"Content-Type": "application/json", "X-Auth-Token": token} re1=requests.get (urlset,headers=header) Verify=False) print (re1.status_code) return re1.json () else: passdef Collect_Info (ipaddr,username,password): dell740=GetHostInfo (ipaddr,username,password) # total_system_URL collection / redfish/v1/Systems/System.Embedded.1 select_system_total ='/ redfish/v1/Systems/System.Embedded.1' # print ('cpu_total') Hw2288HV5.GetInfo (select_cpu_total)) temp_system_result1= dell740.GetInfo (select_system_total) if isinstance (temp_system_result1,dict) and ('error' not in temp_system_result1.keys ()): # # process cpu cpu = temp_system_result1 [' Processors'] ['@ odata.id'] # # get URL # print ('Processors') of CPU Dell740.GetInfo (cpu)) cpu_result1 = dell740.GetInfo (cpu) cpu_count = cpu_result1 ['Members@odata.count'] cpu_URLsuffix_list = [x [' @ odata.id'] for x in cpu_result1 ['Members']] print (' CPU count:' Cpu_count) for single_cpuurl in cpu_URLsuffix_list: singlecpu_result2= dell740.GetInfo (single_cpuurl) if isinstance (singlecpu_result2, dict) and ('error' not in singlecpu_result2.keys ()): # print (' singlecpu_result2',singlecpu_result2) print ('CPU single name:', singlecpu_result2 [' Name']) print ('CPU single ID:' Singlecpu_result2 ['Id']) print (' CPU single TotalCores (cpus):', singlecpu_result2 ['TotalCores']) print (' CPU single Model (cpus):' Singlecpu_result2 ['Model']) # processing memory memory = temp_system_result1 [' Memory'] ['@ odata.id'] # # URL memory_result1 = dell740.GetInfo (memory) memory_count = memory_result1 ['Members@odata.count'] memory_URLsuffix_list = [x [' @ odata.id'] for x in memory_result1 ['Members']] print (' Memory count:') Memory_count) for single_memoryurl in memory_URLsuffix_list: singlememory_result2 = dell740.GetInfo (single_memoryurl) if isinstance (singlememory_result2, dict) and ('error' not in singlememory_result2.keys ()): # print (' singlecpu_result2', singlememory_result2) print ('Memory name:', singlememory_result2 [' Name']) print ('Memory ID:' Singlememory_result2 ['Id']) print (' Memory Size:', singlememory_result2 ['CapacityMiB']) print (' Memory Type:', singlememory_result2 ['MemoryDeviceType']) # # processing storage storage = temp_system_result1 [' Storage'] ['@ odata.id'] # # get storage URL # print ('storage' Dell740.GetInfo (storage) storage_result1 = dell740.GetInfo (storage) storage_URLsuffix_list = [x ['@ odata.id'] for x in storage_result1 ['Members']] for single_storageurl in storage_URLsuffix_list: singlestorage_result2 = dell740.GetInfo (single_storageurl) if isinstance (singlestorage_result2 Dict) and ('error' not in singlestorage_result2.keys ()): # print (' singlecpu_result2', singlestorage_result2) disk_count=singlestorage_result2 ['Drives@odata.count'] print (' disk count:',disk_count) print ('storage name:',singlestorage_result2 [' Id']) if disk_count > 0: # some URL have a disk of 0 There is no need to get the value single_disk_URLsuffix_list = [x ['@ odata.id'] for x in singlestorage_result2 ['Drives']] for disk_single in single_disk_URLsuffix_list: single_disk_result1 = dell740.GetInfo (disk_single) if isinstance (single_disk_result1) Dict) and ('error' not in single_disk_result1.keys ()): # print (' single_disk_result1',single_disk_result1) print ('disk name:', single_disk_result1 [' Name']) print ('disk ID:' Single_disk_result1 ['Id']) print (' disk CapacityBytes:', single_disk_result1 ['CapacityBytes']) print (' disk MediaType:' Single_disk_result1 ['MediaType']) else: pass # # get sel log logurlsuffix =' / redfish/v1/Managers/iDRAC.Embedded.1/Logs/Sel' # # log sel sellog=dell740.GetInfo (logurlsuffix) if isinstance (sellog,dict) and ('error' not in sellog.keys ()): print (' SEL log:') Sellog) if _ _ name__ = ='_ _ main__': Collect_Info ('10.252.209.7,' username', 'password')
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.