-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsystem_information.py
More file actions
62 lines (51 loc) · 1.98 KB
/
system_information.py
File metadata and controls
62 lines (51 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
BASE_PATH = "C:\\dev\\projects\\OS_Project\\SystemResourceMonitor\\"
import winstats
import wmi
computer = wmi.WMI()
computer_info = computer.Win32_ComputerSystem()[0]
os_info = computer.Win32_OperatingSystem()[0]
proc_info = computer.Win32_Processor()[0]
gpu_info = computer.Win32_VideoController()[0]
os_name = os_info.Name.encode('utf-8').split(b'|')[0]
os_version = ' '.join([os_info.Version, os_info.BuildNumber])
system_ram = float(os_info.TotalVisibleMemorySize) / 1048576 # KB to GB
usage = winstats.get_perf_data(r'\Processor(_Total)\% Processor Time', delay=100)
# print ' CPU Usage: %.02f %%' % usage
meminfo = winstats.get_mem_info()
total = meminfo.TotalPhys
load = meminfo.MemoryLoad
# TotalPhys, Memory Load
drives = winstats.get_drives()
drive = drives[0]
fsinfo = winstats.get_fs_usage(drive)
vinfo = winstats.get_vol_info(drive)
# print ' Disks:', ', '.join(drives)
# print ' %s:\\' % drive
# print ' Name:', vinfo.name
# print ' Type:', vinfo.fstype
# print ' Total:', fmt(fsinfo.total)
# print ' Used: ', fmt(fsinfo.used)
# print ' Free: ', fmt(fsinfo.free)
# First 5 lines
# print('OS Name: {0}'.format(os_name))
# print('OS Version: {0}'.format(os_version))
# print('CPU: {0}'.format(proc_info.Name))
# print('RAM: {0} GB'.format(system_ram))
# print('Graphics Card: {0}'.format(gpu_info.Name))
with open(BASE_PATH + 'sys_info.txt', 'w') as file:
# Basic
file.write('OS Name: {0}\n'.format(os_name))
file.write('OS Version: {0}\n'.format(os_version))
file.write('CPU: {0}\n'.format(proc_info.Name))
file.write('RAM: {0} GB\n'.format(system_ram))
file.write('Graphics Card: {0}\n'.format(gpu_info.Name))
# CPU Usage
file.write(str(usage[0]) + '\n')
# RAM
file.write(str(load) + '\n')
# Storage
file.write(vinfo.name + '\n')
file.write(vinfo.fstype + '\n')
file.write(str(fsinfo.total / 1e9) + '\n')
file.write(str(fsinfo.used / 1e9) + '\n')
file.write(str(fsinfo.free / 1e9) + '\n')