I am working on a project for which I need to create a Python class which can determine underlying OS on which it is running and performs a sequence of checks if OS is found to be Windows Server 2003/2008.
Currently my check includes following parameters:
- CPU Utilization Check
- RAM Utilization Check
- HD Volume space available
- Well configured network parameters like DNS and DHCP
- RDP and other critical application services running
For 1 to 3 information can be extracted from Windows Task Manager BUT the question in HOW ?
For 4, ipconfig /all output would be fine and I think I would be able to extract them either from some python modules or regex ! (Believe me I am not sure)
For 5, I think I should use powershell trimmed Get-Services output.
I look foreward to seek help on points 1 to 3
- How can I extract this information from windows machine ?
- How can I use that information for further processing in Python ?
Apart from this any type of suggestion/query/improvements/known issues are most welcome.
Best Answer
Give this a look for parts 1, 2 and 3: http://code.google.com/p/psutil/
As for network parameters, you might have a bit better luck with parsing the output from the following command:
netsh interface ipv4 show config
for interface configuration and DNS. However you can also try this: http://alastairs-place.net/projects/netifaces/ It doesn't give very friendly interface names on Windows but works. However I don't think it shows whether you're using DHCP or what you're using for DNS.Lastly for 5 there is http://code.activestate.com/recipes/303339/ but it is unhelpfully only processes. There's a WMI Python module that can provide service information however: http://timgolden.me.uk/python/wmi/index.html