如何在 Linux 中获取有关进程的信息

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5584460/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 03:34:07  来源:igfitidea点击:

How to get information about process in Linux

linuxprocess

提问by universe_root

How can I get process statistics from kerneland return the buf as

如何从内核获取进程统计信息并将 buf 返回为

number of processes : ticks_user : ticks_system : ticks_interrupt : cpuseconds : procsizes : resident segment sizes

进程数:ticks_user:ticks_system:ticks_interrupt:cpuseconds:procsizes:常驻段大小

I found some information in /proc/[pid]/stat, but there is no data about ticks system, ticks_interrupt, cpusecond.

我在 中找到了一些信息/proc/[pid]/stat,但没有关于滴答系统、ticks_interrupt、cpusecond 的数据

Where can I find info about these?

我在哪里可以找到有关这些的信息?

Any pointers to API or documentation will be helpful

任何指向 API 或文档的指针都会有所帮助

回答by user unknown

Use

ps ax
top
htop

for the start, read the manpage, and for top/htop press hto get a help screen q to quit;

首先,请阅读联机帮助页,然后按 top/htoph以获取帮助屏幕q 以退出;

However, none of the manpages mentions ticks - what is it?

但是,没有一个联机帮助页提到刻度 - 它是什么?

回答by graugans

You may can give vmstat a try it is not in ticks, but why do you need ticks?

你可以试试 vmstat 它不是以滴答为单位,但你为什么需要滴答?

CPU These are percentages of total CPU time. us: Time spent running non-kernel code. (user time, including nice time) sy: Time spent running kernel code. (system time) id: Time spent idle. Prior to Linux 2.5.41, this includes IO-wait time. wa: Time spent waiting for IO. Prior to Linux 2.5.41, included in idle. st: Time stolen from a virtual machine. Prior to Linux 2.6.11, unknown.

CPU 这些是总 CPU 时间的百分比。us:运行非内核代码所花费的时间。(用户时间,包括美好时光) sy:运行内核代码所花费的时间。(系统时间)id:空闲时间。在 Linux 2.5.41 之前,这包括 IO 等待时间。wa:等待IO所花费的时间。在 Linux 2.5.41 之前,包含在 idle 中。st:从虚拟机中窃取的时间。在 Linux 2.6.11 之前,未知。

What are you planing to do with this information?

你打算用这些信息做什么?

Sometimes it may also to grep through the kernel sources, trying your buzzwords.

有时它也可能会通过内核源代码进行搜索,尝试使用您的流行语。