PVE 8 显示硬盘温度 不用hddtemp实现
参考:https://blog.csdn.net/qq_17111397/article/details/129920765
为啥不用因为装不上。。。
Package hddtemp is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
具体啥原因么。。。不纠结了因为都得去手动添加到web上。。。当然也可以改sensors的指令把硬盘温度加载sensors里面
显示所有硬盘温度
ls /dev/sd?|xargs -I {} smartctl -A {} |grep Temperature_Celsius|awk -F' ' '$0=$4'|cut -d'0' -f2
除非你硬盘超过100度。。。正常不会超过80度。。。吧。。。如果担心超过100度那就把最后的cut那堆去了
显示顺序是按照硬盘在dev中排的顺序决定的
cat > /usr/bin/hddtemp.sh <<EOF
a=\`ls /dev/sd?|xargs -I {} smartctl -A {} |grep Temperature_Celsius|awk -F' ' '\$0=\$4'|cut -d'0' -f2\`
echo \$a
EOF
诶发现有老哥给出了其他办法
https://forums.linuxmint.com/viewtopic.php?t=377639
modprobe drivetemp再用sensors查看
vi /usr/share/perl5/PVE/API2/Nodes.pm
插入点在PVE::pvecfg::version_text()下面
输入/tdata因为pvetools安装的是用这个变量名
下面一行
$res->{hddtemp} = `hddtemp /dev/sd?`;
$res->{hddtemp} = `/usr/bin/hddtemp.sh`;
按esc输入:wq保存并退出
vi /usr/share/pve-manager/js/pvemanagerlib.js
搜索输入/sensors \c点回车
,{
itemId: 'hddtemp',
colspan: 2,
printBar: false,
title: gettext('HDD:'),
textField: 'hddtemp',
renderer:function(value)
{
value = value.replaceAll('Â',' ');
return value.replaceAll('\n','<br/>');
}
}
添加在]的前面,操作失误会导致web界面无法显示,请确保括号完整
重启web界面
systemctl restart pveproxy
呃。。。目前还是显示不出来。。。目测是这样温度更新太慢???
vi /usr/share/perl5/PVE/API2/Nodes.pm
改成$res->{hddtemp} = `cat /tmp/hddtemp`;
然后写个while死循环每隔一分钟更新下硬盘温度
ls /dev/sd?|xargs -I {} smartctl -A {} |grep Temperature_Celsius|awk -F' ' '$0=$4'|cut -d'0' -f2 > /tmp/hddtemp
每隔一分钟更新下硬盘温度?这样会不会让硬盘没法进入休眠?所以还是放弃这个办法了。。。
下面尝试webget安装hddtemp的也没法再pve 8的web界面显示温度所以
请跳到下一段红字
去wget一个hddtemp
https://launchpad.net/ubuntu/+source/hddtemp
或者ubuntu官方 http://archive.ubuntu.com/ubuntu/pool/universe/h/hddtemp/
找到最新的amd64的deb,应该没有人还用86或者arm吧
wget http://archive.ubuntu.com/ubuntu/pool/universe/h/hddtemp/hddtemp_0.3-beta15-53_amd64.deb
apt install ./hddtemp_0.3-beta15-53_amd64.deb
rm ./hddtemp_0.3-beta15-53_amd64.deb
呃,一样读不到硬盘数据
用来检测硬盘状态:如果是unkown就是休眠了
hdparm -C /dev/sd?
要不也写道文件里???这不还是让硬盘没法进入休眠么,内存???这得写一个程序那。。。
卸载hddtemp
apt remove hddtemp
所以hddtemp也特喵的无法再pve 8下使用!!!难怪不让装了毛用都没有啊!!!
诶。。。要不还是试试sensor哪个读硬盘温度的办法吧。。。
modprobe drivetemp&&sensors|grep -E "temp1|drive"|cut -d'(' -f1
继续去改
vi /usr/share/perl5/PVE/API2/Nodes.pm
输入/tdata 按回车搜索
$res->{hddtemp} = `modprobe drivetemp&&sensors|grep -E "temp1|drive"|cut -d'(' -f1`;
这个时候就可以重启web管理服务了,后端需要重启web服务,js前端不用
systemctl restart pveproxy
输入/sensors\c按回车搜索,如果有下一个就按n
vi /usr/share/pve-manager/js/pvemanagerlib.js
,{
itemId: 'HDD Temp',
colspan: 2,
printBar: false,
title: gettext('HDD Temp'),
textField: 'hddtemp',
renderer:function(value){
value = value.replaceAll('Â',' ');
value = value.replaceAll('\ntemp1',' ');
return value.replaceAll('\n','<br/>');
}
}
再]之前输入
如果高度不够显示全
按esc输入/搜索widget.pveNodeStatus
我的height得改到500
按esc输入:w
刷新web界面就能看到前端的变化
前提是用pvetools添加了senosrs用来显示cpu温度
pvetools群里的朋友分享的:
https://www.aitxn.com/887.html?replytocom=146
wget -q -O /root/pve_source 'https://bbs.x86pi.cn/file/topic/2023-01-02/file/79bf8f916aca457d9c05df5864018dd7b2.zip' && chmod +x /root/pve_source && /root/./pve_source
通过my $变量=读取smartctl信息,来解决$res读不到硬盘信息的问题
再加上iostat的信息