检查 Linux 中给定进程的开放 FD 限制 [英] Check the open FD limit for a given process in Linux

查看:19
本文介绍了检查 Linux 中给定进程的开放 FD 限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近有一个 Linux 进程泄露"了文件描述符:它打开了它们,但没有正确关闭其中的一些.

I recently had a Linux process which "leaked" file descriptors: It opened them and didn't properly close some of them.

如果我对此进行了监控,我可以提前知道该过程已达到极限.

If I had monitored this, I could tell – in advance – that the process was reaching its limit.

是否有一种不错的 Bash 或 Python 方法来检查 Ubuntu Linux 系统中给定进程的 FD 使用率?

Is there a nice, Bash or Python way to check the FD usage ratio for a given process in a Ubuntu Linux system?

我现在知道如何检查有多少打开的文件描述符了;我只需要知道一个进程允许使用多少个文​​件描述符.某些系统(如 Amazon EC2)没有 /proc/pid/limits 文件.

I now know how to check how many open file descriptors are there; I only need to know how many file descriptors are allowed for a process. Some systems (like Amazon EC2) don't have the /proc/pid/limits file.

推荐答案

计算 /proc//fd/ 中的条目.应用于进程的硬限制和软限制可以在 /proc//limits 中找到.

Count the entries in /proc/<pid>/fd/. The hard and soft limits applying to the process can be found in /proc/<pid>/limits.

这篇关于检查 Linux 中给定进程的开放 FD 限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