Cygwin top 命令 - 查看所有用户的进程

发布于 2024-09-15 02:22:09 字数 271 浏览 4 评论 0原文

有谁知道如何在 Cygwin 中使用 top 命令查看所有用户的进程(系统下 procps 库的一部分)。

我知道这可以在 *nix 中完成,但我在 Cygwin 中挣扎。我尝试过使用 pslist,但它在 putty SSH 控制台中不起作用。

我需要一个解决方案,让我可以使用 SSH 看到类似于 top 的对话框。我根本没有任何 NTLM SSO 访问 Win2k3 来宾的权限,因此 ssh 是唯一的进入方式。

Does anybody know how to see the processes for all users using top command in Cygwin (part of procps library under System).

I know this can be done in *nix but I am struggling in Cygwin. I have tried using pslist but it does not behave in a putty SSH console.

I need to have a solution where I can see a top like dialog using SSH. I do not have any NTLM SSO access to the Win2k3 guest at all so ssh is the only way in.

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

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

发布评论

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

评论(3

站稳脚跟 2024-09-22 02:22:09

top 仅显示 Cygwin 进程。 ps -W 也会列出 Windows 进程。

top only displays Cygwin processes. ps -W will list Windows processes as well.

飞烟轻若梦 2024-09-22 02:22:09

很多时候,命令“tasklist”可以更有效地完成工作。它内置于 Windows 中,只需确保您的 System32 文件夹是您的 bash 配置文件路径的一部分。还有 Props 本身。您还应该尝试在终端上使用 mintty。您始终可以尝试将任何这些任务应用程序附加到屏幕,和/或使用手表轮询信息。

Manytimes the command "tasklist" gets the job done more effectively. It built into windows, just make sure your System32 folder is part of your bash profile PATH. There is also procps itself. You should also try using mintty for your terminal. You could always try attaching any of these task apps to screen, and or using watch to poll the information.

枕头说它不想醒 2024-09-22 02:22:09

看来你可以做类似的事情:

wmic process get ProcessId,Name,UserModeTime,KernelModeTime /EVERY:1

用户和内核模式时间似乎以 1/10,000,000 秒表示。

您应该能够对该输出进行后处理以获得每秒的 CPU 使用率。

这里使用 cygwin 的 perl

wmic process get ProcessId,Name,UserModeTime,KernelModeTime /EVERY:1 |
  perl -lne '
    if (/\S/) {
      my ($k,$c,$p,$u) = split /\s{2,}/;
      $n{"$p\t$c"}=$k+$u;
    } else {
      my %c;
      for my $k (keys %n) {
        $c{$k} = $n{$k} - $o{$k} if defined $o{$k}
      }
      print "$_\t" . $c{$_}/1e5 for (sort {$c{$b}<=>$c{$a}} keys %c)[0..20];
      %o = %n; %n = undef; print ""
    }'

输出类似:

0       System Idle Process     588.12377
2196    sh.exe  107.00075
248     svchost.exe     85.80055
7140    explorer.exe    26.52017
[...]

每秒。

请注意,如果空闲系统上的系统空闲进程显示略低于 800%,那是因为您的系统有 8 个 CPU 核心(至少有 8 个线程),因为这会计算所有 CPU 的 CPU 时间。

另请注意,上面的 EVERY:1 是一个谎言。 wmic 似乎并没有每秒给出该输出。更有可能的是,它在每个报告之间休眠大约 1 秒,并且不会补偿计算报告所需的时间。因此,在实践中,它会每 1 秒运行一次,这意味着这些百分比不是很准确,并且略有高估。

It seems you can do something like:

wmic process get ProcessId,Name,UserModeTime,KernelModeTime /EVERY:1

The User and Kernel mode times there seem to be expressed in 1/10,000,000th of second.

You should be able to post-process that output to get the CPU-usage per second.

Here using cygwin's perl:

wmic process get ProcessId,Name,UserModeTime,KernelModeTime /EVERY:1 |
  perl -lne '
    if (/\S/) {
      my ($k,$c,$p,$u) = split /\s{2,}/;
      $n{"$p\t$c"}=$k+$u;
    } else {
      my %c;
      for my $k (keys %n) {
        $c{$k} = $n{$k} - $o{$k} if defined $o{$k}
      }
      print "$_\t" . $c{$_}/1e5 for (sort {$c{$b}<=>$c{$a}} keys %c)[0..20];
      %o = %n; %n = undef; print ""
    }'

Outputs something like:

0       System Idle Process     588.12377
2196    sh.exe  107.00075
248     svchost.exe     85.80055
7140    explorer.exe    26.52017
[...]

every second.

Note that if the System Idle Process shows just under 800% on an idle system, that's because your system has 8 CPU cores (well at least 8 threads) as that counts the CPU time of all CPUs.

Also note that the EVERY:1 above is a lie. wmic doesn't seem to give that output every second. More likely, it sleeps roughly 1 second between each report and doesn't compensate for the time it takes to compute the report. So in practice, it will run every 1 second and a bit which means those percentages are not very accurate and slightly overestimated.

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