Skip to content

Instantly share code, notes, and snippets.

@britcey
Created December 10, 2013 15:46
Show Gist options
  • Select an option

  • Save britcey/7892775 to your computer and use it in GitHub Desktop.

Select an option

Save britcey/7892775 to your computer and use it in GitHub Desktop.
rsyslog config to share Nagios logs through a Merlin cluster
$umask 0000
$FileCreateMode 0644
$DirCreateMode 0755
# for debugging
# $template HostLogs,"/var/tmp/rsyslog/%fromhost-ip%.log"
# *.* ?HostLogs
$template NagiosLogs,"/usr/local/nagios/var/cluster_logs/nagios-%$YEAR%-%$MONTH%-%$DAY%.log"
# date-unixtimestamp was introduced in the 6.x release of rsyslog
$template NagiosFormat,"[%timereported:::date-unixtimestamp%]%msg%\n"
$ModLoad imtcp
$InputTCPServerRun 514
# write remote nagios entries to the Nagios log, then stop
if $fromhost-ip != '127.0.0.1' and $app-name == 'nagios' then ?NagiosLogs;NagiosFormat
& stop
# write local nagios entries to the Nagios log
if $fromhost-ip == '127.0.0.1' and $app-name == 'nagios' then ?NagiosLogs;NagiosFormat
# central logging servers
if $fromhost-ip == '127.0.0.1' then @syslog01.xxx.xxx
if $fromhost-ip == '127.0.0.1' then @syslog02.xxx.xxx
# send Nagios messages to the other members of the cluster
$WorkDirectory /var/lib/rsyslog
$ActionQueueFileName nagios02.xxx.xxx
$ActionQueueMaxDiskSpace 1g
$ActionQueueSaveOnShutdown on
$ActionQueueType LinkedList
$ActionResumeRetryCount -1
if $fromhost-ip == '127.0.0.1' and $app-name == 'nagios' then @@1xx.xxx.xxx.xxx
$WorkDirectory /var/lib/rsyslog
$ActionQueueFileName nagios03.xxx.xxx
$ActionQueueMaxDiskSpace 1g
$ActionQueueSaveOnShutdown on
$ActionQueueType LinkedList
$ActionResumeRetryCount -1
if $fromhost-ip == '127.0.0.1' and $app-name == 'nagios' then @@1xx.xxx.xxx.xxx
$WorkDirectory /var/lib/rsyslog
$ActionQueueFileName nagios04.xxx.xxx
$ActionQueueMaxDiskSpace 1g
$ActionQueueSaveOnShutdown on
$ActionQueueType LinkedList
$ActionResumeRetryCount -1
if $fromhost-ip == '127.0.0.1' and $app-name == 'nagios' then @@1xx.xxx.xxx.xxx
$FileCreateMode 0600
$DirCreateMode 0700
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment