如何让 xfce4-sensors 插件在 XFCE 面板中显示硬盘温度?

Dan*_*oca 10 xubuntu 12.10

我在我的笔记本电脑上运行 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 的替代方法是什么?

rub*_*o77 3

升级到13.04后我遇到了同样的问题。

我也更喜欢一个不脏的解决方案。

但是这个错误报告 也没有提供任何干净的解决方案

至少:提到的肮脏的解决方案对我有用:

将 suid 位设置为 hddtemp:

$sudo chmod u+s /usr/sbin/hddtemp

$xfce4-sensors


小智 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 作为守护进程运行) )。

注意事项:

  1. 启动守护程序时,您必须指定要监视的所有 HDD 设备hddtemp
    IE。sudo hddtemp --listen=127.0.0.1 -dF /dev/sda /dev/sdb /dev/sdc
    只能看到指定的设备xfce4-sensors-plugin
  2. 如果上面(第 1 点)指定的任何设备不存在,则会出现一个?条目xfce4-sensors-plugin,您可以在该条目中始终保持可见,直到设备出现为止。这可能是也可能不是您想要的。但使用 suid hddtemp 并启用 netcat 时,它只会列出当前存在的 HDD 设备,并且可能(未经测试)将来不会自动添加新设备,因此您必须在 下自行输入并检查/Properties启用它们Sensors type: Hard disks
  3. 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"我想。

我会在此处更新要点以及任何进一步的信息