import
os
import
platform
import
psutil
import
socket
import
subprocess
import
datetime
import
sys
import
time
import
wmi
import
iis_bridge as iis
import
wmicq
print
(
'System Inventory is running, Please wait ...'
)
projectpath
=
(os.path.dirname(os.path.abspath(__file__)))
save_path
=
projectpath
file_name
=
"SystemInfo.txt"
completeName
=
os.path.join(save_path, file_name)
file1
=
open
(completeName,
"w"
)
now
=
datetime.datetime.now()
original_stdout
=
sys.stdout
with
open
(completeName,
'w'
) as f:
sys.stdout
=
f
print
(
'System Inventory'
)
print
(
"Current date and time : "
, now)
hostname
=
socket.gethostname()
print
(
"Hostname : "
, hostname)
try
:
attributes
=
[
'Description'
,
'IPAddress'
,
'MACAddress'
]
header, queryData
=
wmicq.query(wmicq.Category.NICCONFIG, attributes
=
attributes, where
=
"IpEnabled=True"
)
maxLen
=
max
(
len
(x)
for
x
in
header)
for
q
in
queryData:
print
(
"NIC info : "
,
"{}: MAC: {}, IP: {}"
.
format
(q[
"Description"
], q[
"MACAddress"
], q[
"IPAddress"
]))
except
wmicq.QueryError as e:
print
(
"Query error: {}"
.
format
(e))
ip_address
=
socket.gethostbyname(hostname)
print
(
"Current IP Address : "
, ip_address)
print
(
f
"Machine type: {platform.machine()}"
)
print
(
f
"Processor type: {platform.processor()}"
)
print
(
f
"Platform type: {platform.platform()}"
)
print
(
f
"Operating system: {platform.system()}"
)
print
(
f
"Operating system release: {platform.release()}"
)
print
(
f
"Operating system version: {platform.version()}"
)
myWMI
=
wmi.WMI ()
for
processer
in
myWMI.Win32_Processor ():
print
(
"Current Clock Speed : %s"
%
(processer.CurrentClockSpeed))
print
(
"Name : %s"
%
(processer.Name))
print
(
"Cores : %s"
%
(processer.NumberOfCores))
print
(
f
"Number of physical cores: {psutil.cpu_count(logical=False)}"
)
print
(
f
"Number of logical cores: {psutil.cpu_count(logical=True)}"
)
print
(
f
"Current CPU frequency: {psutil.cpu_freq().current}"
)
print
(
f
"Min CPU frequency: {psutil.cpu_freq().min}"
)
print
(
f
"Max CPU frequency: {psutil.cpu_freq().max}"
)
print
(
f
"Total RAM installed: {round(psutil.virtual_memory().total/1000000000, 2)} GB"
)
print
(
f
"Available RAM: {round(psutil.virtual_memory().available/1000000000, 2)} GB"
)
print
(
f
"Used RAM: {round(psutil.virtual_memory().used/1000000000, 2)} GB"
)
print
(
f
"RAM usage: {psutil.virtual_memory().percent}%"
)
print
(
f
"Disk Info : {psutil.disk_partitions()}"
)
totalsize
=
psutil.disk_usage(
'C:\\'
).total
/
2
*
*
30
for
disk
in
psutil.disk_partitions():
if
disk.fstype:
print
(disk.device, psutil.disk_usage(disk.mountpoint) .total
/
2
*
*
30
,
' GB'
)
print
(
"<<< Windows System Information >>>"
)
Id
=
subprocess.check_output([
'systeminfo'
]).decode(
'utf-8'
).split(
'\n'
)
new
=
[]
for
item
in
Id
:
new.append(
str
(item.split(
"\r"
)[:
-
1
]))
for
i
in
new:
print
(i[
2
:
-
2
])
print
(
"IIS Version %s"
%
iis.get_version())
print
(
"IIS Pools names: "
, iis.get_pool_names())
print
(
"IIS Websites: "
, iis.get_site_names())
sys.stdout
=
original_stdout
file1.close()
print
(
"Result File: "
, completeName)