Rsyslog : Basic Usage2023/07/13 |
This is Basic Usage of Rsyslog that is the Log Management Service Daemon.
|
|
[1] | According to the configuration when installing Debian OS, though, for example, if Debian is installed without GUI, only selected [Standard system utilities], Rsyslog is not installed, only Jornald manages system logs, so if you need Rsyslog, it needs to install it. |
root:~# apt -y install rsyslog
|
[2] | Stored rules of logging data are configured in [/etc/rsyslog.conf] and included files. |
root@dlp:~# grep -v -E "^#|^$" /etc/rsyslog.conf module(load="imuxsock") # provides support for local system logging module(load="imklog") # provides kernel logging support $FileOwner root $FileGroup adm $FileCreateMode 0640 $DirCreateMode 0755 $Umask 0022 $WorkDirectory /var/spool/rsyslog $IncludeConfig /etc/rsyslog.d/*.conf *.*;auth,authpriv.none -/var/log/syslog auth,authpriv.* /var/log/auth.log cron.* -/var/log/cron.log kern.* -/var/log/kern.log mail.* -/var/log/mail.log user.* -/var/log/user.log *.emerg :omusrmsg:* # * how to write rules : (Facility).(Priority) (Action) # # ex : *.info;mail.none;authpriv.none;cron.none /var/log/messages # ⇒ [syslog] messages of [info] Priority of all Facilities are stored in [/var/log/messages] # ⇒ but messages of [mail], [authpriv], [cron] Facilities are not stored in [/var/log/messages] # # * the [-] that is added at the head of a filename means asynchronous output # if [-] is not added, logging data are written with synchronous output # * Facilities # kern : kernel messages # auth : authentication related messages # authpriv : authentication related messages (private) # cron : cron or at related messages # mail : mail services related messages # news : news related messages # uucp : uucp related messages # daemon : daemon services related messages # user : user level processes related messages # lpr : printer related messages # syslog : internal syslog related messages # local0 - local7 : possible to use for custom settings # * Priorities # emerg : maybe panic level troubles # alert : need to correct immediately more than critical # crit : need to correct immediately # err : common errors, non urgent failures # warning : warning messages # notice : not errors but some unusual events detected # info : normal operational messages # debug : debug information # none : none (not output) # * if you'd like to store only specified priority messages # add [=] like follows # ex : kern.=crit /dev/console |
[2] | To transfer logging data to remote Hosts, Configure like follows. |
###### on Syslog Server Host (receives logging data from other Hosts) ###### root@dlp:~# vi /etc/rsyslog.conf # line 20-21 : uncomment
line 22 : set allowed hosts to connect
module(load="imtcp")
input(type="imtcp" port="514")
$AllowedSender TCP, 127.0.0.1, 10.0.0.0/24, *.srv.world
root@dlp:~#
systemctl restart rsyslog
###### on Sender Host (sends logging data to Syslog Server Host) ###### root@node01:~# vi /etc/rsyslog.conf # add to the end action(type="omfwd" queue.filename="fwdRule_dlp.srv.world" queue.maxdiskspace="1g" queue.saveonshutdown="on" queue.type="LinkedList" action.resumeRetryCount="-1" Target="dlp.srv.world" Port="514" Protocol="tcp") # queue.filename : queue filename # queue.maxdiskspace : maxdiskspace for queue # queue.saveonshutdown=on : save queue data on disk when system shutdown # queue.type=LinkedList : asynchronous queue which can store 10,000 messages # action.resumeRetryCount=-1 : continue to retry sending when syslog server does not respond # Target=*** : specify syslog server Host
root@node01:~# systemctl restart rsyslog
###### that's OK, verify settings to see logs on syslog server Host ###### root@dlp:~# tail /var/log/syslog 2023-07-12T23:23:16-05:00 node01 systemd[1]: Stopped rsyslog.service - System Logging Service. 2023-07-12T23:23:16-05:00 node01 systemd[1]: Starting rsyslog.service - System Logging Service... 2023-07-12T23:23:16-05:00 node01 rsyslogd: imuxsock: Acquired UNIX socket '/run/systemd/journal/syslog' (fd 3) from systemd. [v8.2302.0] 2023-07-12T23:23:16-05:00 node01 rsyslogd: [origin software="rsyslogd" swVersion="8.2302.0" x-pid="965" x-info="https://www.rsyslog.com"] start 2023-07-12T23:23:16-05:00 node01 systemd[1]: Started rsyslog.service - System Logging Service. 2023-07-12T23:23:24-05:00 node01 systemd[1]: Stopping ssh.service - OpenBSD Secure Shell server... 2023-07-12T23:23:24-05:00 node01 systemd[1]: ssh.service: Deactivated successfully. 2023-07-12T23:23:24-05:00 node01 systemd[1]: Stopped ssh.service - OpenBSD Secure Shell server. 2023-07-12T23:23:24-05:00 node01 systemd[1]: Starting ssh.service - OpenBSD Secure Shell server... 2023-07-12T23:23:24-05:00 node01 systemd[1]: Started ssh.service - OpenBSD Secure Shell server. |
Sponsored Link |
|