Mediante rsyslog podemos mandar lo que se escriba en un fichero de log a syslog. Para ello configuraremos el modulo imfile que usa inotify por defecto.
Primero deberemos habilitar el modulo imfile en /etc/rsyslog.conf:
$ModLoad imfile
Para el fichero que usaremos de ejemplo, /var/log/mysqld.log, crearemos un fichero en el rsyslog.d, por ejemplo: /etc/rsyslog.d/mysqllog.conf
$InputFileName /var/log/mysqld.log $InputFileTag mysqld $InputFileStateFile mysqld-state $InputFileSeverity info $InputFileFacility local7 $InputRunFileMonitor
No debemos olvidar la opció $InputRunFileMonitor, ya que es la que habilita el monitor del fichero.
Una vez reiniciado el rsyslog veremos que empieza mandando todo el fichero al syslog, podemos apreciar que las fechas no coinciden:
Feb 19 19:19:43 mysql1 mysqld 2015-02-16 11:28:10 10184 [Note] Event Scheduler: scheduler thread started with id 1
A partir de entonces los cambios ya irán apareciendo en el syslog a mediad que se escriban en el fichero:
Feb 19 19:20:53 mysql1 mysqld 2015-02-19 19:20:49 10184 [Note] /usr/sbin/mysqld: Normal shutdown Feb 19 19:20:53 mysql1 mysqld 2015-02-19 19:20:49 10184 [Note] Giving 1 client threads a chance to die gracefully Feb 19 19:20:53 mysql1 mysqld 2015-02-19 19:20:49 10184 [Note] Event Scheduler: Killing the scheduler thread, thread id 1 Feb 19 19:20:53 mysql1 mysqld 2015-02-19 19:20:49 10184 [Note] Event Scheduler: Waiting for the scheduler thread to reply Feb 19 19:20:53 mysql1 mysqld 2015-02-19 19:20:49 10184 [Note] Event Scheduler: Stopped Feb 19 12:20:53 mysql1 mysqld 2015-02-19 19:20:49 10184 [Note] Event Scheduler: Purging the queue. 1 events Feb 19 19:20:53 mysql1 mysqld 2015-02-19 19:20:49 10184 [Note] Shutting down slave threads Feb 19 19:20:53 mysql1 mysqld 2015-02-19 19:20:49 10184 [Note] Forcefully disconnecting 0 remaining clients Feb 19 19:20:53 mysql1 mysqld 2015-02-19 19:20:49 10184 [Note] Binlog endTags: rsyslog
Enviar un fichero a syslog was first posted on February 23, 2015 at 8:34 am.