sl命令
最近发现一个有趣的命令,输入sl执行后会有动态的小火车从你的屏幕上开过去。首先sl命令严格来说并不算是命令,甚至也不是linux内置的,它只是一个比较有趣的小程序,它的名称叫yung,执行指令是sl。
下载sl
#apt -y install sl

执行效果

ps:它同样支持下面的选项:
-a : 似乎发生了意外。你会为那些哭喊求助的人们感到难过。
-l : 显示小一点的火车
-F : 它居然飞走了
-e : 允许被 Ctrl+C 中断
使用sq数据库采集散热数据
说明:这是一个通过SQLite轻量级数据库与Python来存储散热数据的方案,可以对 CPU 温度进行长时间采集并且记录在数据库中,进而便于分析与展示来观察CPU温度和系统压力状态。
下载sqlite3数据库
#sudo apt -y install sqlite3

编写python脚本代码
import sqlite3
import datetime
import time
def get_temp(): #获取温度
with open('/sys/class/thermal/thermal_zone0/temp', 'rb') as f:
cpu_temp =f.readline()
return cpu_temp
def create_table(): #数据库与表的创建
try:
conn = sqlite3.connect('rpitemp.db') #创建数据库,取名:rpitemp.db
cursor = conn.cursor () #设置游标
print("[0K]Successfully Connected to SQLite")
create_table_query ='''CREATE TABLE rpitemp(id INTEGER PRIMARY KEY AUTOINCREMENT,temperature REAL NOT NULL, date DATETIME NOT NULL);''' #创建表,增加数据类型
cursor.execute(create_table_query) #游标执行
conn.commit()
print("[0K]SQLite: table has been created")
except sqlite3.Error as e:
print("Failed to create table", e)
finally:
if conn:
conn.close()
print("[0K]The SQLite connection is closed!")
def insert_temp_to_table(): #插入数据
try:
conn = sqlite3.connect('rpitemp.db')
cursor = conn.cursor ()
print("Successfully Connected to SQLite")
insert_table_query ='''INSERT INTO rpitemp(id, temperature, date) VALUES(?,?,?);'''
temp =int(get_temp())/1000.0
data_tuple = (id, temp, datetime.datetime.now())
cursor.execute(insert_table_query, data_tuple)
conn.commit() #提交数据
print("Successfully Insert {} record to table.".format(cursor.rowcount))
except sqlite3.Error as e:
print("Failed to create table",e)
id = 0
create_table()
while True:
insert_temp_to_table()
id +=1
time.sleep(1)
if id >= 10:
break
执行代码

ps:数据已成功保存至数据库。
查看结果

通过sysbench压力测试
下载sysbench软件包
#sudo apt -y install sysbench

编写脚本后运行
# while true
> do
> sysbench --test=cpu --cpu-max-prime=20000 --num-threads=4 run
> sleep 1
> done

查看CPU温度与运行频率
#sudo hrut_somstatus

采集温度数据

查看采集结果

总结
通过sysbench软件测试可以看到cpu火力全开温度上升还是挺明显的,不过还是处在正常范围,总得来说芯片温控这块做还是很不错的。关于这个简单的温度压测就到这里了,感谢观看。