Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

How do I prevent remote syslog events from printing locally?

+1
−0

I have a GNU/Linux host that I use to aggregate syslog events from a few switches, printers, and generally less versatile hosts on my LAN.

I set up rsyslog years ago to listen on UDP:514 and save syslog messages it receives from any host to /var/log/netsyslog/${HostNameOrIPHere}.log and that works.
("netsyslog" was my creation) LogRogate then regularly compresses them and rotates them out. It's delightful.

But sometimes (depending on the "severity level" probably), the remote devices' messages also interrupt me when I'm SSH'd into my linux host. (In the middle of vim is particularly annoying.)

How can I prevent any remote message (regardless of severity) from displaying on local login sessions?

Here's my current config:

==> /etc/rsyslog.conf <==
$ModLoad imudp
$UDPServerRun 514
$ModLoad imtcp
$InputTCPServerRun 514
$template DynaFile,"/var/log/netsyslog/%HOSTNAME%.log"
*.* -?DynaFile
$WorkDirectory /var/lib/rsyslog
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
$IncludeConfig /etc/rsyslog.d/*.conf
$OmitLocalLogging on
$IMJournalStateFile imjournal.state
*.info;mail.none;authpriv.none;cron.none /var/log/messages
authpriv.*      /var/log/secure
mail.*         -/var/log/maillog
cron.*          /var/log/cron
*.emerg         :omusrmsg:*
uucp,news.crit  /var/log/spooler
local7.*        /var/log/boot.log
==> /etc/rsyslog.d/listen.conf <==
$SystemLogSocketName /run/systemd/journal/syslog

I'm thinking I want to change: *.emerg :omusrmsg:* By adding sort of filter to it like localhost.emerg. But I'm not sure how to compose such a filter.

Maybe there's a more elegant way of doing this. I half think perhaps I was wrong to use the same daemon to log locally-originated events as remote ones. I'm open to change.

History
Why does this post require moderator attention?
You might want to add some details to your flag.
Why should this post be closed?

2 comment threads

Format editing suggestions (2 comments)
Possible solution (2 comments)

1 answer

+0
−0

You said rsyslog specifically. Hopefully you are using a version new enough to use the advanced syntax (aka RainerScript). 1

Would something similar to the following work for you?

$EscapeControlCharactersOnReceive off
$template RemoteHost,"/var/log/remote/%HOSTNAME%/application.log"
if ($hostname != 'localhostnamehere') and ($hostname != 'localhost.fqdn') then ?RemoteHost
if ($hostname != 'localhostnamehere') and ($hostname != 'localhost.fqdn') then stop

Followed by whatever else you want. This is from something I wrote for myself in 2016 on CentOS 7. I have no idea if the EscapeControlCharactersOnReceive matters for your situation, but it was part of my template back then.

History
Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

Sign up to answer this question »