1. 程式人生 > >Python 檢視伺服器磁碟資訊

Python 檢視伺服器磁碟資訊

檢視磁碟資訊,主要用到了兩個方法

  • psutil.disk_partitions()
  • psutil.disk_usage()

使用方法:
1、安裝 psutil

pip install psutil

2、進入 python shell,並 import psutil

輸入 help(psutil.disk_partitions)

返回

Help on function disk_partitions in module psutil:

disk_partitions(all=False)
    Return mounted partitions as a list of
(device, mountpoint, fstype, opts) namedtuple. 'opts' field is a raw string separated by commas indicating mount options which may vary depending on the platform. If *all* parameter is False return physical devices only and ignore all others.

輸入 help(psutil.disk_usage)

返回

Help on function disk_usage in module psutil:

disk_usage(path)
    Return disk usage statistics about the given *path* as a
    namedtuple including total, used and free space expressed in bytes
    plus the percentage usage.

3、應用

輸入 psutil.disk_partitions()

>>> psutil.disk_partitions()
[sdiskpart(device='/dev/disk1'
, mountpoint='/', fstype='hfs', opts='rw,local,rootfs,dovolfs,journaled,multilabel'), sdiskpart(device='/dev/disk12s2', mountpoint='/Volumes/QQ', fstype='hfs', opts='ro,nosuid,quarantine,local,dovolfs,ignore-ownership,multilabel')]

輸入 psutil.disk_usage(‘/’)

>>> psutil.disk_usage("/")
sdiskusage(total=120101666816, used=88392372224, free=31447150592, percent=73.8)

注:上述查到的大小資訊單位為 bytes,因此,為了便於直觀的觀察使用量,應將其轉換為M或G為單位的資料

相關推薦

Python 檢視伺服器磁碟資訊

檢視磁碟資訊,主要用到了兩個方法 psutil.disk_partitions() psutil.disk_usage() 使用方法: 1、安裝 psutil pip install

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

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

【Linux】Linux作業系統檢視伺服器配置資訊

檢視伺服器配置資訊 編寫bash shell指令碼檢視Linux作業系統的伺服器配置資訊 1 #!/bin/bash 2 echo "This lists the information of this computer." 3 echo 4 echo "Hostna

檢視伺服器基本資訊(meminfo, cpu, kernal等),適用於centos, ubuntu, redhat等

此指令碼已經在ubuntu以及centos版本上測試通過,指令碼如下: #!/bin/bash Line='===========' #linux發行版名稱 if [[ -f /usr/bin/lsb_release ]]; then  OS=$(/usr/bin/lsb_

QQ坦白說裡匿名罵我,逃得過我的法眼?Python檢視匿名使用者資訊

介紹QQ坦白說 據騰訊釋出內容來看,“坦白說”是剛剛在QQ中上線的新功能,目前還在測試階段就已經非常火爆。如果你對QQ中的“坦白說”這個全新功能還不熟悉,不妨一起來瞧瞧看。 “坦白說”可以讓我們和玩悄悄話一樣的匿名描述你好友的性格與一段文字

python 檢視函式幫助資訊

注:本文基於Python 2.7.5編寫 在linux上檢視某個命令的使用可以使用man看使用者手冊,但是對於python的一些函式使用,卻沒辦法使用man這個命令。但是也是有辦法查詢相應的幫助資訊的,那就是用help的方式。 首先要進入python互動式環

Linux檢視伺服器資源資訊

檢視系統及系統版本資訊:lsb_release -a(注:這個命令適用於所有的linux,包括Redhat、SuSE、Debian等發行版) 如果執行該命令時提示command not found則表示未安裝lsb_release,通過yum進行安裝命令如下 yum in

MySQL 如何檢視伺服器配置資訊

進入到MySQL 安裝目錄,開啟my.ini 檔案可以檢視。 但是my.ini 檔案裡,好多都是自設定的value值。 如果沒有自動設定,好多值實際上是看不到的,都是預設值, 這時候需要用命令列: show variables like 'port' ;  檢視伺服器埠 。

