我的系统上有一个进程叫做恶魔它将大约 100 个条目记录到 systemd 日志中每15秒一次:
Okt 11 04:58:42 scarecrow demond[1692]: [P:1692 T:108160832] src/discovery.c : 158 getHidDevices -- failed in opening HIDDEV file: /dev/hiddev0. No such file or directory
Okt 11 04:58:42 scarecrow demond[1692]: [P:1692 T:108160832] src/discovery.c : 158 getHidDevices -- failed in opening HIDDEV file: /dev/hiddev1. No such file or directory
Okt 11 04:58:42 scarecrow demond[1692]: [P:1692 T:108160832] src/discovery.c : 158 getHidDevices -- failed in opening HIDDEV file: /dev/hiddev2. No such file or directory
Okt 11 04:58:42 scarecrow demond[1692]: [P:1692 T:108160832] src/discovery.c : 158 getHidDevices -- failed in opening HIDDEV file: /dev/hiddev3. No such file or directory
Okt 11 04:58:42 scarecrow demond[1692]: [P:1692 T:108160832] src/discovery.c : 158 getHidDevices -- failed in opening HIDDEV file: /dev/hiddev4. No such file or directory
Okt 11 04:58:42 scarecrow demond[1692]: [P:1692 T:108160832] src/discovery.c : 158 getHidDevices -- failed in opening HIDDEV file: /dev/hiddev5. No such file or directory
Okt 11 04:58:42 scarecrow demond[1692]: [P:1692 T:108160832] src/discovery.c : 158 getHidDevices -- failed in opening HIDDEV file: /dev/hiddev6. No such file or directory
Okt 11 04:58:42 scarecrow demond[1692]: [P:1692 T:108160832] src/discovery.c : 158 getHidDevices -- failed in opening HIDDEV file: /dev/hiddev7. No such file or directory
Okt 11 04:58:42 scarecrow demond[1692]: [P:1692 T:108160832] src/discovery.c : 158 getHidDevices -- failed in opening HIDDEV file: /dev/hiddev8. No such file or directory
Okt 11 04:58:42 scarecrow demond[1692]: [P:1692 T:108160832] src/discovery.c : 158 getHidDevices -- failed in opening HIDDEV file: /dev/hiddev9. No such file or directory
Okt 11 04:58:42 scarecrow demond[1692]: [P:1692 T:108160832] src/discovery.c : 158 getHidDevices -- failed in opening HIDDEV file: /dev/hiddev10. No such file or directory
Okt 11 04:58:42 scarecrow demond[1692]: [P:1692 T:108160832] src/discovery.c : 158 getHidDevices -- failed in opening HIDDEV file: /dev/hiddev11. No such file or directory
Okt 11 04:58:42 scarecrow demond[1692]: [P:1692 T:108160832] src/discovery.c : 158 getHidDevices -- failed in opening HIDDEV file: /dev/hiddev12. No such file or directory
Okt 11 04:58:42 scarecrow demond[1692]: [P:1692 T:108160832] src/discovery.c : 158 getHidDevices -- failed in opening HIDDEV file: /dev/hiddev13. No such file or directory
Okt 11 04:58:42 scarecrow demond[1692]: [P:1692 T:108160832] src/discovery.c : 158 getHidDevices -- failed in opening HIDDEV file: /dev/hiddev14. No such file or directory
Okt 11 04:58:42 scarecrow demond[1692]: [P:1692 T:108160832] src/discovery.c : 158 getHidDevices -- failed in opening HIDDEV file: /dev/hiddev15. No such file or directory
这会很快填满日志并创建永久磁盘访问,从而耗尽电池电量。这些条目的优先级均为 7(调试)。
demod 是 Lexmark 打印机驱动程序的一部分。我猜他们用它来发现设备的 Wifi。我联系了 Lexmark 支持人员,他们说他们无法更改驱动程序,并且无法抑制这些消息。由于驱动程序是闭源的,我无法自己更改它。
我知道我可以MaxLevelStore=info
在journald.conf中使用完全抑制调试级别7,但这会抑制调试级别全部流程。
有没有办法抑制日志记录对于某个过程比如恶魔?
我正在使用带有最新 systemd 208 的 ArchLinux。我不使用 syslog-ng 或 rsyslog。
答案1
结果发现有一个名为 ENABLE_D_LOG=0|1 的环境变量,默认情况下为 1,这导致了日志记录的疯狂。将其设置为 0 会关闭驱动程序。因此,我为 demod 创建了一个包装脚本,设置 ENABLE_D_LOG=0,然后调用原始的 demod:
# cd /usr/local/lexmark/legacy/bin
# mv demond demond.orig
# cat > demond <<EOF
#!/bin/sh
export ENABLE_D_LOG=0
/usr/local/lexmark/legacy/bin/demond.orig $@
EOF
# chmod +x demond