rsyslog server und 1 file pro client.

Alle weiteren Dienste, die nicht in die drei oberen Foren gehören.
Antworten
fichtl
Beiträge: 5
Registriert: 29.11.2013 21:39:02

rsyslog server und 1 file pro client.

Beitrag von fichtl » 08.02.2020 15:44:48

Grüezi Wohl

Ich hoffe es geht Euch allen gut.

Ich habe einen rsyslog server und je ein Cisco 2960 / 3750 L2 / L3 Switch.

Problembeschreibung und folgend die configs.

Eig. funktioniert alles, ich habe auf dem Server je eine file für die switches, /var/log/homelab/2960/log und /var/log/homelab/3750/log.
Das Problem ist nur, es werden alle remote Meldungen der Switches in die 2960 log file geschrieben.
Langsam macht mich die Fehlersuche stutzig... :)

Folgend die configs:

1) : /etc/rsyslog.d/2960.conf

Code: Alles auswählen

$template RemoteLogs, "/var/log/homelab/2960/log"
:fromhost-ip, isequal, "172.16.0.10" -?RemoteLogs
& ~
2) : /etc/rsyslog.d/3750.conf

Code: Alles auswählen

$template RemoteLogs, "/var/log/homelab/3750/log"
:fromhost-ip, isequal, "172.16.0.1" -?RemoteLogs
& ~
3) : /etc/rsyslog.conf

Code: Alles auswählen

# /etc/rsyslog.conf configuration file for rsyslog
#
# For more information install rsyslog-doc and see
# /usr/share/doc/rsyslog-doc/html/configuration/index.html


#################
#### MODULES ####
#################

module(load="imuxsock") # provides support for local system logging
module(load="imklog")   # provides kernel logging support
#module(load="immark")  # provides --MARK-- message capability

# provides UDP syslog reception
module(load="imudp")
input(type="imudp" port="514")

# provides TCP syslog reception
#module(load="imtcp")
#input(type="imtcp" port="514")


###########################
#### GLOBAL DIRECTIVES ####
###########################

#
# Use traditional timestamp format.
# To enable high precision timestamps, comment out the following line.
#
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat

#
# Set the default permissions for all log files.
#
$FileOwner root
$FileGroup adm
$FileCreateMode 0640
$DirCreateMode 0755
$Umask 0022

#
# Where to place spool and state files
#
$WorkDirectory /var/spool/rsyslog

#
# Include all config files in /etc/rsyslog.d/
#
$IncludeConfig /etc/rsyslog.d/*.conf


###############
#### RULES ####
###############

#
# First some standard log files.  Log by facility.
#
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
lpr.*                           -/var/log/lpr.log
mail.*                          -/var/log/mail.log
user.*                          -/var/log/user.log

#
# Logging for the mail system.  Split it up so that
# it is easy to write scripts to parse these files.
#
mail.info                       -/var/log/mail.info
mail.warn                       -/var/log/mail.warn
mail.err                        /var/log/mail.err

#
# Some "catch-all" log files.
#
*.=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

#
# Emergencies are sent to everybody logged in.
#
*.emerg                         :omusrmsg:*
Also ich hoffe wirklich ich übersehe da etwas....

Ich danke schon mal fürs lesen und grüsse Euch.

Edit:
Hier noch die 2960 log file, während die 3750 log file leer ist... :)

Code: Alles auswählen

Feb  8 08:34:42 172.16.0.1 119: Feb  8 08:34:41.350: %LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet1/0/1, changed state to down
Feb  8 08:34:44 172.16.0.1 120: Feb  8 08:34:43.355: %LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet1/0/1, changed state to up
Feb  8 08:49:22 172.16.0.10 372: Feb  8 08:48:59: %LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet1/0/26, changed state to down
Feb  8 08:49:23 172.16.0.10 373: Feb  8 08:49:00: %LINK-3-UPDOWN: Interface GigabitEthernet1/0/26, changed state to down
Feb  8 11:26:04 172.16.0.10 374: Feb  8 11:25:41: %LINK-3-UPDOWN: Interface GigabitEthernet1/0/26, changed state to up
Feb  8 11:26:04 172.16.0.10 375: Feb  8 11:25:42: %LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet1/0/26, changed state to up
Feb  8 11:57:53 172.16.0.1 121: Feb  8 11:57:53.152: %LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet1/0/1, changed state to down
Feb  8 11:57:54 172.16.0.1 122: Feb  8 11:57:54.150: %LINK-3-UPDOWN: Interface GigabitEthernet1/0/1, changed state to down
Feb  8 11:58:18 172.16.0.1 123: Feb  8 11:58:17.529: %LINK-3-UPDOWN: Interface GigabitEthernet1/0/1, changed state to up
Feb  8 11:58:18 172.16.0.1 124: Feb  8 11:58:18.535: %LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet1/0/1, changed state to up
Feb  8 12:09:55 172.16.0.1 125: Feb  8 12:09:54.840: %LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet1/0/1, changed state to down
Feb  8 12:09:56 172.16.0.1 126: Feb  8 12:09:55.839: %LINK-3-UPDOWN: Interface GigabitEthernet1/0/1, changed state to down
Feb  8 12:09:58 172.16.0.1 127: Feb  8 12:09:58.053: %LINK-3-UPDOWN: Interface GigabitEthernet1/0/1, changed state to up
Feb  8 12:09:58 172.16.0.1 128: Feb  8 12:09:59.060: %LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet1/0/1, changed state to up
Feb  8 12:10:09 172.16.0.1 129: Feb  8 12:10:08.707: %LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet1/0/1, changed state to down
Feb  8 12:10:10 172.16.0.1 130: Feb  8 12:10:09.705: %LINK-3-UPDOWN: Interface GigabitEthernet1/0/1, changed state to down
Feb  8 12:10:13 172.16.0.1 131: Feb  8 12:10:12.297: %LINK-3-UPDOWN: Interface GigabitEthernet1/0/1, changed state to up
Feb  8 12:10:13 172.16.0.1 132: Feb  8 12:10:13.304: %LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet1/0/1, changed state to up
Feb  8 12:40:38 172.16.0.1 133: Feb  8 12:40:38.061: %LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet1/0/1, changed state to down
Feb  8 12:40:39 172.16.0.1 134: Feb  8 12:40:39.059: %LINK-3-UPDOWN: Interface GigabitEthernet1/0/1, changed state to down
Feb  8 12:40:44 172.16.0.1 135: Feb  8 12:40:43.245: %LINK-3-UPDOWN: Interface GigabitEthernet1/0/1, changed state to up
Feb  8 12:40:44 172.16.0.1 136: Feb  8 12:40:44.251: %LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet1/0/1, changed state to up

Benutzeravatar
HZB
Beiträge: 486
Registriert: 22.10.2003 11:52:15
Wohnort: Wien

Re: rsyslog server und 1 file pro client.

Beitrag von HZB » 09.02.2020 08:15:49

Probier mal folgendes:

Nimm $IncludeConfig /etc/rsyslog.d/*.conf raus und füge direkt in der rsyslog.conf mal das ein:

Code: Alles auswählen

If $fromhost-ip=='172.16.0.10' then /var/log/homelab/2960/switch1.log
& ~
if $fromhost-ip=='172.16.0.1' then /var/log/homelab/3750/switch2.log
& ~
https://www.rsyslog.com/storing-message ... ific-file/

Das mit den Templates muss ich ehrlich gestehen hab ich noch nie gemacht. kA ob es vielleicht deshalb ist weil beide templates RemoteLogs heissen.

HTH

Antworten