最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Python讀取硬盤所有信息的完整方法

 更新時間:2026年01月29日 09:43:20   作者:XerCis  
這篇文章主要為大家詳細介紹了Python讀取硬盤所有信息的相關(guān)方法,文中的示例代碼講解詳細,具有一定的借鑒價值,感興趣的小伙伴可以跟隨小編一起了解下

簡介

smartmontools 包含兩個程序 smartctlsmartd,用于控制和監(jiān)控存儲系統(tǒng):

  • 檢查硬盤(HDD/SSD)的健康狀態(tài)
  • 預(yù)測硬盤故障風(fēng)險
  • 執(zhí)行硬盤自檢(如短/長測試)
  • 查看溫度、通電時間、壞扇區(qū)等關(guān)鍵指標(biāo)

SMART 指的是 Self-Monitoring, Analysis and Reporting Technology System

pySMART 是 smartctl 的 Python 封裝,兼容 Linux 和 Windows

建議使用管理員權(quán)限運行

安裝

pip install pySMART

Windows

下載 smartmontools 或從 releases 下載

Linux

apt-get install smartmontools

yum install smartmontools

列出系統(tǒng)中的硬盤

lsblk

NAME MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda    8:0    0  256G  0 disk
sdb    8:16   0  256G  0 disk /

smartctl --scan

/dev/sda -d ata # /dev/sda, ATA device
/dev/sdb -d ata # /dev/sdb, ATA device
/dev/sdc -d nvme # /dev/sdc, NVMe device
/dev/sdd -d scsi # /dev/sdd, SCSI device

實現(xiàn)代碼

from pySMART import DeviceList

device_list = DeviceList()
devices = device_list.devices
print(devices)
# [<ATA device on /dev/sda mod:ST4000VX000-1F4168 sn:Z302B410>, 
# <ATA device on /dev/sdb mod:ST8000NM0055-1RM112 sn:ZA1F6NQX>, 
# <NVME device on /dev/sdc mod:Samsung SSD 970 EVO 500GB sn:S466NX0M733342K>]

查看硬盤基本信息

smartctl -i /dev/sda

=== START OF INFORMATION SECTION ===
Model Family:     Seagate Surveillance  # 硬盤系列
Device Model:     ST4000VX000-1F4168  # 具體型號
Serial Number:    Z302B410  # 序列號
LU WWN Device Id: 5 000c50 0793e2e21  # 邏輯單元全球名稱
Firmware Version: CV12  # 固件版本號
User Capacity:    4,015,189,831,680 bytes [4.01 TB]  # 可用容量
Sector Sizes:     512 bytes logical, 4096 bytes physical  # 邏輯扇區(qū)大小512字節(jié),物理扇區(qū)大小4096字節(jié)(4KB)
Rotation Rate:    5900 rpm  # 轉(zhuǎn)速
Form Factor:      3.5 inches  # 外形規(guī)格
Device is:        In smartctl database  # 
ATA Version is:   ACS-2, ACS-3 T13/2161-D revision 3b  # 支持的ATA標(biāo)準(zhǔn)版本
SATA Version is:  SATA 3.1, 6.0 Gb/s (current: 6.0 Gb/s)  # SATA接口版本及傳輸速率
Local Time is:    Tue Jan 27 12:05:24 2026  # 系統(tǒng)本地時間
SMART support is: Available - device has SMART capability.  # 具備SMART監(jiān)測功能
SMART support is: Enabled  # 已啟用SMART功能

實現(xiàn)代碼 

from pySMART import Device

device = Device('/dev/sda')
device.all_attributes()
# ID# ATTRIBUTE_NAME          CUR WST THR TYPE     UPDATED WHEN_FAIL   RAW
#   1 Raw_Read_Error_Rate     113  92   6 Pre-fail Always  -           55785344
#   3 Spin_Up_Time            091  91   0 Pre-fail Always  -           0
#   4 Start_Stop_Count        037  37  20 Old_age  Always  -           65535
#   5 Reallocated_Sector_Ct   100 100  10 Pre-fail Always  -           0
#   7 Seek_Error_Rate         088  60  30 Pre-fail Always  -           713434302
#   9 Power_On_Hours          064  64   0 Old_age  Always  -           31980
#  10 Spin_Retry_Count        100 100  97 Pre-fail Always  -           0
#  12 Power_Cycle_Count       087  37  20 Old_age  Always  -           13611
# 184 End-to-End_Error        100 100  99 Old_age  Always  -           0
# 187 Reported_Uncorrect      001   1   0 Old_age  Always  -           348
# 188 Command_Timeout         100  99   0 Old_age  Always  -           8590065666
# 189 High_Fly_Writes         100 100   0 Old_age  Always  -           0
# 190 Airflow_Temperature_Cel 064  45  45 Old_age  Always  In_the_past 36 (Min/Max 27/36)
# 191 G-Sense_Error_Rate      100 100   0 Old_age  Always  -           0
# 192 Power-Off_Retract_Count 029  29   0 Old_age  Always  -           143207
# 193 Load_Cycle_Count        024  24   0 Old_age  Always  -           152378
# 194 Temperature_Celsius     036  55   0 Old_age  Always  -           36 (0 12 0 0 0)
# 197 Current_Pending_Sector  100 100   0 Old_age  Always  -           96
# 198 Offline_Uncorrectable   100 100   0 Old_age  Offline -           96
# 199 UDMA_CRC_Error_Count    200 200   0 Old_age  Always  -           0

