Hi Folks,
I'm trying to get memory usage for all processes on a windows box and then
later on I want to set up alerts if certain applications are using over a
certain amount of memory.
Here's what I have so far, but it's not working as expected. Any help
appreciated. Basically it looks like my problem is in getting the process
handle...
Thanks, Tom
import win32process
import win32api
class WinProcesses:
def __init__(self):
pass
def listprocesses(self):
for process in self.proclist():
try:
han = win32api.OpenProcess(1, 0, process)
print self.meminfo(han)
except:
print "Couldn't get process %s" % (process,)
def proclist(self):
return win32process.EnumProcesses()
def meminfo(self, handle):
return win32process.GetProcessMemoryInfo(handle)
if __name__=="__main__":
processes = WinProcesses()
test = processes.listprocesses()
print test
---------------------------------------
Tom Haddon
Equilar, Inc.
1710 South Amphlett Boulevard
Suite 312
San Mateo, CA 94402
650-286-4528 (phone)
650-286-4513 (fax)
[EMAIL PROTECTED]
CONFIDENTIALITY NOTICE:
This is a transmission from Equilar, Inc. and may contain information which is
confidential and proprietary. If you are not the addressee, any disclosure,
copying or distribution or use of the contents of this message is expressly
prohibited. If you have received this transmission in error, please destroy it
and notify us immediately at 650-286-4512. Internet and e-mail communications
are Equilar's property and Equilar reserves the right to retrieve and read any
message created, sent and received.
_______________________________________________
Python-win32 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-win32