-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwinmonitor.py
137 lines (112 loc) · 3.25 KB
/
winmonitor.py
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
import wmi
import platform
import subprocess
import psutil
import locale
# Get the account name of the current user
def get_account_name():
return psutil.users()[0].name
# Get the BIOS caption
def get_bios_caption():
c = wmi.WMI()
bios = c.Win32_BIOS()[0]
return bios.Caption
# Get the BIOS manufacturer
def get_bios_maker():
c = wmi.WMI()
bios = c.Win32_BIOS()[0]
return bios.Manufacturer
# Get the BIOS serial number
def get_bios_serial_number():
c = wmi.WMI()
bios = c.Win32_BIOS()[0]
return bios.SerialNumber
# Get the board product ID
def get_board_product_id():
c = wmi.WMI()
board = c.Win32_BaseBoard()[0]
return board.Product
# Get the board manufacturer
def get_board_maker():
c = wmi.WMI()
board = c.Win32_BaseBoard()[0]
return board.Manufacturer
# Get the CD/DVD-ROM drive information
def get_cdrom_drive():
c = wmi.WMI()
for drive in c.Win32_CDROMDrive():
return drive.Name
# Get the computer name
def get_computer_name():
return platform.node()
# Get the current CPU clock speed
def get_cpu_current_clock_speed():
c = wmi.WMI()
cpu = c.Win32_Processor()[0]
return cpu.CurrentClockSpeed
# Get the CPU manufacturer
def get_cpu_manufacturer():
c = wmi.WMI()
cpu = c.Win32_Processor()[0]
return cpu.Manufacturer
# Get the CPU speed in GHz
def get_cpu_speed_in_ghz():
c = wmi.WMI()
cpu = c.Win32_Processor()[0]
return cpu.MaxClockSpeed / 1000.0
# Get the HDD serial number
def get_hdd_serial_number():
result = subprocess.check_output(['wmic', 'diskdrive', 'get', 'serialnumber'])
serial_numbers = result.decode().strip().split('\n')[1:]
return serial_numbers[0].strip()
# Get the MAC address
def get_mac_address():
for interface in psutil.net_if_addrs().values():
for addr in interface:
if addr.family == psutil.AF_LINK:
return addr.address
# Get the OS information
def get_os_information():
return platform.platform()
# Get the physical memory (RAM) in bytes
def get_physical_memory():
return str(psutil.virtual_memory().total/(1024 * 1024))
# Get the processor ID
def get_processor_id():
c = wmi.WMI()
processor = c.Win32_Processor()[0]
return processor.ProcessorId
# Get the processor information
def get_processor_information():
c = wmi.WMI()
processor = c.Win32_Processor()[0]
return processor.Name
# Get the number of RAM slots
def get_no_ram_slots():
c = wmi.WMI()
memory = c.Win32_PhysicalMemory()
return len(memory)
# Get the current language
def get_current_language():
return locale.getlocale()[0]
def getAvailableRAM():
remain_ram = ""
try:
virtual_memory = psutil.virtual_memory()
free_ram = virtual_memory.available / (1024 * 1024) # Convert to MB
remain_ram = str(free_ram)
except Exception as exception:
pass
return remain_ram
def GetCpuUsage():
value_use = ""
try:
cpu_percent = psutil.cpu_percent(interval=1)
value_use = str(cpu_percent)
except Exception as exception:
pass
return value_use
def getPCSpace():
drive_info = psutil.disk_usage('/')
total_free_space = drive_info.free / (1024 * 1024 * 1024) # Convert to GB
return str(total_free_space) + "GB"