91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

曙光I1620G30獲取設備的cpu、內存、存儲等參數信息。

發布時間:2020-07-23 12:27:48 來源:網絡 閱讀:240 作者:chier11 欄目:系統運維

曙光I1620G30獲取設備的cpu、內存、存儲等參數信息。原本打算使用redfish協議獲取信息,無奈廠家說暫時不支持,只好使用restfull協議獲取信息。

import requests
requests.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:
            pass

def 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')
向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

恩平市| 葫芦岛市| 沭阳县| 盖州市| 西城区| 中江县| 鹤山市| 葫芦岛市| 苍溪县| 澳门| 宁夏| 志丹县| 徐州市| 武冈市| 环江| 杭锦后旗| 庐江县| 崇州市| 云南省| 古浪县| 乃东县| 瓮安县| 宁津县| 洛阳市| 扬中市| 乌拉特前旗| 库伦旗| 扶风县| 平原县| 白银市| 渭南市| 宝山区| 山丹县| 济宁市| 五家渠市| 咸宁市| 故城县| 抚宁县| 桃江县| 兴海县| 界首市|