在 Python 中查看磁盘活动

发布于 01-17 00:05 字数 180 浏览 3 评论 0原文

是否有一个 python 命令或库可以调用来查看硬盘驱动器是否正在写入或读取?

就像这个 C# 一样 检测硬盘是否正在被访问

Is there a python command or library that I can call to see if hard drive is being written to or read from?

Like this C# one
Detect if hard disk is being accessed or not

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

℉絮湮2025-01-24 00:05:39

Nathan Liang 在上面回答了

监控磁盘读/写活动

答案位于
https://pypi.org/project/psutil/5.2.2/

调用将基于

import psutil
print(psutil.disk_io_counters(perdisk=False))

给出类似这样的输出

sdiskio(读计数=719566,写计数=1082197,
read_bytes=18626220032,write_bytes=24081764352,read_time=5023392,
write_time=63199568,read_merged_count=619166,
write_merged_count=812396,busy_time=4523412)

查看繁忙时间是

import psutil
psutil.disk_io_counters(perdisk=False)
print(psutil.disk_io_counters(perdisk=False).busy_time)

Answered above by Nathan Liang

Monitoring disk read/write activity

The answer is at
https://pypi.org/project/psutil/5.2.2/

The call would be based on

import psutil
print(psutil.disk_io_counters(perdisk=False))

giving the output something like this

sdiskio(read_count=719566, write_count=1082197,
read_bytes=18626220032, write_bytes=24081764352, read_time=5023392,
write_time=63199568, read_merged_count=619166,
write_merged_count=812396, busy_time=4523412)

to see busy time is

import psutil
psutil.disk_io_counters(perdisk=False)
print(psutil.disk_io_counters(perdisk=False).busy_time)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文