rsyslog conditional forwarding for remote logs
I have a rsyslog Server which have the below settings,Where its getting all the remote Linux systems logs and network logs.
# cat /etc/rsyslog.conf
$ModLoad imudp
$UDPServerRun 514
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
$template noida-dc, "/scratch/rsyslog/%HOSTNAME%/messages.log"
authpriv.* ?noida-dc
*.info,mail.none,authpriv.none,cron.none ?noida-dc
$IncludeConfig /etc/rsyslog.d/*.conf
Whereas Linux system logs are log as they are storing into /scratch/rsyslog
with their hostames by creating a directory with hostnames itself and then creating a message file within it, that's fine.
However, i want to segregate the network logs which basically creates a Folder by Month names like Jan Feb Mar
and then creates a message.log
as well but as network logs do not have hostnames it Just creating a dir based on the moth name and keeping the only one file into it thats messages.log
, my wish is to have these network logs to a different Directory like /scratch/network
.
Below is message format within the network log directory Dec
Dec 2 19:04:22 Dec 02 13:34:22.768 cisco-apic-1 %LOG_-3-SYSTEM_MSG
So, Is there a way to tell rsyslog if remote message contains Dec
or Jan
then must go to /scratch/network
.
What i tried as Follows but not working.
$template mynets,"/scratch/network/%HOSTNAME%/messages.log"
if $fromhost contains 'cisco-apic-1' then -?mynets
& stop
&
$template mynets,"/scratch/network/%HOSTNAME%/messages.log"
if $fromhost startswith 'Dec' then -?mynets
& stop
Linux Distro is : Centos 6
rsyslog
add a comment |
I have a rsyslog Server which have the below settings,Where its getting all the remote Linux systems logs and network logs.
# cat /etc/rsyslog.conf
$ModLoad imudp
$UDPServerRun 514
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
$template noida-dc, "/scratch/rsyslog/%HOSTNAME%/messages.log"
authpriv.* ?noida-dc
*.info,mail.none,authpriv.none,cron.none ?noida-dc
$IncludeConfig /etc/rsyslog.d/*.conf
Whereas Linux system logs are log as they are storing into /scratch/rsyslog
with their hostames by creating a directory with hostnames itself and then creating a message file within it, that's fine.
However, i want to segregate the network logs which basically creates a Folder by Month names like Jan Feb Mar
and then creates a message.log
as well but as network logs do not have hostnames it Just creating a dir based on the moth name and keeping the only one file into it thats messages.log
, my wish is to have these network logs to a different Directory like /scratch/network
.
Below is message format within the network log directory Dec
Dec 2 19:04:22 Dec 02 13:34:22.768 cisco-apic-1 %LOG_-3-SYSTEM_MSG
So, Is there a way to tell rsyslog if remote message contains Dec
or Jan
then must go to /scratch/network
.
What i tried as Follows but not working.
$template mynets,"/scratch/network/%HOSTNAME%/messages.log"
if $fromhost contains 'cisco-apic-1' then -?mynets
& stop
&
$template mynets,"/scratch/network/%HOSTNAME%/messages.log"
if $fromhost startswith 'Dec' then -?mynets
& stop
Linux Distro is : Centos 6
rsyslog
add a comment |
I have a rsyslog Server which have the below settings,Where its getting all the remote Linux systems logs and network logs.
# cat /etc/rsyslog.conf
$ModLoad imudp
$UDPServerRun 514
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
$template noida-dc, "/scratch/rsyslog/%HOSTNAME%/messages.log"
authpriv.* ?noida-dc
*.info,mail.none,authpriv.none,cron.none ?noida-dc
$IncludeConfig /etc/rsyslog.d/*.conf
Whereas Linux system logs are log as they are storing into /scratch/rsyslog
with their hostames by creating a directory with hostnames itself and then creating a message file within it, that's fine.
However, i want to segregate the network logs which basically creates a Folder by Month names like Jan Feb Mar
and then creates a message.log
as well but as network logs do not have hostnames it Just creating a dir based on the moth name and keeping the only one file into it thats messages.log
, my wish is to have these network logs to a different Directory like /scratch/network
.
Below is message format within the network log directory Dec
Dec 2 19:04:22 Dec 02 13:34:22.768 cisco-apic-1 %LOG_-3-SYSTEM_MSG
So, Is there a way to tell rsyslog if remote message contains Dec
or Jan
then must go to /scratch/network
.
What i tried as Follows but not working.
$template mynets,"/scratch/network/%HOSTNAME%/messages.log"
if $fromhost contains 'cisco-apic-1' then -?mynets
& stop
&
$template mynets,"/scratch/network/%HOSTNAME%/messages.log"
if $fromhost startswith 'Dec' then -?mynets
& stop
Linux Distro is : Centos 6
rsyslog
I have a rsyslog Server which have the below settings,Where its getting all the remote Linux systems logs and network logs.
# cat /etc/rsyslog.conf
$ModLoad imudp
$UDPServerRun 514
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
$template noida-dc, "/scratch/rsyslog/%HOSTNAME%/messages.log"
authpriv.* ?noida-dc
*.info,mail.none,authpriv.none,cron.none ?noida-dc
$IncludeConfig /etc/rsyslog.d/*.conf
Whereas Linux system logs are log as they are storing into /scratch/rsyslog
with their hostames by creating a directory with hostnames itself and then creating a message file within it, that's fine.
However, i want to segregate the network logs which basically creates a Folder by Month names like Jan Feb Mar
and then creates a message.log
as well but as network logs do not have hostnames it Just creating a dir based on the moth name and keeping the only one file into it thats messages.log
, my wish is to have these network logs to a different Directory like /scratch/network
.
Below is message format within the network log directory Dec
Dec 2 19:04:22 Dec 02 13:34:22.768 cisco-apic-1 %LOG_-3-SYSTEM_MSG
So, Is there a way to tell rsyslog if remote message contains Dec
or Jan
then must go to /scratch/network
.
What i tried as Follows but not working.
$template mynets,"/scratch/network/%HOSTNAME%/messages.log"
if $fromhost contains 'cisco-apic-1' then -?mynets
& stop
&
$template mynets,"/scratch/network/%HOSTNAME%/messages.log"
if $fromhost startswith 'Dec' then -?mynets
& stop
Linux Distro is : Centos 6
rsyslog
rsyslog
edited Dec 19 '18 at 8:27
Rui F Ribeiro
39k1479130
39k1479130
asked Dec 19 '18 at 7:24
pygo
696
696
add a comment |
add a comment |
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f489846%2frsyslog-conditional-forwarding-for-remote-logs%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f489846%2frsyslog-conditional-forwarding-for-remote-logs%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown