user990951
user990951

Reputation: 1479

Getting Computer System Information using Python

I am trying to build a python script that will grab certain information about a system running mostly Windows or Linux. Here is what I got so far.

import socket
import os 
import sys
import platform
import psutil
import uuid

print  "Name: " +socket.gethostname() 
print "FQDN: " +socket.getfqdn()
print "System Platform: "+sys.platform
print "Machine: " +platform.machine()
print "Node " +platform.node()
print "Platform: "+platform.platform()
print "Pocessor: " +platform.processor()
print "System OS: "+platform.system()
print "Release: " +platform.release()
print "Version: " +platform.version()
print "Number of CPUs: " +str(psutil.cpu_count()) 
print "Number of Physical CPUs: " +str(psutil.cpu_count(logical=False))
#Need  Model of Computer i.e.  HP Compaq 8100 Elite SFF, HP X600 workstation
#need Ram
#need Disk space
#Need Manufacturer i.e. HP, Dell, Lenova

I am not sure how to get the Model Number of the System, and the Manufacturer both in Linux and Windows. I think I am able to get the RAM and Disk Space using psutil.

Upvotes: 3

Views: 7678

Answers (1)

user59634
user59634

Reputation:

I wrote an article sometime back which you may find useful. However, it is written exclusively for Linux and besides using some standard library modules, it directly reads data from the files in /proc and uses the subprocess module to execute Linux commands in some cases.

I haven't played with Windows recently, but you may find the technique of executing the relevant Windows commands using the subprocess module useful there as well.

Upvotes: 2

Related Questions