Last active
June 28, 2024 20:15
-
-
Save 3dgoose/fd91caade53e6fd70fba1ead161543f2 to your computer and use it in GitHub Desktop.
Get SysInfo in Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import psutil | |
import os | |
import subprocess | |
def get_cpu_temp(): | |
temp = psutil.sensors_temperatures()['cpu_thermal'][0].current | |
return temp | |
ip = "hostname -I" | |
uptime = "uptime -p" | |
print("CPU Temperature: ", get_cpu_temp()) | |
# IP | |
result_ip = subprocess.check_output(ip, shell=True, text=True) | |
print("IP: ", result_ip) | |
# Uptime | |
result_uptime = subprocess.check_output(uptime, shell=True, text=True) | |
print("Uptime: ", result_uptime) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment