曙光I1620G30获取设备的cpu、内存、存储等参数信息。
发表于:2025-02-03 作者:千家信息网编辑
千家信息网最后更新 2025年02月03日,曙光I1620G30获取设备的cpu、内存、存储等参数信息。原本打算使用redfish协议获取信息,无奈厂家说暂时不支持,只好使用restfull协议获取信息。import requestsreque
千家信息网最后更新 2025年02月03日曙光I1620G30获取设备的cpu、内存、存储等参数信息。
曙光I1620G30获取设备的cpu、内存、存储等参数信息。原本打算使用redfish协议获取信息,无奈厂家说暂时不支持,只好使用restfull协议获取信息。
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 ##同时存在4-5个token链接,每个token链接时间为5分钟,可以自己设置。 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 == 200: #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): #定义总获取函数,传参url的后半部分。如'/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", 'X-Requested-With':'XMLHttpRequest', "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) ####处理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']) ####处理内存 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) ####处理存储,无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']) ##处理日志 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')
处理
信息
内存
存储
链接
参数
设备
曙光
函数
半部
厂家
原本
同时
无奈
日志
时间
支持
查询
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
访谈大学生网络安全
梦幻西游买角色怎么转服务器
华硕双子星服务器
ibm的服务器风扇太响了
惠州点餐软件开发
服务器风扇改电脑散热器底座
数据库实验手段
数据库累加
变电站网络安全策略
违反网络安全法询问提纲
房卡棋牌用什么服务器
树立忧患意识强化网络安全论文
大学生网络安全宣传进校园
数据库借书日期
公安部分管网络安全的副部长
网络技术下文化产业新业态
sql类型数据库
初级计算机网络安全课程
我的世界ec服务器恭贺新春
服务器怎么分配ip
工业园区网络安全解决方案
数据库中国时区
服务器管理口怎么进
爱复互联网科技有限公司
数据库实验手段
眼镜行业软件开发有哪些原因
白话软件开发
明日之后苹果手机哪个服务器最多
我想看国家网络安全
数据库不能输入哪些字符