Skip to content

Instantly share code, notes, and snippets.

@3dgoose
Last active June 28, 2024 20:15
Show Gist options
  • Save 3dgoose/fd91caade53e6fd70fba1ead161543f2 to your computer and use it in GitHub Desktop.
Save 3dgoose/fd91caade53e6fd70fba1ead161543f2 to your computer and use it in GitHub Desktop.
Get SysInfo in Python
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