ProcLimits - File /proc/<PID>/limits

Parser for parsing the the limits file under special /proc/<PID> directory.

class insights.parsers.proc_limits.HttpdLimits(context)[source]

Bases: ProcLimits

Class for parsing the limits file of the httpd process.

class insights.parsers.proc_limits.Limits(data={})[source]

Bases: LegacyItemAccess

An object representing a line in the /proc/limits. Each entry contains below fixed attributes:

hard_limit

Hard limit

Type

str

soft_limit

Soft limit

Type

str

units

Unit of the limit value

Type

str

items()[source]

To keep backward compatibility and let it can be iterated as a dictionary.

class insights.parsers.proc_limits.MysqldLimits(context)[source]

Bases: ProcLimits

Class for parsing the limits file of the mysqld process.

class insights.parsers.proc_limits.OvsVswitchdLimits(context)[source]

Bases: ProcLimits

Class for parsing the limits file of the ovs-vswitchd process.

class insights.parsers.proc_limits.ProcLimits(context)[source]

Bases: Parser

Base class for parsing the limits file under special /proc/<PID> directory into a list of dictionaries by using the insights.parsers.parse_fixed_table() function.

Each line is a dictionary of fields, named according to their definitions in Limit.

This class provides the ‘__len__’ and ‘__iter__’ methods to allow it to be used as a list to iterate over the parsed dictionaries.

Each of the resource provided by this file will be set as an attribute. The attribute name is the resource name got from the Limit column, which is converted to lowercase and joined the words with underline ‘_’. If not sure about whether an attribute is exist or not, check it via the ‘__contains__’ method before fetching it. The attribute value is set to a Limits which wraps the corresponding hard_limit, soft_limit and units.

Typical content looks like:

Limit                     Soft Limit           Hard Limit           Units
Max cpu time              unlimited            unlimited            seconds
Max file size             unlimited            unlimited            bytes
Max data size             unlimited            unlimited            bytes
Max stack size            10485760             unlimited            bytes
Max core file size        0                    unlimited            bytes
Max resident set          unlimited            unlimited            bytes
Max processes             9                    99                   processes
Max open files            1024                 4096                 files
Max locked memory         65536                65536                bytes
Max address space         unlimited            unlimited            bytes
Max file locks            unlimited            unlimited            locks
Max pending signals       15211                15211                signals
Max msgqueue size         819200               819200               bytes
Max nice priority         0                    0
Max realtime priority     0                    0
Max realtime timeout      unlimited            unlimited            us

Examples

>>> len(proc_limits)
16
>>> proc_limits.max_processes.hard_limit
'99'
>>> proc_limits.max_processes.soft_limit
'9'
>>> 'max_cpu_time' in proc_limits
True
>>> proc_limits.max_cpu_time.soft_limit
'unlimited'
>>> proc_limits.max_cpu_time.units
'seconds'
Raises

insights.parsers.ParseException -- if the limits file is empty or doesn’t exist.

parse_content(content)[source]

This method must be implemented by classes based on this class.