AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题

问题[ps](server)

Martin Hope
jhericks
Asked: 2021-09-24 16:29:02 +0800 CST

为什么`ps -x | grep foo` 是否包含 grep 命令?

  • 1

我知道它确实(通常)包括 grep 进程,并且我知道添加 | grep -v grep或 grepping[f]oo会阻止它,但我的问题更多是关于我猜的操作顺序。

例如,在这个人为的例子中,我看到了几个 grep 进程:

% ps -x | grep login | grep login | grep login | grep login
 2475 ??         0:00.03 /usr/libexec/loginitemregisterd
 2115 ttys004    0:00.04 login -fp jasonerickson
29715 ttys004    0:00.00 grep login
29716 ttys004    0:00.00 grep login
29717 ttys004    0:00.00 grep login
29718 ttys004    0:00.00 grep login

这告诉我ps -x必须在该行最后执行,因为它列出了所有后续的 grep 命令。但是,它并不一致。有时它会列出 4 或 3 或 2 个,甚至没有 grep 进程。这对我来说意味着它并不总是最后的。

这是怎么回事?

shell shell-scripting ps
  • 2 个回答
  • 1571 Views
Martin Hope
Usman
Asked: 2020-08-29 05:15:42 +0800 CST

如何从本地使用 powershell 连接到远程服务器。Enter-PSSession 不工作(不相关的 Exchange 服务)

  • -1

我正在尝试使用本地 powershell 会话连接到远程计算机。

为此,我尝试使用本地 powershell Enter-PSSession 或 New-PSSession 命令作为:

$session = New-PSSession -ConnectionUri 'http://testserverUri.dom/PowerShell'

但是我总是在异常之后得到。

New-PSSession : [testserveruri.dom] Connecting to remote server apdv0710.forest7.dom failed with the following
error message : The WinRM client sent a request to an HTTP server and got a response saying the requested HTTP URL was
not available. This is usually returned by a HTTP server that does not support the WS-Management protocol. For more
information, see the about_Remote_Troubleshooting Help topic.
At line:1 char:12
+ $session = New-PSSession -ConnectionUri 'http://testserverUri.dom/ ...
+            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotin
   gTransportException
    + FullyQualifiedErrorId : URLNotAvailable,PSSessionOpenFailed

我还使用了其他变体:

    Enter-PSSession -Authentication Kerberos -ConnectionUri 'http://testserveruri.dom/PowerShell' -Cred $credential
    Enter-PSSession : Connecting to remote server apdv0710.forest7.dom failed with the following error message : The WinRM
    client sent a request to an HTTP server and got a response saying the requested HTTP URL was not available. This is
    usually returned by a HTTP server that does not support the WS-Management protocol. For more information, see the
    about_Remote_Troubleshooting Help topic.
    At line:1 char:12
    + $session = Enter-PSSession -Authentication Kerberos -ConnectionUri 'h ...
    +            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidArgument: (http://testserveruri.dom/PowerShell:Uri) [Enter-PSSession], PSRemot
       ingTransportException
        + FullyQualifiedErrorId : CreateRemoteRunspaceFailed

在大多数情况下,我得到了第一个例外。

当我使用 C# 打开运行空间并为 WSManConnectionInfo 对象提供远程服务器 powerSell url 时,也会发生同样的异常。

我已经对 winrm 命令进行了各种处理,但这并不能真正解决问题。如何摆脱这个问题?

powershell remoting winrm ps
  • 2 个回答
  • 1540 Views
Martin Hope
Emerson Prado
Asked: 2020-07-26 08:57:22 +0800 CST

sar 和 top 显示高 cpu 使用率,但 vmstat 和 ps 显示低 cpu 使用率。为什么?

  • 0

我正在诊断一个高 CPU 使用率事件,我发现来自 的数字之间存在一个奇怪的差异ps/vmstat,显示几乎为 0%,sar/top而 显示几乎为 100%(用户 + 系统):

sar 1 5
Linux 2.6.9-67.ELsmp (uxdfl712)         07/25/2020

01:48:31 PM       CPU     %user     %nice   %system   %iowait     %idle
01:48:32 PM       all     43.83      0.00     56.17      0.00      0.00
01:48:33 PM       all     42.68      0.00     57.32      0.00      0.00
01:48:34 PM       all     42.57      0.00     57.43      0.00      0.00
01:48:35 PM       all     43.18      0.00     56.82      0.00      0.00
Average:          all     43.14      0.00     56.86      0.00      0.00

vmstat
procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in    cs us sy id wa
32  0      0 10493612 233320 4485160    0    0     0    14    0     1  0  0 100  0

ps -e hao %cpu | awk '{ sum += $1 } END { print sum }'
0.2

top -bn 1 |
sed '1,/PID USER      PR  NI %CPU/d' |
awk '{ sum += $5 } END { print sum }'
398

我在 StackExchange 和其他地方进行了很多搜索,但我只能找到有关虚拟化内容(这是一台物理机器)和 CPU 负载的参考资料,这不是我的问题。我也检查了/proc/<PID>/stat,但没有发现任何提示。

为什么这些命令显示不同的数字?他们实际上是在查询不同的东西吗?或者可执行文件可能太旧和错误(请参阅下面的服务器数据 - 我确实对它的过时程度感到恐惧)。

谢谢!

uname -r
2.6.9-67.ELsmp

cat /etc/redhat-release
Red Hat Enterprise Linux ES release 4 (Nahant Update 6)

yum provides `which sar` | grep installed
sysstat.i386                             5.0.5-16.rhel4         installed       

yum provides `which vmstat` | grep installed
procps.i386                              3.2.3-8.9              installed       

yum provides `which ps`
<Too many providers>
ps -V
procps version 3.2.3

yum provides `which top` | grep installed
procps.i386                              3.2.3-8.9              installed       

grep -c processor /proc/cpuinfo 
4
linux vmstat sar cpu-usage ps
  • 1 个回答
  • 934 Views
Martin Hope
Jeff
Asked: 2017-04-23 03:12:26 +0800 CST

“ps aux”与 1 分钟平均服务器负载之间的差异

  • 0

我是一名 Linux 菜鸟,所以我试图找出一个差异。问题是与“ps aux”命令的输出相比,/proc/loadavg 中可用的 1 分钟平均负载没有意义。例如,有时 1 分钟平均负载达到 15+。鉴于我的 VPS 有 6 个内核,这是一个巨大的负载。然而,“ps aux”几乎没有显示任何负载——所有进程的 %CPU 加起来只有几个百分点。

我究竟做错了什么?这种差异是否是由于“ps”显示当前正在运行的进程,而高 1 分钟平均值可能是由不再运行的进程引起的?如果是这种情况,我如何查看过去一分钟内运行的所有进程的列表?

ps
  • 2 个回答
  • 334 Views
Martin Hope
compcentral
Asked: 2016-08-24 05:38:59 +0800 CST

如何列出在freebsd中启动服务的用户

  • 0

只是一个简单的问题,但我到处寻找,似乎找不到这个。我只需要知道哪个用户启动了特定服务。在这种情况下,我想知道哪个用户运行耳机服务(FreeNAS 监狱中的耳机插件)。

我尝试使用service headphones status,但这只是给了我 PID(23069)。有没有办法使用 PID 来列出用户?我也尝试过使用:ps 23069但这只给出了运行时间和路径。

service freebsd jail truenas ps
  • 1 个回答
  • 2517 Views
Martin Hope
Joshua Garcia
Asked: 2013-04-05 15:21:44 +0800 CST

使用具有用户定义格式的 ps 时,如何获得无限宽度的列?

  • 6

我正在使用 ps 和用户定义的格式,如下所示:

$ ps ax -o pid,args,psr,pcpu | grep python
2236 /usr/bin/python2.7 -u /home   2  0.0
2452 /usr/bin/python /usr/lib/un   2  0.0
2480 /usr/bin/python /usr/lib/ub   0  0.7
2501 /usr/bin/python /usr/lib/un   2  0.0
4129 /usr/bin/python /usr/bin/up   0  0.1
4792 grep --color=auto python      0  0.0
20665 /usr/bin/python /usr/lib/sy   0  0.0
27022 python                        0  0.0

我特别希望 args 的宽度不受限制。我知道我可以提供这样的设置宽度:

$ ps axww -o pid,args:100,psr,pcpu | grep python
2236 /usr/bin/python2.7 -u /home/joshua/Applications/eclipse-classic-4.2/plugins/org.python.pydev_2.7.3.2   2  0.0
2452 /usr/bin/python /usr/lib/unity-lens-video/unity-lens-video                                             2  0.0
2480 /usr/bin/python /usr/lib/ubuntuone-client/ubuntuone-syncdaemon                                         3  0.7
2501 /usr/bin/python /usr/lib/unity-scope-video-remote/unity-scope-video-remote                             2  0.0
4129 /usr/bin/python /usr/bin/update-manager --no-focus-on-map                                              2  0.1
4905 grep --color=auto python                                                                               2  0.0

20665 /usr/bin/python /usr/lib/系统服务/系统服务-d 0 0.0 27022 蟒蛇 0 0.0

我试过使用 ww 选项无限宽度,但它不起作用。这是我在尝试 ww 时使用的命令:

$ ps axww -o pid,args,psr,pcpu | grep python
ps
  • 1 个回答
  • 2381 Views
Martin Hope
Alaa Alomari
Asked: 2012-06-19 22:21:57 +0800 CST

Nginx/php-fpm进程陷入不可中断睡眠

  • 2

我收到了关于服务器的 nagios 严重警告,当我检查时ps -aux我发现所有的 nginx (php-fpm) 都处于不间断睡眠状态

www-数据 1330 0.4 0.3 299992 108560 ?D 16:06 0:16 php-fpm:池 www
www-数据 1338 0.4 0.2 254728 92728 ?D 16:06 0:16 php-fpm:池 www
www-数据 1346 0.4 0.3 293544 100272 ?D 16:06 0:17 php-fpm:池 www
www-数据 1356 0.7 0.3 302504 101532 ?D 16:06 0:29 php-fpm:池 www
www-数据 1357 0.3 0.2 270672 85952 ?D 16:06 0:13 php-fpm:池 www
....

我被它困住了,甚至无法重新启动 nginx。最后我重新启动服务器来解决问题!
虽然我在 /etc/php5/fpm/php.ini 中有这个

emergency_restart_threshold=10
emergency_restart_interval=1 米
process_control_timeout=10s

这意味着 php5-fpm 应该在这种情况下重新启动,但它没有!
知道什么可能导致这些进程进入不间断的睡眠状态,以及将来如何避免这种情况?
谢谢你的帮助

nginx php-fpm ps
  • 1 个回答
  • 2162 Views
Martin Hope
OJ278
Asked: 2012-05-14 09:21:14 +0800 CST

ps 显示 migration/* 进程消耗大量 CPU,但 top 对此保持沉默

  • 1

这是 ps 命令的结果,只显示前 10 行

ps aufx | head
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         2  0.0  0.0      0     0 ?        S    May08   0:00 [kthreadd]
root         3  0.0  0.0      0     0 ?        S    May08   0:04  \_ [ksoftirqd/0]
**root         6 98.5  0.0      0     0 ?        S    May08 6841:08  \_ [migration/0]**
**root         7 99.9  0.0      0     0 ?        S    May08 6933:53  \_ [migration/1]**
root         9  0.0  0.0      0     0 ?        S    May08   0:04  \_ [ksoftirqd/1]
**root        11 95.3  0.0      0     0 ?        S    May08 6618:59  \_ [migration/2]**
root        12  0.0  0.0      0     0 ?        S    May08   0:00  \_ [kworker/2:0]
root        13  0.0  0.0      0     0 ?        S    May08   0:14  \_ [ksoftirqd/2]
**root        14 94.6  0.0      0     0 ?        S    May08 6569:27  \_ [migration/3]**

但是 top 命令没有显示任何关于迁移进程/线程的特殊信息。

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 5377 root      13  -7 64304  45m  11m S    2  1.5 169:28.81 Xorg
 7368 user2    16  -4  457m  98m  34m S    2  3.3  95:06.16 application
 5555 root      10 -10 64212  20m 2820 S    1  0.7  97:04.17 application
 7400 user  16  -4  416m  96m  30m S    1  3.2  93:15.77 application
 7903 user1    16  -4  402m  90m  32m S    1  3.0  59:56.47 application
 7396 user  16  -4  433m  98m  30m S    1  3.3  93:20.15 application
 7401 user  16  -4  417m  98m  30m S    1  3.3  93:05.87 application
 7403 user     16  -4  416m  96m  30m S    1  3.2  93:01.16 application
  500 root      20   0     0    0    0 S    0  0.0   0:46.80 jbd2/sda3-8
 1017 root      20   0  4536  696  476 S    0  0.0  17:38.05 cgrulesengd
 6703 user      12  -8 55240  17m  16m S    0  0.6   3:27.26 application
 7269 root      18  -2 10652 4892 2388 S    0  0.2   6:46.83 python2.5
...

操作系统:debian squeeze
内核:2.6.32

debian monitoring top ps
  • 2 个回答
  • 8993 Views
Martin Hope
Jürgen Thelen
Asked: 2012-05-09 01:16:52 +0800 CST

RHEL/Apache - WCHAN="semtim" 的含义

  • 0

WCHAN="semtim" 是什么意思?

ps -ylC httpd

S   UID   PID  PPID  C PRI  NI    RSS     SZ WCHAN  TTY      TIME CMD
S     0 25330     1  0  78   0  16168 170563 -      ?    00:00:14 httpd
R    48 16566 25330  4  76   0  36864 174156 -      ?    00:00:02 httpd
S    48 31450 25330  2  75   0 109992 186745 -      ?    00:02:24 httpd
S    48 31460 25330  2  75   0 115724 186745 semtim ?    00:02:11 httpd
S    48 23069 25330  1  75   0 116812 186745 semtim ?    00:02:13 httpd
S    48 12335 25330  2  75   0 117444 186745 -      ?    00:03:48 httpd
S    48 23130 25330  1  75   0 118616 200530 -      ?    00:01:54 httpd
S    48 23205 25330  2  77   0 119044 187769 semtim ?    00:02:50 httpd
S    48 23138 25330  2  75   0 120436 186745 semtim ?    00:02:39 httpd
S    48 23194 25330  1  75   0 120544 186745 semtim ?    00:02:16 httpd
S    48 12309 25330  2  75   0 120604 186745 semtim ?    00:03:00 httpd
S    48 23204 25330  2  75   0 120848 186489 semtim ?    00:02:41 httpd
S    48 23202 25330  3  76   0 121584 186745 semtim ?    00:03:45 httpd
S    48 31454 25330  2  75   0 122516 200530 semtim ?    00:02:12 httpd

有问题的服务器是 Red Hat 4.1.2-52 系统(内核 2.6.18),运行带mpm_prefork模块的 Apache 2.2.3。

查看boot/System.map-2.6.18-308.1.1.el5文件我可以找到:

ffffffff80122b12 T compat_sys_semtimedop
ffffffff80125203 T sys_semtimedop

但我既不确定其中之一是否是 semtim,也不确定它们是什么semtim意思。

redhat apache-2.2 process ps
  • 1 个回答
  • 2232 Views
Martin Hope
John
Asked: 2010-03-17 08:37:05 +0800 CST

在 Linux 中,当我使用 PS 命令时,为什么会看到多行 www-data?

  • 2

我有一个使用 ubuntu 9.10、apache2、mysql5 和 php5 的 LAMP 服务器。

当我通过 shell 以 root 身份登录时,我运行“ps aux”命令并看到类似以下内容

www-data  3151  0.1  4.3 220024 31032 ?        S    12:22   0:00 /usr/sbin/apache2 -k start
www-data  3153  0.2  3.6 214776 26020 ?        S    12:22   0:01 /usr/sbin/apache2 -k start
www-data  3162  0.3  5.1 225060 36920 ?        S    12:26   0:01 /usr/sbin/apache2 -k start
www-data  3163  0.1  4.1 218872 29664 ?        S    12:26   0:00 /usr/sbin/apache2 -k start

我怎么会看到多行 www-data?每条线是否代表我网站上的实际用户?

我有时会遇到内存问题,所以我试图确定这些 www-data 统计数据是否相关。

linux apache-2.2 ps
  • 2 个回答
  • 1833 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve