blob: fa0c409838db997269af1b514598f3c47aa2be18 [file] [log] [blame]
Ved-vampirf0089e52015-03-16 15:52:54 +03001from discover import provides
2from utils import SensorInfo, is_dev_accepted
3
4
5# return this values or setted in allowed
6ram_fields = [
7 'MemTotal',
8 'MemFree',
9 'Buffers',
10 'Cached',
11 'SwapCached',
12 'Dirty',
13 'Writeback',
14 'SwapTotal',
15 'SwapFree'
16]
17
18
19@provides("system-ram")
20def sysram_stat(disallowed_prefixes=None, allowed_prefixes=None):
21 if allowed_prefixes is None:
22 allowed_prefixes = ram_fields
23 results = {}
24 for line in open('/proc/meminfo'):
25 vals = line.split()
26 dev_name = vals[0]
27
28 dev_ok = is_dev_accepted(dev_name,
29 disallowed_prefixes,
30 allowed_prefixes)
31
32 if dev_ok:
33 results[dev_name] = SensorInfo(int(vals[1]), False)
34 return results