Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Computer System Information using Python

Tags:

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.

like image 638
user990951 Avatar asked Jun 09 '26 17:06

user990951


1 Answers

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.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!