473,395 Members | 1,986 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to get Windows system information?

Does anybody know how to get the:

Free hard disk space
Amount of CPU load
and Amount of RAM used

on windows? I am making an artificial intelligence program that has
"moods" based on how much stress the system is under, based on these
parameters. I think it could possibly be done via COM. I am not looking
for a cross-platform solution- just something that will work on
Windows. Thank you for your help!

Jan 13 '06 #1
8 2468
dp******@pacbell.net wrote:
Does anybody know how to get the:

Free hard disk space
Amount of CPU load
and Amount of RAM used

on windows? I am making an artificial intelligence program that has
"moods" based on how much stress the system is under, based on these
parameters. I think it could possibly be done via COM. I am not looking
for a cross-platform solution- just something that will work on
Windows. Thank you for your help!


Have a look at WMI* , it's specifically designed to getthat kind of
stuff, there is also a python layer for WMI**.

* http://msdn.microsoft.com/library/en..._reference.asp
** http://tgolden.sc.sabren.com/python/wmi.html

hth

--
mph
Jan 13 '06 #2
Martin P. Hellwig wrote:
dp******@pacbell.net wrote:
Does anybody know how to get the:

Free hard disk space
Amount of CPU load
and Amount of RAM used

on windows? I am making an artificial intelligence program that has
"moods" based on how much stress the system is under, based on these
parameters. I think it could possibly be done via COM. I am not looking
for a cross-platform solution- just something that will work on
Windows. Thank you for your help!


Have a look at WMI* , it's specifically designed to getthat kind of
stuff, there is also a python layer for WMI**.

* http://msdn.microsoft.com/library/en..._reference.asp
** http://tgolden.sc.sabren.com/python/wmi.html

hth


WMI sounds like the right way to go. I recently had to whack a little
WHS because I could find no Python interface without downloading
additional modules. Do you think Tim Golden would submit it for
inclusion with the standard Python build? If so, would that require
pywin32 to be in the build or could Tim do this through ctypes?
Jan 13 '06 #3
thank you!

from what I can see from the second website you listed, there is a way
to get harddisk space information, but is there any way to get CPU load
and RAM usage?

Jan 15 '06 #4
dp******@pacbell.net wrote:
thank you!

from what I can see from the second website you listed, there is a way
to get harddisk space information, but is there any way to get CPU load
and RAM usage?


Have a look at the snippet:

#>>> import wmi
#>>> t = wmi.WMI()
#>>> for i in t.Win32_PerfFormattedData_PerfOS_Memory():
# print(i)
#
#instance of Win32_PerfFormattedData_PerfOS_Memory
#{
# AvailableBytes = "1683038208";
# AvailableKBytes = "1643592";
# AvailableMBytes = "1605";
# CacheBytes = "89645056";
# CacheBytesPeak = "358023168";
# CacheFaultsPersec = 0;
# CommitLimit = "4131782656";
# CommittedBytes = "274153472";
# DemandZeroFaultsPersec = 91522;
# FreeSystemPageTableEntries = 150702;
# PageFaultsPersec = 91522;
# PageReadsPersec = 0;
# PagesInputPersec = 0;
# PagesOutputPersec = 0;
# PagesPersec = 0;
# PageWritesPersec = 0;
# PercentCommittedBytesInUse = 6;
# PoolNonpagedAllocs = 34580;
# PoolNonpagedBytes = "19292160";
# PoolPagedAllocs = 45037;
# PoolPagedBytes = "28307456";
# PoolPagedResidentBytes = "28053504";
# SystemCacheResidentBytes = "59023360";
# SystemCodeResidentBytes = "2568192";
# SystemCodeTotalBytes = "942080";
# SystemDriverResidentBytes = "0";
# SystemDriverTotalBytes = "6234112";
# TransitionFaultsPersec = 0;
# WriteCopiesPersec = 0;
#};
#
#>>> for i in t.Win32_PerfFormattedData_PerfOS_Processor():
# print(i)
#
#
#
#instance of Win32_PerfFormattedData_PerfOS_Processor
#{
# C1TransitionsPersec = "0";
# C2TransitionsPersec = "0";
# C3TransitionsPersec = "65";
# DPCRate = 0;
# DPCsQueuedPersec = 0;
# InterruptsPersec = 65;
# Name = "0";
# PercentC1Time = "0";
# PercentC2Time = "0";
# PercentC3Time = "95";
# PercentDPCTime = "0";
# PercentIdleTime = "100";
# PercentInterruptTime = "0";
# PercentPrivilegedTime = "0";
# PercentProcessorTime = "0";
# PercentUserTime = "0";
#};
#
#
#instance of Win32_PerfFormattedData_PerfOS_Processor
#{
# C1TransitionsPersec = "0";
# C2TransitionsPersec = "0";
# C3TransitionsPersec = "0";
# DPCRate = 0;
# DPCsQueuedPersec = 0;
# InterruptsPersec = 65;
# Name = "_Total";
# PercentC1Time = "0";
# PercentC2Time = "0";
# PercentC3Time = "0";
# PercentDPCTime = "0";
# PercentIdleTime = "0";
# PercentInterruptTime = "0";
# PercentPrivilegedTime = "0";
# PercentProcessorTime = "0";
# PercentUserTime = "0";
#};

