linux - CPU 和硬盘信息

标签 linux

我进行了搜索,但没有找到适合我的问题。 我想在 Linux 命令行中获得有关 CPU 使用率和本地 HDD 的信息,其格式文本与我的程序的以下示例完全一样。 这些示例是 MS-Windows 上的命令行输出。 我希望它也可以在 Linux 上实现。

谢谢

wmic logicaldisk where drivetype=3 get caption,freespace,size

Caption  FreeSpace     Size
C:       135314194432  255953203200
D:       126288519168  128033222656
E:       336546639872  1000194015232
F:       162184503296  1000194015232

wmic cpu get loadpercentage

LoadPercentage
4

最佳答案

您找不到任何完全与您提供的输出相同的内容。 唯一的选择是使用磁盘空间 df:

Filesystem                   1K-blocks      Used Available Use% Mounted on
/dev/root                     73216256  27988724  41485276  41% /
devtmpfs                       8170164         0   8170164   0% /dev
tmpfs                          8203680       544   8203136   1% /dev/shm
tmpfs                          8203680     12004   8191676   1% /run
tmpfs                             5120         4      5116   1% /run/lock
tmpfs                          8203680         0   8203680   0% /sys/fs/cgroup
/dev/sdb1                       482922     83939    374049  19% /boot

对于 cpu 你有更多的选择,例如 vmstat

procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 0  0      0 11865304 149956 1474172    0    0    53    46  126  707  3  0 96  0  0

top -b |头:

top - 21:48:43 up 54 min,  1 user,  load average: 0.13, 0.17, 0.22
Tasks: 188 total,   1 running, 187 sleeping,   0 stopped,   0 zombie
%Cpu(s):  3.0 us,  0.4 sy,  0.1 ni, 96.5 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem : 16407364 total, 11848936 free,  2888844 used,  1669584 buff/cache
KiB Swap:        0 total,        0 free,        0 used. 13230972 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
    1 root      20   0   40544   6440   3780 S   0.0  0.0   0:01.15 systemd
    2 root      20   0       0      0      0 S   0.0  0.0   0:00.00 kthreadd
    3 root      20   0       0      0      0 S   0.0  0.0   0:00.00 ksoftirqd/0

关于linux - CPU 和硬盘信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33134161/

相关文章:

linux - 获取将在 `XKB_KEY_dead_circumflex` 和普通键上键入的字符

php - 如何有效地监视 linux 上目录的更改?

linux - 将 n 个字节的数据 x 复制到文件

linux - 在 Linux 上安装 OSVR - 设置二进制目录

linux - 如何在Openwrt中降级内核版本?

python - 如何隐藏 python 命令提示符窗口

python - 在 python 中使用 os.popen 转换 linux 命令

linux - ARM 工具链构建

c - 循环中的文件 mmap

由于维护,Compute Engine 上的 MySQL 未正确关闭