Skip to content

Crashes if Softlimit is set to unlimited #383

Closed

Description

@Smithx10

File "/opt/conda/lib/python3.7/site-packages/prometheus_client/process_collector.py", line 84, in collect
value=float(line.split()[3]))
ValueError: could not convert string to float: b'unlimited'

https://github.com/prometheus/client_python/blob/master/prometheus_client/process_collector.py#L85

        try:
            with open(os.path.join(pid, 'limits'), 'rb') as limits:
                for line in limits:
                    if line.startswith(b'Max open file'):
                        max_fds = GaugeMetricFamily(self._prefix + 'max_fds',
                                                    'Maximum number of open file descriptors.',
                                                    value=float(line.split()[3]))
                        break
            open_fds = GaugeMetricFamily(self._prefix + 'open_fds',
                                         'Number of open file descriptors.',
                                         len(os.listdir(os.path.join(pid, 'fd'))))

Activity

  1. brian-brazil commented on Mar 15, 2019

    @brian-brazil
    Contributor

    Are you on Joyent? I believe this is non-standard output they produce.

  2. Smithx10 commented on Mar 16, 2019

    @Smithx10
    Author

    @brian-brazil, I believe you are correct.

    Attempting to set unlimited in Linux

    [root@demo ~]# ulimit -Hn unlimited
    -bash: ulimit: open files: cannot modify limit: Operation not permitted
    [root@demo ~]# ulimit -Hn "unlimited"
    -bash: ulimit: open files: cannot modify limit: Operation not permitted
    

    I'll bring this up in #SmartOS and see if this semantic can be fixed. For now if anyone reads this, just set integer limits. Ex. ulimit -Sn 1024, ulimit -Hn 4096.

    Thanks for the response 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions