Page 1 of 1

Testing nagios log server

Posted: Sat Jan 11, 2020 11:21 am
by fsodah
I am in the process evaluating nagios log server comparing with other products.
I did the setup working perfectly, however how can I sniff for example all logs from my linux server under /var/log/, can you please give me a sample rsyslog.conf that capture all logs under linux, I am attaching my rsyslog.conf from a linux machine the one I am using now



Code: Select all

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

*.* @@10.1.23.111:514
#################
#### 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:*
# ### begin forwarding rule ### NAGIOSLOGSERVER
#
#$WorkDirectory /var/lib/rsyslog # where to place spool files
$ActionQueueFileName fwdRule1 # unique name prefix for spool files
$ActionQueueMaxDiskSpace 1g   # 1gb space limit (use as much as possible)
$ActionQueueSaveOnShutdown on # save messages to disk on shutdown
$ActionQueueType LinkedList   # run asynchronously
$ActionResumeRetryCount -1    # infinite retries if host is down
# remote host is: name/ip:port, e.g. 192.168.0.1:514, port optional
*.* @@10.1.23.111:5544
# ### end of the forwarding rule ###

module(load="imfile" PollingInterval="10")

# Apache access file:
input(type="imfile"
      File="/var/log/apache2/access.log"
      Tag="apache-access"
      Severity="info")

# Apache error file:
input(type="imfile"
      File="/var/log/apache2/error.log"
      Tag="apache-error"
      Severity="info")


# Input for mysqld.log
$InputFileName /var/log/mysql/error.log
$InputFileTag mysqld_log:
$InputFileStateFile nls-state-mysqld_log # Must be unique for each file being polled
# Uncomment the folowing line to override the default severity for messages
# from this file.
#$InputFileSeverity info
$InputFilePersistStateInterval 20000
$InputRunFileMonitor

# Forward to Nagios Logserver and then discard.
if $programname == 'mysqld_log' then @@10.1.23.111:5544
if $programname == 'mysqld_log' then ~


root@kali:/etc#


Re: Testing nagios log server

Posted: Mon Jan 13, 2020 2:52 pm
by cdienger
I would recommend using the setup-linux.sh script to send over the logs. This will create the proper rsyslog configuration under /etc/rsyslog.d/. It can be found on the NLS server by pointing your browser to http://nls-ip/nagioslogserver/configure ... inux-files.

I wouldn't recommend sending over all logs found here with a single configuration. The logs will have different formats and using separate configurations will allow you to add additional filtering easier if it is needed.

For example, I would run the script twice if I wanted to see both auth and boot logs in NLS:

Code: Select all

sudo bash setup-linux.sh -s 192.168.55.3 -p 5544 -f "/var/log/auth.log" -t auth_logs
sudo bash setup-linux.sh -s 192.168.55.3 -p 5544 -f "/var/log/boot.log" -t boot_logs

Re: Testing nagios log server

Posted: Tue Jan 14, 2020 3:00 pm
by fsodah
Thank really appreciated .... Done
Please close the ticket