/usr/lib/python2.7/dist-packages/celery/utils/sysinfo.py is in python-celery 4.1.0-2ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | # -*- coding: utf-8 -*-
"""System information utilities."""
from __future__ import absolute_import, unicode_literals
import os
from math import ceil
from kombu.utils.objects import cached_property
__all__ = ['load_average', 'df']
if hasattr(os, 'getloadavg'):
def _load_average():
return tuple(ceil(l * 1e2) / 1e2 for l in os.getloadavg())
else: # pragma: no cover
# Windows doesn't have getloadavg
def _load_average(): # noqa
return (0.0, 0.0, 0.0)
def load_average():
"""Return system load average as a triple."""
return _load_average()
class df(object):
"""Disk information."""
def __init__(self, path):
self.path = path
@property
def total_blocks(self):
return self.stat.f_blocks * self.stat.f_frsize / 1024
@property
def available(self):
return self.stat.f_bavail * self.stat.f_frsize / 1024
@property
def capacity(self):
avail = self.stat.f_bavail
used = self.stat.f_blocks - self.stat.f_bfree
return int(ceil(used * 100.0 / (used + avail) + 0.5))
@cached_property
def stat(self):
return os.statvfs(os.path.abspath(self.path))
|