1. 程式人生 > >Python 3.6 利用psutil 獲取伺服器磁碟資訊

Python 3.6 利用psutil 獲取伺服器磁碟資訊

獲取磁碟完整資訊

[[email protected] python_auto]# vim disk.py

!/usr/bin/env python

import psutil

disk = psutil.disk_partitions() #利用psutil模組的disk_partitions()方法

print disk

執行檢視結果

[[email protected] python_auto]# python disk.py
[sdiskpart(device='/dev/sda2', mountpoint='/', fstype='ext4', opts='rw'), sdiskpart(device='/dev/sda1', mountpoint='/boot', fstype='ext4', opts='rw')]

獲取分割槽的使用情況

[[email protected] python_auto]# vim disk.py

!/usr/bin/env python

import psutil

disk = psutil.disk_partitions()

partition = psutil.disk_usage('/')
print partition

執行檢視結果

[[email protected] python_auto]# python disk.py
sdiskusage(total=18779398144, used=3674472448, free=14150983680, percent=19.600000000000001)
[

[email protected] python_auto]#

獲取磁碟總的IO個數、讀寫資訊

[[email protected] python_auto]# vim disk.py

!/usr/bin/env python

import psutil

disk = psutil.disk_partitions()

partition = psutil.disk_usage('/')

print partition

io = psutil.disk_io_counters()
print io

執行檢視結果

[[email protected] python_auto]# python disk.py
sdiskio(read_count=245556, write_count=118038, read_bytes=5248733184, write_bytes=3704962048, read_time=1424144, write_time=3252612)
[

[email protected] python_auto]#

獲取單個分割槽io個數、讀寫資訊。

[[email protected] python_auto]# vim disk.py

!/usr/bin/env python

import psutil

disk = psutil.disk_partitions()

partition = psutil.disk_usage('/')

print partition

io = psutil.disk_io_counters()

print io

perdisk = psutil.disk_io_counters(perdisk=True)
print perdisk

執行檢視結果
[[email protected] python_auto]# python disk.py
{'sda2': sdiskio(read_count=243109, write_count=117669, read_bytes=5193733120, write_bytes=3656708096, read_time=1409641, write_time=3249864), 'sda3': sdiskio(read_count=1223, write_count=466, read_bytes=10375168, write_bytes=49188864, read_time=10872, write_time=2831), 'sda1': sdiskio(read_count=1224, write_count=29, read_bytes=44624896, write_bytes=48128, read_time=3631, write_time=83)}
[[email protected] python_auto]#

可以看到磁碟每個分割槽的詳細資訊都有了。

相關推薦

Python 3.6 利用psutil 獲取伺服器磁碟資訊

獲取磁碟完整資訊 [[email protected] python_auto]# vim disk.py !/usr/bin/env python import psutil disk = psutil.disk_partitions() #利用psu

Python 3.6 利用NLTK 統計多個文字中的詞頻

#!/usr/bin/env python # encoding: utf-8 """ @author: wg @software: PyCharm @file: word_frequency_statistics.py @time: 2017/3/16 00

