# -*- encoding: utf-8 -*-
from ctypes import *
import os,time
class MEMORYSTATUS (Structure):
_fields_ = [('dwLength', c_ulong),#sizeof(MEMORYSTATUS)
('dwMemoryLoad',c_ulong), # percent of memory in use
('dwTotalPhys', c_ulong),#; // bytes of physical memory
('dwAvailPhys', c_ulong),#; // free physical memory bytes
('dwTotalPageFile',c_ulong),#; // bytes of paging file
('dwAvailPageFile', c_ulong),#; // free bytes of paging file
('dwTotalVirtual', c_ulong),#; // user bytes of address space
('dwAvailVirtual',c_ulong),#; // free user bytes
]
if os.name == 'nt':
mem = MEMORYSTATUS()
memptr = pointer(mem)
windll.kernel32.GlobalMemoryStatus(memptr)
print "mem used",mem.dwMemoryLoad,"%"
print "mem",mem.dwTotalPhys
else:
file = open('/proc/meminfo')
conf = {}
line = file.readline()
while line:
title, num, kb = line.split()
conf[title[:-1]] = int(num)
line = file.readline()
file.close()
from ctypes import *
import os,time
class MEMORYSTATUS (Structure):
_fields_ = [('dwLength', c_ulong),#sizeof(MEMORYSTATUS)
('dwMemoryLoad',c_ulong), # percent of memory in use
('dwTotalPhys', c_ulong),#; // bytes of physical memory
('dwAvailPhys', c_ulong),#; // free physical memory bytes
('dwTotalPageFile',c_ulong),#; // bytes of paging file
('dwAvailPageFile', c_ulong),#; // free bytes of paging file
('dwTotalVirtual', c_ulong),#; // user bytes of address space
('dwAvailVirtual',c_ulong),#; // free user bytes
]
if os.name == 'nt':
mem = MEMORYSTATUS()
memptr = pointer(mem)
windll.kernel32.GlobalMemoryStatus(memptr)
print "mem used",mem.dwMemoryLoad,"%"
print "mem",mem.dwTotalPhys
else:
file = open('/proc/meminfo')
conf = {}
line = file.readline()
while line:
title, num, kb = line.split()
conf[title[:-1]] = int(num)
line = file.readline()
file.close()