[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: rsyslog e variabili



Ciao Davide,
scusa la risposta non tempestiva, appena avrò un po di tempo mi ci metto con piu determinazione.

Grazie cmq per la disponibilità.

Vi farò sapere.

Saluti, ALessandro.
On 09/03/2012 07:01 PM, Davide Prina wrote:
On 03/09/2012 11:42, Alessandro Baggi wrote:

è possibile usare variabili per effettuare delle sostituzioni, per
esempio dei path, per i file di log?

non lo so, non ho mai provato

Esempio:

$define VARIABILE "/var/log/qualcosa"
*.*.... $VARIABILE/auth.log

però se guardi il file /etc/rsyslog.conf o il man
$ man rsyslog.conf

vedi subito che con quel formato non funziona.
Per esempio per prendere l'$HOSTNAME usa %HOSTNAME%, mentre i $VARIABILE sono usati per delle variabili interne

Ho provato ad utilizzare i template:

$template FILETEMPLATE,"/var/log/%fromhost-ip%"
*.* ?FILETEMPLATE/auth.log

non avevo visto questo pezzo...

Templates allow you to specify format of the logged message. They are also used for dynamic file name generation. They have to be defined before they are used in rules. For more info about templates see TEMPLATES section of this manpage.

ma, vedendo velocemente l'help potresti usare la "Shell execute", ti crei uno script eseguibile (nel path) che imposta le tue variabili (con export) e poi lo richiami con ^
Poi dovresti poter usare le variabili nella forma %VARIABILE%

Please note that templates can also by used to generate selector lines with dynamic file names. For example, if you would like to split syslog messages from different hosts to different files (one per host), you can define the following template:
    $template DynFile,"/var/log/system-%HOSTNAME%.log"

hmm... ti conviene leggerti bene il man e poi fai qualche prova

Ciao
Davide



Reply to: