python功能筆記——遠程監控

來源:互聯網
上載者:User

標籤:python   遠程監控   

python 監控遠程主機(根據慕課網手打)
1.擷取要監控的電腦的資訊
os.system(‘command‘) 直接輸出結果
os.popen(‘command‘) 返回一個檔案
open(‘/proc/file‘) cpuinfo檔案 儲存的cpu資訊

    字串的處理        注意特殊符號 \n        編碼問題            +             join            ‘%s‘%str            (‘{}‘).format(a)        路徑的處理            os.path        檔案對象的處理            read            readline            readlines        python基本的資料類型的轉換            int            str            list            dict            tuple    監控目標        cpu        記憶體        磁碟        系統進程        網路介面    監控的方式        1.之前採用的方式:os、sys、file        2.psutil            1.是一個跨平台的庫            2.可以擷取到系統的進程和系統利用率            3.本身就是為了監控出現的        cpu需要監控的東西            user( Time):執行使用者進程的時間的百分比                psutil.cpu_times().user            system( Time):執行核心進程和中斷的時間百分比                psutil.cpu_times().system            wait( IO):空閑時間比                psutil.cpu_times().wait            idle:CPU處於idle狀態的時間百分比                psutil.cpu_times().idle                psutil.cpu_times():返回以上所有資料                psutil.cpu_count():返回cpu的邏輯個數        記憶體            記憶體的總數(total)                psutil.virtual_memory().total            已經使用的核心數(used)                psutil.virtual_memory().used            閒置記憶體數(free)                psutil.virtual_memory().free            緩衝使用數(buffers)                psutil.virtual_memory().buffers            緩衝使用數(cache)                psutil.virtual_memory().cache            交換分區使用數(swap)                psutil.virtual_memory().swap                psutil.virtual_memory():返回記憶體的完整資訊        磁碟            磁碟的使用率            IO資訊                psutil.disk_partitions():擷取磁碟的完整資訊                psutil.disk_usage("裝置名稱"):擷取分區的使用方式                psutil.disk_io_counters():擷取磁碟的io個數        系統進程            psutil.pids:返回系統進程Pid            p = psutil.Process:(P要大寫)返回一個process對象,參數為進程的Pid                         p.name():返回進程的名字                         p.exe():返回進程的名字                         p.cwd():進程的工作目錄的絕對路徑                         p.status():返回進程狀態                         p.create_time():進程的建立時間(時間戳記)                         p.gids():返回進程的gid資訊                         p.uid():返回進程的Uid資訊                         p.cpu_times():返回cpu的時間資訊                         p.memory_info():返回進程記憶體的利用率                         p.io_counters():返回進程的io讀寫資訊

python功能筆記——遠程監控

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.