added option to display max cpu frequency

This commit is contained in:
Adnan Hodzic 2019-12-31 19:50:47 +01:00
parent 2813c64e7c
commit 91fc3c0d5a
1 changed files with 8 additions and 5 deletions

View File

@ -20,6 +20,7 @@ import click
# - add option to enable turbo in powersave # - add option to enable turbo in powersave
# - go thru all other ToDo's # - go thru all other ToDo's
# - in case of daemon deploy check if it's already running/daemon script exists # - in case of daemon deploy check if it's already running/daemon script exists
# - add temperature for each core
# global var # global var
p = psutil p = psutil
@ -147,7 +148,7 @@ def mon_turbo():
# ToDo: move load and cpuload to sysinfo # ToDo: move load and cpuload to sysinfo
if load1m > 2: if load1m > 2:
print("High load, would turn turbo boost: on") print("High load, suggesting turbo boost: on")
#s.run("echo 0 > /sys/devices/system/cpu/intel_pstate/no_turbo", shell=True) #s.run("echo 0 > /sys/devices/system/cpu/intel_pstate/no_turbo", shell=True)
if cur_turbo == "0": if cur_turbo == "0":
print("Currently turbo boost is: on") print("Currently turbo boost is: on")
@ -159,7 +160,7 @@ def mon_turbo():
# print("High load:", load1m) # print("High load:", load1m)
# print("CPU load:", cpuload, "%") # print("CPU load:", cpuload, "%")
elif cpuload > 25: elif cpuload > 25:
print("High CPU load, would turn turbo boost: on") print("High CPU load, suggesting turbo boost: on")
if cur_turbo == "0": if cur_turbo == "0":
print("Currently turbo boost is: on") print("Currently turbo boost is: on")
else: else:
@ -168,7 +169,7 @@ def mon_turbo():
#print("\n" + "-" * 60 + "\n") #print("\n" + "-" * 60 + "\n")
footer(79) footer(79)
else: else:
print("Load optimal, would turn turbo boost: off") print("Load optimal, suggesting turbo boost: off")
if cur_turbo == "0": if cur_turbo == "0":
print("Currently turbo boost is: on") print("Currently turbo boost is: on")
else: else:
@ -212,14 +213,14 @@ def mon_autofreq():
# auto cpufreq based on battery state # auto cpufreq based on battery state
if bat_state == "Discharging": if bat_state == "Discharging":
print("Battery is: discharging") print("Battery is: discharging")
print("Based on this would set to \"powersave\" governor.\nCurrently using:", gov_state) print("Suggesting to use \"powersave\" governor\nCurrently using:", gov_state)
#s.run("cpufreqctl --governor --set=powersave", shell=True) #s.run("cpufreqctl --governor --set=powersave", shell=True)
#cur_gov = s.getoutput("cpufreqctl --governor --set=powersave", shell=True) #cur_gov = s.getoutput("cpufreqctl --governor --set=powersave", shell=True)
#print(gov_state) #print(gov_state)
#set_powersave() #set_powersave()
elif bat_state == "Charging" or "Full": elif bat_state == "Charging" or "Full":
print("Battery is: charging") print("Battery is: charging")
print("Based on this would set to \"performance\" governor.\nCurrently using:", gov_state) print("Suggesting to use \"performance\" governor\nCurrently using:", gov_state)
#set_performance() #set_performance()
#print(gov_state) #print(gov_state)
else: else:
@ -232,6 +233,7 @@ def sysinfo():
cpu_brand = cpuinfo.get_cpu_info()['brand'] cpu_brand = cpuinfo.get_cpu_info()['brand']
cpu_arch = cpuinfo.get_cpu_info()['arch'] cpu_arch = cpuinfo.get_cpu_info()['arch']
cpu_count = cpuinfo.get_cpu_info()['count'] cpu_count = cpuinfo.get_cpu_info()['count']
max_cpu_freq = p.cpu_freq().max
fdist = distro.linux_distribution() fdist = distro.linux_distribution()
dist = " ".join(x for x in fdist) dist = " ".join(x for x in fdist)
@ -240,6 +242,7 @@ def sysinfo():
print("Architecture:", cpu_arch) print("Architecture:", cpu_arch)
print("Processor:", cpu_brand) print("Processor:", cpu_brand)
print("CPU max frequency: " + "{:.0f}".format(max_cpu_freq) + " MHz")
print("Cores:", cpu_count) print("Cores:", cpu_count)
print("\n" + "-" * 30 + " Current CPU state " + "-" * 30 + "\n") print("\n" + "-" * 30 + " Current CPU state " + "-" * 30 + "\n")