Ubuntu – way to suppress one specific message from syslog

pciesyslog

I'm getting a lot of

Dec 27 08:35:49 htpc kernel: [ 1552.153797] pciehp 0000:00:1c.5:pcie04: Card not present on Slot(0-2)
Dec 27 08:35:49 htpc kernel: [ 1552.157744] pciehp 0000:00:1c.5:pcie04: Card present on Slot(0-2)

messages in my syslog, about 10 every second. That just makes syslog unusable, can I somehow get rid of them?

I don't know and don't really care about the reason of those messages being there, partly because my motherboard doesn't have pcie slots on it and partly because everything I care about works perfectly. That might be a WiFi chip I disabled in bios but hey, I don't want wifi to be powered on, I'm not using it.

So can I just suppress those messages?

Best Answer

Since Ubuntu 10.04 rsyslog is used instead of plain syslog and it does have filtering capabilities. Proceed as follows:

  • Create gksudo gedit /etc/rsyslog.d/01-blocklist.conf
  • Add the following lines there
    :msg,contains,"Card not present on Slot(0-2)" ~
    :msg,contains,"Card present on Slot(0-2)" ~
  • Reboot or service rsyslog restart

The solution works as follows:

  • 01- part in file name forces rsyslog to load this config before it loads anything else
  • the lines in the file find any messages containing the text we want to ignore and discards those messages right away, thanks for discard operator (~)
  • it is possible to match by regexp or ignore case, check [this helpful guide] (http://www.rsyslog.com/doc/property_replacer.html) on matching

Note, that solving that kind of issues the right way is always preferred. For example, broken pciehp won't let your CPU to go into deeper sleep states and will increase effective TDP and power consumption of you CPU. However, since pciehp is compiled into Ubuntu kernel, there's little you can do without compiling your own kernel, which is not advisable.

Related Question