| from discover import provides |
| from utils import SensorInfo, is_dev_accepted |
| |
| |
| # return this values or setted in allowed |
| ram_fields = [ |
| 'MemTotal', |
| 'MemFree', |
| 'Buffers', |
| 'Cached', |
| 'SwapCached', |
| 'Dirty', |
| 'Writeback', |
| 'SwapTotal', |
| 'SwapFree' |
| ] |
| |
| |
| @provides("system-ram") |
| def sysram_stat(disallowed_prefixes=None, allowed_prefixes=None): |
| if allowed_prefixes is None: |
| allowed_prefixes = ram_fields |
| results = {} |
| for line in open('/proc/meminfo'): |
| vals = line.split() |
| dev_name = vals[0] |
| |
| dev_ok = is_dev_accepted(dev_name, |
| disallowed_prefixes, |
| allowed_prefixes) |
| |
| if dev_ok: |
| results[dev_name] = SensorInfo(int(vals[1]), False) |
| return results |