Im uses Pylons in combination with the WMI module to perform some basic system monitoring of several machines, for POSIX systems everything is simple - for Windows - not so much.
Making a request to the Pylons server to get the current CPU, however, it does not work well, or at least with the WMI module. At first I just did (something) the following:
c = wmi.WMI()
for cpu in c.Win32_Processor():
value = cpu.LoadPercentage
However, this caused an error while accessing this module through Pylons (GET http: // ip: port / cpu ):
raise x_wmi_uninitialised_thread ("WMI returned a syntax error: you're probably running inside a thread without first calling pythoncom.CoInitialize[Ex]")
x_wmi_uninitialised_thread: <x_wmi: WMI returned a syntax error: you're probably running inside a thread without first calling pythoncom.CoInitialize[Ex] (no underlying exception)>
Looking at http://timgolden.me.uk/python/wmi/tutorial.html , I wrapped the code according to the example in the "CoInitialize and CoUninitialize" section, which makes the code but it keeps throwing"Win32 exception occurred releasing IUnknown at..."
http://mail.python.org/pipermail/python-win32/2007-August/006237.html , , pythoncom._GetInterfaceCount() 20.
, - , , , .
,
EDIT: - , WMI, http://msdn.microsoft.com/en-us/library/aa394531%28VS.85%29.aspx, " , .