Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Dawning I1620G30 acquires the cpu, memory, storage and other parameter information of the device.

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Dawning I1620G30 acquires the cpu, memory, storage and other parameter information of the device. Originally intended to use the redfish protocol to obtain information, but the manufacturer said that temporarily does not support, had to use the restfull protocol to obtain information.

Import requestsrequests.packages.urllib3.disable_warnings () class GetHostInfo (object): def _ _ init__ (self,ipaddr,username,password): self.username=username self.password=password self.URLprefix=' http://' + ipaddr.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. Global cookie token=0 cookie=0 tokenurl=self.URLprefix+'/api/session' print (tokenurl) data= {"username": self.username, "password": self.password} re1=requests.post (tokenurl,data=data Verify=False) print (re1.status_code) if re1.status_code = # print (re1.json ()) # print (re1.status_code) # print (re1.json ()) # print ('header:') Re1.headers) # temp = re1.json () # print (temp ['CSRFToken']) # print (re1.headers) # print (re1.json ()) temp_header=re1.headers cookie=temp_header [' Set-Cookie'] temp_token=re1.json () token=temp_token ['CSRFToken'] Print (cookie) print (token) else: pass def GetInfo (self) URL_suffix): # define the total get function Pass the second half of the parameter url. For example,'/ api/system1/memory' urlset=self.URLprefix + URL_suffix.strip () # print (urlset) # print ('token:',token) # print (' cookie:',cookie) if cookie! = 0 and token! = 0: header = {"Content-Type": "application/json,text/javascript", 'Xmuri RequestedMushWithvillWittPRequest`' "X-CSRFTOKEN": token, Cookie: cookie} re1=requests.get (urlset,headers=header,verify=False) print (re1.status_code) return (re1.json ()) else: passdef Collect_Info (ipaddr,username,password): SuGon=GetHostInfo (ipaddr,username Password) # handle CPU select_cpu_total ='/ api/serverrepo/cpus' # print ('cpu_total', SuGon.GetInfo (select_cpu_total)) temp_cpu_result1= SuGon.GetInfo (select_cpu_total) if isinstance (temp_cpu_result1,list): cpu_count = len (temp_cpu_result1) print (' @'* 50) print ('CPU Count:') Cpu_count) for cpu_single in temp_cpu_result1: if isinstance (cpu_single, dict): print ('CPU single name:',cpu_single [' Location']) print ('CPU single ID:',cpu_single [' id']) print ('CPU single TotalCores (cpus):' Cpu_single ['CoreThread']) print (' CPU single Model (cpus):', cpu_single ['BrandName']) # processing memory select_mem_total =' / api/serverrepo/mems' # print ('mem_total', SuGon.GetInfo (select_mem_total)) temp_mem_result1 = SuGon.GetInfo (select_mem_total) memory_count=0 if isinstance (temp_mem_result1) List): mem_count = len (temp_mem_result1) print ('@'* 50) print ('Memory Count (exist):', mem_count) for mem_single in temp_mem_result1: if isinstance (mem_single, dict): Memory_Size = mem_single ['Size'] # print (' Memory_Size AAAAA' Memory_Size) if Memory_Size: memory_count+=1 print ('Memory name:', mem_single [' Location']) print ('Memory ID:', mem_single [' id']) print ('Memory Size:', Memory_Size) print (' Memory Type:') Mem_single ['DimmType']) else: pass print (' Memory Count (alive):', memory_count) # processing storage, query without raid select_storage_total ='/ api/serverrepo/hdds' # print ('storage_total', SuGon.GetInfo (select_storage_total)) temp_storage_result1 = SuGon.GetInfo (select_storage_total) if isinstance (temp_storage_result1) List): mem_count = len (temp_storage_result1) print ('@'* 50) print ('Storage Count:', mem_count) for storage_single in temp_storage_result1: if isinstance (storage_single, dict): print (' Storage name:', storage_single ['Location']) print (' Storage ID:' Storage_single ['id']) print (' Storage Size:', storage_single ['Size']) print (' Storage Type:', storage_single ['Mode']) # # processing log selecteventlog =' / api/logs/eventlog' # # post selectselinfo ='/ api/logs/selinfo' # # get print ('selectselinfo', SuGon.GetInfo (selectselinfo)) print (' selecteventlog') SuGon.GetInfo (selecteventlog)) if _ _ name__ = ='_ _ main__': Collect_Info ('10.249.177.29, 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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report