You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.7 KiB
53 lines
1.7 KiB
import psutil
|
|
threads_por_nucleo = psutil.cpu_count(logical=False)
|
|
memoria = psutil.virtual_memory()
|
|
|
|
def get_running_processes():
|
|
# Using list comprehension to get information about all running processes
|
|
return [proc.info for proc in psutil.process_iter(['pid', 'name', 'username'])]
|
|
|
|
def procesesRunning():
|
|
# Get and print information about all running processes
|
|
running_processes = get_running_processes()
|
|
|
|
# Print the information without a separate loop
|
|
print("\n".join([f"PID: {process['pid']}, Name: {process['name']}, User: {process['username']}" for process in running_processes]))
|
|
|
|
battery = psutil.sensors_battery()
|
|
plugged = battery.power_plugged
|
|
percent = str(battery.percent)
|
|
plugged = "Plugged In" if plugged else "Not Plugged In"
|
|
|
|
ans=True
|
|
while ans:
|
|
print("""
|
|
1. Hilos por nucleo
|
|
2. Memoria Total
|
|
3. Memoria Diponible
|
|
4. Porcentaje de memoria utilizada
|
|
5. El estado de bateria
|
|
6. Procesos activados
|
|
7. El uso del CPU
|
|
8. Exit/Quit
|
|
""")
|
|
ans=input("Elige que tipo de informacio deseas saber:")
|
|
if ans=="1":
|
|
print(f"Tu procesador tiene {threads_por_nucleo} hilos por núcleo.")
|
|
elif ans=="2":
|
|
print(f"Memoria total: {memoria.total} bytes")
|
|
elif ans=="3":
|
|
print(f"Memoria disponible: {memoria.available} bytes")
|
|
elif ans == "4":
|
|
print(f"Porcentaje de memoria utilizada: {memoria.percent}%")
|
|
elif ans == "5":
|
|
print(percent+'% | '+plugged)
|
|
elif ans == "6":
|
|
procesesRunning()
|
|
elif ans == "7":
|
|
cpu_usage = psutil.cpu_percent(interval=1)
|
|
print(f"CPU Usage: {cpu_usage}%")
|
|
elif ans=="8":
|
|
print("\n Goodbye")
|
|
ans = None
|
|
else:
|
|
print("\n Not Valid Choice Try again") |