查看硬盤所有信息

smartctl -a /dev/pd0

smartctl -a /dev/sda

實現(xiàn)代碼 

from pySMART import Device

sda = Device('/dev/sda')
print(sda)
# <ATA device on /dev/sda mod:ST4000VX000-1F4168 sn:Z302B410>

檢查硬盤健康狀態(tài)

smartctl -H /dev/sda

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED
Please note the following marginal Attributes:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
190 Airflow_Temperature_Cel 0x0022   063   045   045    Old_age   Always   In_the_past 37 (Min/Max 20/37)

查看詳細屬性

smartctl -A /dev/sda

=== START OF READ SMART DATA SECTION ===
SMART Attributes Data Structure revision number: 10
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate     0x000f   108   092   006    Pre-fail  Always       -       16945048
  3 Spin_Up_Time            0x0003   091   091   000    Pre-fail  Always       -       0
  4 Start_Stop_Count        0x0032   037   037   020    Old_age   Always       -       65535
  5 Reallocated_Sector_Ct   0x0033   100   100   010    Pre-fail  Always       -       0
  7 Seek_Error_Rate         0x000f   088   060   030    Pre-fail  Always       -       713392046
  9 Power_On_Hours          0x0032   064   064   000    Old_age   Always       -       31977
 10 Spin_Retry_Count        0x0013   100   100   097    Pre-fail  Always       -       0
 12 Power_Cycle_Count       0x0032   087   037   020    Old_age   Always       -       13610
184 End-to-End_Error        0x0032   100   100   099    Old_age   Always       -       0
187 Reported_Uncorrect      0x0032   001   001   000    Old_age   Always       -       348
188 Command_Timeout         0x0032   100   099   000    Old_age   Always       -       8590065666
189 High_Fly_Writes         0x003a   100   100   000    Old_age   Always       -       0
190 Airflow_Temperature_Cel 0x0022   063   045   045    Old_age   Always   In_the_past 37 (Min/Max 20/37)
191 G-Sense_Error_Rate      0x0032   100   100   000    Old_age   Always       -       0
192 Power-Off_Retract_Count 0x0032   029   029   000    Old_age   Always       -       143207
193 Load_Cycle_Count        0x0032   024   024   000    Old_age   Always       -       152355
194 Temperature_Celsius     0x0022   037   055   000    Old_age   Always       -       37 (0 12 0 0 0)
197 Current_Pending_Sector  0x0012   100   100   000    Old_age   Always       -       96
198 Offline_Uncorrectable   0x0010   100   100   000    Old_age   Offline      -       96
199 UDMA_CRC_Error_Count    0x003e   200   200   000    Old_age   Always       -       0

Reallocated_Sector_Ct(ID 5):壞道重映射數(shù)量

Current_Pending_Sector(ID 197):待處理壞扇區(qū)

Temperature(ID 194):溫度是否過高

硬盤自檢

查看支持哪些測試

smartctl -c /dev/sda

=== START OF READ SMART DATA SECTION ===
General SMART Values:
Offline data collection status:  (0x82) Offline data collection activity
                                        was completed without error.
                                        Auto Offline Data Collection: Enabled.
Self-test execution status:      (   0) The previous self-test routine completed
                                        without error or no self-test has ever
                                        been run.
Total time to complete Offline
data collection:                (  128) seconds.
Offline data collection
capabilities:                    (0x7b) SMART execute Offline immediate.
                                        Auto Offline data collection on/off support.
                                        Suspend Offline collection upon new
                                        command.
                                        Offline surface scan supported.
                                        Self-test supported.
                                        Conveyance Self-test supported.
                                        Selective Self-test supported.
SMART capabilities:            (0x0003) Saves SMART data before entering
                                        power-saving mode.
                                        Supports SMART auto save timer.
Error logging capability:        (0x01) Error logging supported.
                                        General Purpose Logging supported.
Short self-test routine
recommended polling time:        (   1) minutes.
Extended self-test routine
recommended polling time:        ( 527) minutes.
Conveyance self-test routine
recommended polling time:        (   2) minutes.
SCT capabilities:              (0x10b9) SCT Status supported.
                                        SCT Error Recovery Control supported.
                                        SCT Feature Control supported.
                                        SCT Data Table supported.

短自檢

1-2 分鐘

smartctl -t short /dev/sda

長自檢

幾十分鐘到幾小時

smartctl -t long /dev/sda

查看測試結(jié)果

smartctl -l selftest /dev/sda

=== START OF READ SMART DATA SECTION ===
SMART Self-test log structure revision number 1
Num  Test_Description    Status                  Remaining  LifeTime(hours)  LBA_of_first_error
# 1  Short offline       Completed without error       00%     31977         -

到此這篇關(guān)于Python讀取硬盤所有信息的完整方法的文章就介紹到這了,更多相關(guān)Python讀取硬盤信息內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • 使用tf.keras.MaxPooling1D出現(xiàn)錯誤問題及解決

    使用tf.keras.MaxPooling1D出現(xiàn)錯誤問題及解決

    這篇文章主要介紹了使用tf.keras.MaxPooling1D出現(xiàn)錯誤問題及解決方案,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-12-12
  • 目前最全的python的就業(yè)方向

    目前最全的python的就業(yè)方向

    Python是一門面向?qū)ο蟮木幊陶Z言,編譯速度超快,從誕生到現(xiàn)在已經(jīng)25個年頭了。其特點在于靈活運用,因為其擁有大量第三方庫,所以開發(fā)人員不必重復(fù)造輪子,就像搭積木一樣,只要擅于利用這些庫就可以完成絕大部分工作
    2018-06-06
  • python中的scapy抓取http報文內(nèi)容

    python中的scapy抓取http報文內(nèi)容

    這篇文章主要介紹了python中的scapy抓取http報文內(nèi)容方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2023-08-08
  • Python魔法方法 容器部方法詳解

    Python魔法方法 容器部方法詳解

    這篇文章主要介紹了Python魔法方法 容器部方法詳解,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下
    2020-01-01
  • PyCharm使用matplotlib報MatplotlibDeprecationWarning問題解決辦法

    PyCharm使用matplotlib報MatplotlibDeprecationWarning問題解決辦法

    這篇文章主要給大家介紹了關(guān)于PyCharm使用matplotlib報MatplotlibDeprecationWarning問題解決的相關(guān)資料,主要是 matplotlib版本過高導(dǎo)致的,文中通過圖文介紹的非常詳細,需要的朋友可以參考下
    2023-06-06
  • 關(guān)于最大池化層和平均池化層圖解

    關(guān)于最大池化層和平均池化層圖解

    這篇文章主要介紹了關(guān)于最大池化層和平均池化層圖解,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-12-12
  • python內(nèi)置函數(shù)之slice案例詳解

    python內(nèi)置函數(shù)之slice案例詳解

    這篇文章主要介紹了python內(nèi)置函數(shù)之slice案例詳解,本篇文章通過簡要的案例,講解了該項技術(shù)的了解與使用,以下就是詳細內(nèi)容,需要的朋友可以參考下
    2021-09-09
  • python水晶球(函數(shù))詳解

    python水晶球(函數(shù))詳解

    大家好,本篇文章主要講的是python水晶球(函數(shù))詳解,感興趣的同學(xué)趕快來看一看吧,對你有幫助的話記得收藏一下,方便下次瀏覽
    2021-12-12
  • python使用 cx_Oracle 模塊進行查詢操作示例

    python使用 cx_Oracle 模塊進行查詢操作示例

    這篇文章主要介紹了python使用 cx_Oracle 模塊進行查詢操作,結(jié)合實例形式分析了Python使用cx_Oracle模塊進行數(shù)據(jù)庫的基本連接、查詢、輸出等相關(guān)操作技巧,需要的朋友可以參考下
    2019-11-11
  • Python實現(xiàn)為PDF文檔添加標(biāo)準(zhǔn)數(shù)字簽名

    Python實現(xiàn)為PDF文檔添加標(biāo)準(zhǔn)數(shù)字簽名

    電子簽名和數(shù)字簽名現(xiàn)在越來越頻繁地出現(xiàn)在日常交流和文件簽發(fā)中,這篇文章主要介紹了Python實現(xiàn)為PDF文檔添加標(biāo)準(zhǔn)數(shù)字簽名,有需要的小伙伴可以了解下
    2026-05-05

最新評論

苍南县| 平远县| 江源县| 舟山市| 手游| 大新县| 威信县| 隆回县| 宣恩县| 富锦市| 公主岭市| 淮南市| 广德县| 皮山县| 沙河市| 武宣县| 南郑县| 志丹县| 施甸县| 平凉市| 监利县| 朝阳区| 丰县| 蕲春县| 扎兰屯市| 信阳市| 方正县| 凤阳县| 尼木县| 卢湾区| 富宁县| 广州市| 芒康县| 菏泽市| 北京市| 四会市| 禹州市| 北辰区| 县级市| 桦甸市| 云梦县|