python 爬蟲獲取文件式網站資源(基於python 3.6

codes 網頁 大小 file sel dal 網頁代碼 目錄 多級目錄 import urllib.requestfrom bs4 import BeautifulSoupfrom urllib.parse import urljoinfrom Cat.findLink

python 爬蟲獲取文件式網站資源完整版(基於python 3.6

sta 不支持 bytes ror 啟動 www des find parse <--------------------------------下載函數-----------------------------> import requestsimport t

centos 6.9安裝python 3.6

令行 啟用 cal 頭部 fig org conf 源碼包 下載 1、下載源碼包在官網按照需要下載到本地 wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz 2、解壓源碼包 tar -

Python 3.6 使用 pyinstaller 打包exe文件遇到的問題

python pyinstaller 自己做了一個加密解密的小軟件,想打包成exe文件。在網上搜發現pyinstaller使用起來簡單點。在這裏記錄自己遇到問題使用的是Python 3.6版本,直接使用pip安裝pip install pyinstaller安裝過程很順利,安裝的是3.2.1版本使用看

Python 3.6學習筆記(一)

示例 ror 功能 put -m 但是 對象 初始化 absolut 開始之前 基礎示例 Python語法基礎,python語法比較簡單,采用縮緊方式。 # print absolute value of a integer a = 100 if a >= 0:

Python 3.6.1 安裝

-- rip nump com baidu .whl 都是 下載 sci 1.下載所需的python3.6.exe 我已下載好放在 http://pan.baidu.com/s/1pLQCyyJ 2.裏面的組件都是官網下載的 ,操作系統64位 3. 找到python 的安

Windows7 Python-3.6 安裝PyCrypto(pycrypto 2.6.1)出現錯誤以及解決方法

windows python pycrypto 今天準備在Windows系統上基於python3.6安裝一個pycrypto 2.6.1模塊,很不幸的報了一堆錯誤,如下所示:running installrunning buildrunning build_pyrunning build_extw

通過遊戲學python 3.6 第一季 第三章 實例項目 猜數字遊戲--核心代碼--猜測次數--隨機函數和屏蔽錯誤代碼--優化代碼及註釋 可復制直接使用 娛樂 可封裝 函數

nbsp 退出 而不是 判斷 and 封裝 except 次數 img 1 #猜數字--核心代碼--猜測次數--隨機函數和屏蔽錯誤代碼---優化代碼及註釋 2 3 import random 4 number = random.randint(1,

通過遊戲學python 3.6 第一季 第九章 實例項目 猜數字遊戲--核心代碼--猜測次數--隨機函數和屏蔽錯誤代碼--優化代碼及註釋--簡單賬號密碼登陸--賬號的註冊查詢和密碼的找回修改--鎖定賬號--鎖定次數--菜單功能'menufile

lock isp 無限循環 lis true 條件判斷 elif bre format 通過遊戲學python 3.6 第一季 第九章 實例項目 猜數字遊戲--核心代碼--猜測次數--隨機函數和屏蔽錯誤代碼--優化代碼及註釋--簡單賬號密碼登陸--賬號的註冊查詢和密碼的

python 3.6關於Opencv的安裝支持

內容 get 通過 title win 技術 測試 擴展 logs 1、安裝Numpy擴展 按照有些文章的內容,從http://www.lfd.uci.edu/~gohlke/pythonlibs/ 下載對應版本的 “numpy?1.13.1+mkl?cp36

在 Ubuntu 16.04 LTS 上安裝 Python 3.6.0

tty article print spa blog sdn number ins 6.0 轉自(http://blog.csdn.net/Wangdada111/article/details/73382537?locationNum=2&fps=1) 安裝:

win10 64位Python 3.6.2 + Django 環境安裝

下載安裝 install 6.2 images 界面 logs ins bsp ges 一、安裝Python3.6.2 1、下載安裝包 https://www.python.org/downloads/release/python-362/ 2、一直下一步,

Wing ide 6.0 註冊 ,python 3.6環境

index pytho abc encode cnblogs urn python3 uestc 其中 直接切入主題,套路如下: 1、選擇手動輸入license license number輸入:CN123-12345-12345-12345 2、在下一步中,選擇第二

linux下安裝python 3.6

python 3.6、linux獲取Anaconda3-4.3.1-Linux-x86_64.sh、netCDF4-1.2.7-cp36-cp36m-manylinux1_x86_64.whl、opencv_python-3.2.0.7-cp36-cp36m-manylinux1_x86_64.whl1、到/

python 3.6 tkinter+urllib+json 火車車次信息查詢

做的 ttr cnblogs bsp 分享圖片 類型 item ini 車次查詢 --------blogs: 陳月白 http://www.cnblogs.com/chenyuebai -------- 一、概述 妹子工作時需要大量地查詢火車車次至南京的信息

Windows 下 Python 3.6 下安裝 TensorFlow (屢敗屢戰)

plot global install sim can 版本 結果 codec error: 事情是這樣的,好不容易找到了【含代碼而不止代碼】的教程:  (知乎回答)  但是我用的是windows,還是win7,怎麽辦?有代碼就好說,代碼裏不是有“from keras……”

python 3.6 setup

upgrade repo all ade pan use 3.6 版本 ppa 1.添加python3.6安裝包,並且安裝 sudo apt-get install software-properties-common 2.下載python3.6 sudo add

Python 3.6 TypeEror: iter() returned non-iterator of type

ext -i mage on() self. peer 技術分享 .com span 環境:Python 3.6 class Fabs(object): def __init__(self,max): self.max = max