-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[System logs]: Eliminate duplicate log messages and attempt rotation more frequently #520
Changes from 11 commits
27e610b
364c945
c8e435d
3817db5
21b08c2
6304f9d
7b0dd39
9bfaf4f
88e58d6
c7e075c
7c02b86
6ccd0d6
de4552b
ea8e998
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Edit this file to introduce tasks to be run by cron. | ||
# | ||
# Each task to run has to be defined through a single line | ||
# indicating with different fields when the task will be run | ||
# and what command to run for the task | ||
# | ||
# To define the time you can provide concrete values for | ||
# minute (m), hour (h), day of month (dom), month (mon), | ||
# and day of week (dow) or use '*' in these fields (for 'any').# | ||
# Notice that tasks will be started based on the cron's system | ||
# daemon's notion of time and timezones. | ||
# | ||
# Output of the crontab jobs (including errors) is sent through | ||
# email to the user the crontab file belongs to (unless redirected). | ||
# | ||
# For example, you can run a backup of all your user accounts | ||
# at 5 a.m every week with: | ||
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/ | ||
# | ||
# For more information see the manual pages of crontab(5) and cron(8) | ||
# | ||
# m h dom mon dow command | ||
|
||
* * * * * /usr/sbin/logrotate -f /etc/logrotate.d/rsyslog | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/var/log/syslog | ||
/var/log/quagga/*.log | ||
/var/log/sonic/*.log | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. /var/log/sonic? Are we using this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not currently. Please see my first comment on 00-sonic.conf up above. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it |
||
/var/log/teamd.log | ||
{ | ||
rotate 7 | ||
# Removed 'daily' interval, as we now call logrotate more frequently via cron | ||
# and we want to check these logs every time | ||
# daily | ||
size 100M | ||
missingok | ||
notifempty | ||
compress | ||
delaycompress | ||
postrotate | ||
invoke-rc.d rsyslog rotate > /dev/null | ||
endscript | ||
} | ||
/var/log/mail.info | ||
/var/log/mail.warn | ||
/var/log/mail.err | ||
/var/log/mail.log | ||
/var/log/daemon.log | ||
/var/log/kern.log | ||
/var/log/auth.log | ||
/var/log/user.log | ||
/var/log/lpr.log | ||
/var/log/cron.log | ||
/var/log/debug | ||
/var/log/messages | ||
{ | ||
rotate 4 | ||
weekly | ||
size 100M | ||
missingok | ||
notifempty | ||
compress | ||
delaycompress | ||
sharedscripts | ||
postrotate | ||
invoke-rc.d rsyslog rotate > /dev/null | ||
endscript | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,8 +42,8 @@ $UDPServerRun 514 | |
#$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat | ||
|
||
# Define a custom template | ||
$template ACSFileFormat,"%TIMESTAMP% %HOSTNAME% %syslogseverity-text:::uppercase% %syslogtag%%msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%\n" | ||
$ActionFileDefaultTemplate ACSFileFormat | ||
$template SONiCFileFormat,"%TIMESTAMP% %HOSTNAME% %syslogseverity-text:::uppercase% %syslogtag%%msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%\n" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we add milliseconds into syslog output? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately, from my research, it appears rsyslog doesn't provide granularity of milliseconds. It only provides "subseconds" which are, in fact, microseconds. Do we want microsecond granularity? If so, I'll add this. The format would appear as follows:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. it will work for me too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
$ActionFileDefaultTemplate SONiCFileFormat | ||
|
||
# | ||
# Set the default permissions for all log files. | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
## Quagga rules | ||
|
||
if $programname == ["quagga", | ||
"watchquagga", | ||
"zebra"] | ||
then { | ||
/var/log/quagga/zebra.log | ||
stop | ||
} | ||
|
||
if $programname == "bgpd" then { | ||
/var/log/quagga/bgpd.log | ||
stop | ||
} | ||
|
||
## Teamd rules | ||
|
||
if $programname contains "teamd_" then { | ||
/var/log/teamd.log | ||
stop | ||
} | ||
|
||
## SONiC rules | ||
|
||
if $programname == ["fpmsyncd", | ||
"intfsyncd", | ||
"neighsyncd", | ||
"orchagent", | ||
"portsyncd", | ||
"saidump", | ||
"saiplayer", | ||
"syncd", | ||
"swssconfig", | ||
"swssloglevel", | ||
"teamsyncd", | ||
"updategraph"] | ||
then { | ||
?SONiCPerProcessLogfile,SONiCFileFormat | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Per-process SONiC logging is not currently working. I don't think John finished this. I updated the list of programs, just in case we want it working, but I believe we'd just like everything to log to /var/log/syslog. If so, I will remove this. Please share your thoughts. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I decided to pull this for now, as it was incomplete. We can revisit it again in the future. |
||
stop | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,11 +3,13 @@ | |
# | ||
auth,authpriv.* /var/log/auth.log | ||
*.*;auth,authpriv.none -/var/log/syslog | ||
cron.* /var/log/cron.log | ||
daemon.* -/var/log/daemon.log | ||
kern.* -/var/log/kern.log | ||
kern.* -/var/persist/log/kern.log | ||
lpr.* -/var/log/lpr.log | ||
# Do not redirect cron, daemon, kernel or lpr logs to | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we really need this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see |
||
# their own files. Let them log to /var/log/syslog | ||
#cron.* /var/log/cron.log | ||
#daemon.* -/var/log/daemon.log | ||
#kern.* -/var/log/kern.log | ||
#kern.* -/var/persist/log/kern.log | ||
#lpr.* -/var/log/lpr.log | ||
mail.* -/var/log/mail.log | ||
user.* -/var/log/user.log | ||
|
||
|
@@ -32,10 +34,13 @@ news.notice -/var/log/news/news.notice | |
*.=debug;\ | ||
auth,authpriv.none;\ | ||
news.none;mail.none -/var/log/debug | ||
*.=info;*.=notice;*.=warn;\ | ||
auth,authpriv.none;\ | ||
cron,daemon.none;\ | ||
mail,news.none -/var/log/messages | ||
# | ||
# Removed as duplicates: | ||
#*.=info;*.=notice;*.=warn;\ | ||
# auth,authpriv.none;\ | ||
# cron,daemon.none;\ | ||
# mail,news.none -/var/log/messages | ||
# | ||
*.=crit;*.=alert;*.=emerg -/var/persist/log/alarms | ||
# | ||
# Emergencies are sent to everybody logged in. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# This file is part of systemd. | ||
# | ||
# systemd is free software; you can redistribute it and/or modify it | ||
# under the terms of the GNU Lesser General Public License as published by | ||
# the Free Software Foundation; either version 2.1 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# See journald.conf(5) for details | ||
|
||
[Journal] | ||
#Storage=auto | ||
#Compress=yes | ||
#Seal=yes | ||
#SplitMode=uid | ||
#SyncIntervalSec=5m | ||
#RateLimitInterval=30s | ||
#RateLimitBurst=1000 | ||
SystemMaxUse=50MB | ||
#SystemKeepFree= | ||
#SystemMaxFileSize= | ||
RuntimeMaxUse=50MB | ||
#RuntimeKeepFree= | ||
#RuntimeMaxFileSize= | ||
#MaxRetentionSec= | ||
#MaxFileSec=1month | ||
#ForwardToSyslog=yes | ||
#ForwardToKMsg=no | ||
#ForwardToConsole=no | ||
#ForwardToWall=yes | ||
#TTYPath=/dev/console | ||
#MaxLevelStore=debug | ||
#MaxLevelSyslog=debug | ||
#MaxLevelKMsg=notice | ||
#MaxLevelConsole=info | ||
#MaxLevelWall=emerg | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need to comment all entries out of this file? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is how John originally added the file. He only intended to take advantage of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm good with this. Thanks |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better put this as a file into /etc/cron.d/ ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current directory structure of files/image_config is not set to mirror the structure of /etc on the SONiC image. If we want to do this for crontab, we should rearrange everything into the /etc/... hierarchy to make things clear across the board.
Also, with our Debian distribution, crontab lives directly in /etc, not in /etc/cron.d.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I see in SONiC
$ ls /etc/cron*
/etc/crontab
/etc/cron.d:
/etc/cron.daily:
apt bsdmainutils dpkg logrotate ntp passwd
/etc/cron.hourly:
/etc/cron.monthly:
/etc/cron.weekly:
Can we put a file to /etc/cron.d/ directory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha. Done.