Merge remote-tracking branch 'LCTT/master'

This commit is contained in:
Xingyu Wang 2020-08-01 21:34:04 +08:00
commit 30e7ad62aa
2 changed files with 38 additions and 50 deletions

View File

@ -1,40 +1,36 @@
[#]: collector: (lujun9972) [#]: collector: (lujun9972)
[#]: translator: (geekpi) [#]: translator: (geekpi)
[#]: reviewer: ( ) [#]: reviewer: (wxy)
[#]: publisher: ( ) [#]: publisher: (wxy)
[#]: url: ( ) [#]: url: (https://linux.cn/article-12477-1.html)
[#]: subject: (Bash Script to Check How Long the High CPU/Memory Consumption Processes Runs on Linux) [#]: subject: (Bash Script to Check How Long the High CPU/Memory Consumption Processes Runs on Linux)
[#]: via: (https://www.2daygeek.com/bash-script-to-check-how-long-the-high-cpu-memory-consumption-processes-runs-on-linux/) [#]: via: (https://www.2daygeek.com/bash-script-to-check-how-long-the-high-cpu-memory-consumption-processes-runs-on-linux/)
[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) [#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/)
在 Linux 中运行 Bash 脚本检查高 CPU/内存消耗进程 实用脚本:检查高 CPU / 内存消耗进程
====== ======
过去,我们写了三篇不同的文章来使用 Linux 命令来识别。 ![](https://img.linux.net.cn/data/attachment/album/202008/01/205420jllu1nsngu9qszu5.jpg)
你可以通过下面相关的 URL 立即访问。 过去,我们写了三篇不同的文章来使用 Linux 命令来识别这些进程。
* **[如何在 Linux 中查找高 CPU 消耗进程][1]**
* **[如何找出 Linux 中的高内存消耗进程][2]**
* **[检查进程在 Linux 中运行了多长时间的五种方法][3]**
你可以通过下面相关的 URL 立即访问:
* [如何在 Linux 中找出 CPU 占用高的进程][1]
* [如何在 Linux 中找出内存消耗最大的进程][2]
* [在 Linux 中如何查找一个命令或进程的执行时间][3]
本教程中包含两个脚本,它们可以帮助你确定 Linux 上高 CPU/内存消耗进程的运行时间。 本教程中包含两个脚本,它们可以帮助你确定 Linux 上高 CPU/内存消耗进程的运行时间。
该脚本将显示进程 ID进程的所有者进程的名称以及进程的运行时间。 该脚本将显示进程 ID、进程的所有者、进程的名称以及进程的运行时间。这将帮助你确定哪些必须事先完成作业正在超时运行。这可以使用 `ps` 命令来实现。
这将帮助你确定哪些(必须事先完成)作业正在超时运行。
在可以使用 ps 命令来实现。
### 什么是 ps 命令 ### 什么是 ps 命令
ps 代表进程状态,它显示有关系统上活动/正在运行的进程的信息。 `ps`<ruby>进程状态<rt>processes status</rt></ruby>,它显示有关系统上活动/正在运行的进程的信息。
它提供了当前进程的快照以及详细信息,例如用户名、用户 ID、CPU 使用率、内存使用率、进程开始日期和时间等。 它提供了当前进程的快照以及详细信息,例如用户名、用户 ID、CPU 使用率、内存使用率、进程开始日期和时间等。
### 1Bash 脚本检查高 CPU 消耗进程在 Linux 上运行了多长时间 #### 1检查高 CPU 消耗进程在 Linux 上运行了多长时间的 Bash 脚本
该脚本将帮助你确定高 CPU 消耗进程在 Linux 上运行了多长时间。 该脚本将帮助你确定高 CPU 消耗进程在 Linux 上运行了多长时间。
@ -56,13 +52,13 @@ done | column -t
echo "--------------------------------------------------" echo "--------------------------------------------------"
``` ```
**”long-running-cpu-proc.sh“** 设置可执行**[Linux 文件权限][4]** `long-running-cpu-proc.sh` 设置可执行的 [Linux 文件权限][4]
``` ```
# chmod +x /opt/scripts/long-running-cpu-proc.sh # chmod +x /opt/scripts/long-running-cpu-proc.sh
``` ```
运行此脚本时,你将获得类似以下的输出 运行此脚本时,你将获得类似以下的输出
``` ```
# sh /opt/scripts/long-running-cpu-proc.sh # sh /opt/scripts/long-running-cpu-proc.sh
@ -82,7 +78,7 @@ daygeek 6301 Web 57:40
---------------------------------------------------- ----------------------------------------------------
``` ```
### 2Bash 脚本检查高内存消耗进程在 Linux 上运行了多长时间 #### 2检查高内存消耗进程在 Linux 上运行了多长时间的 Bash 脚本
该脚本将帮助你确定最大的内存消耗进程在 Linux 上运行了多长时间。 该脚本将帮助你确定最大的内存消耗进程在 Linux 上运行了多长时间。
@ -104,13 +100,13 @@ done | column -t
echo "--------------------------------------------------" echo "--------------------------------------------------"
``` ```
**”long-running-memory-proc.sh“** 设置可执行 Linux 文件权限。 `long-running-memory-proc.sh` 设置可执行的 Linux 文件权限。
``` ```
# chmod +x /opt/scripts/long-running-memory-proc.sh # chmod +x /opt/scripts/long-running-memory-proc.sh
``` ```
运行此脚本时,你将获得类似以下的输出 运行此脚本时,你将获得类似以下的输出
``` ```
# sh /opt/scripts/long-running-memory-proc.sh # sh /opt/scripts/long-running-memory-proc.sh
@ -137,13 +133,13 @@ via: https://www.2daygeek.com/bash-script-to-check-how-long-the-high-cpu-memory-
作者:[Magesh Maruthamuthu][a] 作者:[Magesh Maruthamuthu][a]
选题:[lujun9972][b] 选题:[lujun9972][b]
译者:[geekpi](https://github.com/geekpi) 译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.2daygeek.com/author/magesh/ [a]: https://www.2daygeek.com/author/magesh/
[b]: https://github.com/lujun9972 [b]: https://github.com/lujun9972
[1]: https://www.2daygeek.com/how-to-find-high-cpu-consumption-processes-in-linux/ [1]: https://linux.cn/article-11678-1.html
[2]: https://www.2daygeek.com/linux-find-top-memory-consuming-processes/ [2]: https://linux.cn/article-11542-1.html
[3]: https://www.2daygeek.com/how-to-check-how-long-a-process-has-been-running-in-linux/ [3]: https://linux.cn/article-10261-1.html
[4]: https://www.2daygeek.com/understanding-linux-file-permissions/ [4]: https://www.2daygeek.com/understanding-linux-file-permissions/

View File

@ -1,8 +1,8 @@
[#]: collector: (lujun9972) [#]: collector: (lujun9972)
[#]: translator: (geekpi) [#]: translator: (geekpi)
[#]: reviewer: ( ) [#]: reviewer: (wxy)
[#]: publisher: ( ) [#]: publisher: (wxy)
[#]: url: ( ) [#]: url: (https://linux.cn/article-12476-1.html)
[#]: subject: (How to configure an SSH proxy server with Squid) [#]: subject: (How to configure an SSH proxy server with Squid)
[#]: via: (https://fedoramagazine.org/configure-ssh-proxy-server/) [#]: via: (https://fedoramagazine.org/configure-ssh-proxy-server/)
[#]: author: (Curt Warfield https://fedoramagazine.org/author/rcurtiswarfield/) [#]: author: (Curt Warfield https://fedoramagazine.org/author/rcurtiswarfield/)
@ -10,13 +10,13 @@
如何使用 Squid 配置 SSH 代理服务器 如何使用 Squid 配置 SSH 代理服务器
====== ======
![][1] ![](https://img.linux.net.cn/data/attachment/album/202008/01/162730tx0czx60xs6wz00c.jpg)
有时你无法从本地连接到 SSH 服务器。还有时,你可能想为 SSH 连接添加额外的安全层。在这些情况下,通过代理服务器连接到另一台 SSH 服务器是一种解决方式。 有时你无法从本地连接到 SSH 服务器。还有时,你可能想为 SSH 连接添加额外的安全层。在这些情况下,通过代理服务器连接到 SSH 服务器是一种解决方式。
[Squid][2] 是提供缓存和代理服务的全功能代理服务器应用。通常通过在浏览过程中重用和缓存以前请求的网页来帮助缩短响应时间并减少网络带宽。 [Squid][2] 是提供缓存和代理服务的全功能代理服务器应用。它通常用于在浏览过程中重用和缓存以前请求的网页来帮助缩短响应时间并减少网络带宽。
但是在本篇中,你将配置 Squid 作为 SSH 代理服务器,因为它是易于配置的强大的受信任代理服务器。 但是在本篇中,你将配置 Squid 作为 SSH 代理服务器,因为它是强大的受信任代理服务器,易于配置
### 安装和配置 ### 安装和配置
@ -26,9 +26,9 @@
$ sudo dnf install squid -y $ sudo dnf install squid -y
``` ```
squid 配置文件非常广泛但是我们只需要配置其中一些。Squid 使用访问控制列表来管理连接。 squid 配置文件非常庞大但是我们只需要配置其中一些。Squid 使用访问控制列表来管理连接。
编辑 _/etc/squid/squid.conf_ 文件,确保你有下面解释的两行。 编辑 `/etc/squid/squid.conf` 文件,确保你有下面解释的两行。
首先,指定你的本地 IP 网络。默认配置文件已经列出了最常用的,但是如果没有,你需要添加你的配置。例如,如果你的本地 IP 网络范围是 192.168.1.X那么这行会是这样 首先,指定你的本地 IP 网络。默认配置文件已经列出了最常用的,但是如果没有,你需要添加你的配置。例如,如果你的本地 IP 网络范围是 192.168.1.X那么这行会是这样
@ -58,9 +58,9 @@ $ sudo firewall-cmd --reload
### 测试 ssh 代理连接 ### 测试 ssh 代理连接
要通过 ssh 代理服务器连接到服务器,我们将使用 netcat。 要通过 ssh 代理服务器连接到服务器,我们将使用 `netcat`
如果尚未安装 _nmap-ncat_,请安装它: 如果尚未安装 `nmap-ncat`,请安装它:
``` ```
$ sudo dnf install nmap-ncat -y $ sudo dnf install nmap-ncat -y
@ -82,18 +82,10 @@ $ ssh user@example.com -o "ProxyCommand nc --proxy 192.168.1.63:3128 %h %p"
以下是这些选项的含义: 以下是这些选项的含义:
* _ProxyCommand_ 告诉 ssh 使用代理命令。 * `ProxyCommand` 告诉 ssh 使用代理命令。
* `nc` 用于建立与代理服务器连接的命令。这是 netcat 命令。
* `%h` 代理服务器的主机名或 IP 地址的占位符。
* _nc_ 用于建立与代理服务器连接的命令。这是 netcat 命令。 * `%p` 代理服务器端口号的占位符。
* **%**_h_ 代理服务器的主机名或 IP 地址的占位符。
* **%**_p_ 代理服务器端口号的占位符。
有很多方法可以配置 SSH 代理服务器,但这是入门​​的简单方法。 有很多方法可以配置 SSH 代理服务器,但这是入门​​的简单方法。
@ -104,7 +96,7 @@ via: https://fedoramagazine.org/configure-ssh-proxy-server/
作者:[Curt Warfield][a] 作者:[Curt Warfield][a]
选题:[lujun9972][b] 选题:[lujun9972][b]
译者:[geekpi](https://github.com/geekpi) 译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出