/usr/share/checkbox/scripts/memory_info is in checkbox 0.13.7.
This file is owned by root:root, with mode 0o755.
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 | #!/usr/bin/python
import re
import sys
def get_meminfo():
meminfo = {}
for line in open("/proc/meminfo").readlines():
match = re.match(r"(.*):\s+(.*)", line)
if match:
key = match.group(1)
value = match.group(2)
meminfo[key] = value
return meminfo
def main(args):
meminfo = get_meminfo()
amount, units = meminfo["MemTotal"].split()
amount = float(amount)
next_units = {'kB': 'MB',
'MB': 'GB'}
while amount > 1024:
amount = amount / 1024
units = next_units[units]
print ("%.1f %s"
% (amount, units))
return 0
if __name__ == "__main__":
sys.exit(main(sys.argv[1:]))
|