Viewing ulimits in use by a running process

One of my colleagues was working with the support desk this morning on a BIND based open file limit problem and he stumbled across some useful tools that I would like to share with you.

He was trying to work out what hard and soft open file limits the named process was using, and he found the following was a good way to get this information for a running process.

For Linux he used the /proc file system to access the ulimits for the named process:

[qipadmin@Dike ~]$ ps -ef | grep named

qipadmin  4622     1  0 Feb12 ?        00:04:02 /opt/named/current/bin/named -c /opt/named/current/conf/named.conf -u qipadmin

qipadmin 27336 25795  0 10:19 pts/0    00:00:00 grep named

[qipadmin@Dike ~]$ cat /proc/4622/limits

Limit                     Soft Limit           Hard Limit           Units

Max cpu time              unlimited            unlimited            ms

Max file size             unlimited            unlimited            bytes

Max data size             unlimited            unlimited            bytes

Max stack size            unlimited            unlimited            bytes

Max core file size        unlimited            unlimited            bytes

Max resident set          unlimited            unlimited            bytes

Max processes             16373                16373                processes

Max open files            1048576              1048576              files

Max locked memory         65536                65536                bytes

Max address space         unlimited            unlimited            bytes

Max file locks            unlimited            unlimited            locks

Max pending signals       16373                16373                signals

Max msgqueue size         819200               819200               bytes

Max nice priority         0                    0

Max realtime priority     0                    0

Max realtime timeout      unlimited            unlimited            us

And for Solaris he used the plimit command, which appears to ship by default:

-bash-3.00# ps -ef | grep named

    root  1677     1   0 10:11:27 ?           0:00 named

-bash-3.00# plimit 1677

1677:   named

   resource              current         maximum

  time(seconds)         unlimited       unlimited

  file(blocks)          unlimited       unlimited

  data(kbytes)          unlimited       unlimited

  stack(kbytes)         unlimited       unlimited

  coredump(blocks)      unlimited       unlimited

  nofiles(descriptors)  unlimited       unlimited

  vmemory(kbytes)       unlimited       unlimited

 

We can see in both cases that BIND has raised the soft limits right up to the hard limits (1048576 for Linux and unlimited for Solaris).

This is also a good way to see that a ulimit command defined in a startup script is actually being used by a process.

Advertisements
This entry was posted in Computers and Internet and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s