--
mph
Jan 15 '06 #5
[posting through Google; not sure how it will format]

re info on WMI website: please note that the examples I
give no the WMI pages are *nowhere near* exhausting
what WMI can do. They don't even scratch the surface.
And I all too rarely add to them.

If you look around the net, you'll find absolutely loads
of recipes for doing things with WMI. And it's usually
easy to translate them into Python. So, for example,
Googling for WMI CPU load takes you straight to
this page:

http://www.robvanderwoude.com/wshexamples_0o.html

which (after some fairly intrusive boilerplate stuff)
ends up selecting from Win32_Processor. So, in
Python:

<code>
import wmi
c = wmi.WMI ()
for i in c.Win32_Processor ():
print i

# gives, among other things, a LoadPercentage
# field.
</code>

Now, what the different fields mean sometimes requires
a bit more research. But the Microsoft WMI pages
sometimes hit the spot, and indeed, a search for
WMI LoadPercentage

brings up this page:

http://msdn.microsoft.com/library/de...tml/mngwmi.asp

with a useful snippet on using WMI events to monitor
CPU Load.

And so on. By and large, whatever you can think of doing
with WMI, someone's done before. And if someone's done
it in VBS (or Perl, or whatever), we can do it in Python.

HTH
Tim

Jan 15 '06 #6
Thank you all! These tips answer my question. I am glad I discovered
this group.

Jan 16 '06 #7
For the memory, which of these fields tells you the total amount of
RAM? Thanks!

Jan 16 '06 #8
nevermind, found it

thanks all!

Jan 18 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Carlos G Benevides | last post by:
I have a ASP.Net web application that has two assemblies that run under com+. Under Windows 2000 the two assemblies are added to com+ automatically when instantiated from the web site. For this...
10
by: ThunderMusic | last post by:
Hi, How can I get if the Windows running is a server version? Is there a property somewhere that can tell me if the Windows version is a server edition (including server, advanced server, web...
2
by: Phil Stanton | last post by:
When designing a new form or report, the Default ForeColor is often something like -2147483640 which is the colour of Windows text (possibly black) and the default backColor is -2147483643...
5
by: RAJ | last post by:
hi plz tell me how to know "how window is going to close"... i have to right code for X button of forms... plz telll me thanks bye
2
by: Raed Sawalha | last post by:
i have a windows form(Main) with listview, when click an item in listview i open other window form (Sub) which generate the selected item from parent window in as treeview items when click any item...
4
by: Rod Gill | last post by:
Hi, I have a form that when opened in the designer appears of the screen. The form selector can't be dragged (or resized) and if I scroll right and down to centralise it the form simply jumps...
2
by: Trevor | last post by:
Argh! This problem is driving me nuts! Can you help? In November of 2003, I installed a web service on Windows Server 2003 built in VB.NET for v1.1.4322 of the framework. It contains a timer...
0
AmberJain
by: AmberJain | last post by:
Windows Autorun FAQs: Description NOTE- If you are unfamiliar with the concept of autoruns, then read "Windows Autorun FAQs: Overview". Que-1: How can I safely remove or edit the autorun...
0
AmberJain
by: AmberJain | last post by:
Windows Autorun FAQs: Programs dealing with autoruns Linked from the Original article- "Windows Autorun FAQs: Description". Que: Can you list programs that help me to view/modify the autoruns...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.