我在我的笔记本电脑上运行 Xubuntu 12.10,我想监控 CPU 和硬盘的温度。我已经安装了 lm-sensors、hddtemp 和 xfce4-sensors-plugin 并将小部件添加到 XFCE 面板中。现在,当我登录或xfce4-sensors在终端中手动运行时,我收到以下通知:
"hddtemp" was not executed correctly, although it is executable. This is most probably due to the disks requiring root privileges to read their temperatures, and "hddtemp" not being setuid root.
An easy but dirty solution is to run "chmod u+s /usr/sbin/hddtemp" as root user and restart this plugin or its panel.
Calling "/usr/sbin/hddtemp -n -q /dev/sda" gave the following error:
/dev/sda: Permission denied
with a return value of 256.
Run Code Online (Sandbox Code Playgroud)
发生这种情况时,我没有任何选项可以在面板上显示硬盘温度。但是,如果我运行gksudo xfce4-sensors并输入密码,我不会出错,并且可以在面板上显示硬盘温度(如果我愿意)。
由于需要 root 权限才能运行 hddtemp 并且chmod u+s /usr/sbin/hddtemp不推荐,我必须在登录时自动从 xfce4-sensors 插件运行 hddtemp 的替代方法是什么?
小智 1
另一种方法是hddtemp作为守护进程运行(例如 args: --listen=127.0.0.1 -dF),侦听(或)上的某个TCP端口(默认7634)并在每次刷新时查询它。 localhost127.0.0.1xfce4-sensors-plugin
但是,这仅在xfce4-sensors-plugin使用 编译时才有效--disable-netcat,否则(--enable-netcat它会尝试hddtemp在每次刷新时执行自身!这是我的声明的源代码,我也测试了两种方式(suid hddtemp 并通过 hddtemp.service 将 hddtemp 作为守护进程运行) )。
注意事项:
hddtemp。sudo hddtemp --listen=127.0.0.1 -dF /dev/sda /dev/sdb /dev/sdc。xfce4-sensors-plugin。?条目xfce4-sensors-plugin,您可以在该条目中始终保持可见,直到设备出现为止。这可能是也可能不是您想要的。但使用 suid hddtemp 并启用 netcat 时,它只会列出当前存在的 HDD 设备,并且可能(未经测试)将来不会自动添加新设备,因此您必须在 下自行输入并检查/Properties启用它们Sensors type: Hard disks。 xfce4-sensors-plugin(今天的最新 git 2018 年 9 月 27 日)将在每次刷新时通过 TCP 从指定的主机/端口查找localhost并连接(然后断开连接)(例如,如果您设置为 每 1 秒Update interval (seconds))1,这意味着您会看到(并且我测试了这个)就像TIME_WAIT你的命令中的 150 行一样netstat -pantuW,所以很难看到其中的任何其他内容,除非你通过管道将其通过grep -v "127.0.0.1:7634.*TIME_WAIT"我想。 我会在此处更新要点以及任何进一步的信息