在Linux伺服器和本地主機檢視伺服器資訊,檢測埠是否可連線

(1)本地主機上檢測伺服器埠是否可以連線cmd視窗下輸入以下命令(可以檢視埠能否正常連線,第一個引數是ip地址,第二個引數是埠號):如果出現以下問題:更詳細在本地主機檢測伺服器埠是否可連線的方法可參考:怎樣測試某個埠是否開啟(2)在Linux伺服器檢視本伺服器上的所有埠:伺服

Linux系統下檢視伺服器CPU資訊

首先推薦一篇文章超執行緒、多核知識實戰,5分鐘讓你成為CPU專家,非常好的一篇文章,解釋超執行緒的含義,對CPU的結構也可以有一個巨集觀的理解。 1 檢視物理CPU的個數 cat /pr

python os.statvfs() 檢視檔案系統資訊 磁碟使用情況

Python os.statvfs() 方法 os.statvfs() 方法用於返回包含檔案描述符fd的檔案的檔案系統的資訊。 語法 statvfs()方法語法格式如下: os.statvfs

Linux之磁碟資訊檢視

一、磁碟情況查詢 1、檢視磁碟整體情況   命令:df   引數:     -a:列出所有的檔案系統,包括系統特有的/proc等檔案系統     -k:以KB的容量顯示各檔案系統     -m:以MB的容量顯示各檔案系統     -h:以人們較易閱讀的GB,MB,KB等格式自行顯示     -

linux下檢視CPU、記憶體、磁碟資訊,資料夾資訊,GPU資訊

1、檢視CPU資訊 # 總核數 = 物理CPU個數 X 每顆物理CPU的核數  # 總邏輯CPU數 = 物理CPU個數 X 每顆物理CPU的核數 X 超執行緒數 # 檢視物理CPU個數 cat /proc/cpuinfo| grep "physical id"| sort| uniq| w

檢視本地python類庫詳細資訊

python -m pydoc -p 1234     python -m pydoc    表示開啟pydoc模組,這個模組就是用來檢視python文件的工具 -p 1234      &n

Python爬蟲——代理伺服器進行資訊的爬取

利用代理伺服器進行資訊的爬取以防止自己的IP的被伺服器封 def function1(url,IP):#url IP """代理伺服器進行資訊的爬取以防止自己的IP的被伺服器封""" proxy=urllib.request.ProxyHandler({"http":IP}

使用python獲取電腦的磁碟資訊

使用Python獲取電腦的磁碟資訊需要藉助於第三方的模組psutil,這個模組需要自己安裝,純粹的CPython下面不具備這個功能。 在PyCharm互動介面中進行如下演示: 檢視電腦的磁碟分割槽: d = psutil.disk_partitions() print(

centos 檢視伺服器資訊 版本cpu

檢視 版本 cat /etc/redhat-release        uname -a   檢視所有 1、檢視 CPU 物理個數   grep 'physical id' /proc/cpuinfo

Centos 下檢視伺服器CPU的資訊

                實時檢視CPU每核的執行緒利用率  top 後按 1,如下圖所示,我們可以看到有8個CPU,每行顯示的就是該CPU的使用率:    檢視當前作業系統核心資訊  # uname -a    Linux db1.xxx.com 2.6.18-194.el5xen #1 SMP F

CentOS6.檢視 Python中變數的資訊(名稱型別內容等)

ZC:環境:CentOS6、pycharm-community-2018.3.2.tar.gz ZC:是在 使用 微信 的 “5.1 新建臨時素材”,跑 media_upload__test.py 時用到的   ZC:用下面的 方式 變數postData,貌似 還是並不能很

Windows伺服器如何檢視共享目錄資訊

2018-11-13 14:41 by 瀟湘隱者, ... 閱讀, ... 評論, 收藏, 編輯 檢視Windows伺服器上的共享目錄的相關資訊,可以使用兩種方式: 1:命令net share 檢視: 2:通過計算機管理的Shar