|
Packit Service |
a2ae7a |
(*
|
|
Packit Service |
a2ae7a |
Module: Rsyslog
|
|
Packit Service |
a2ae7a |
Parses /etc/rsyslog.conf
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
Author: Raphael Pinson <raphael.pinsons@camptocamp.com>
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
About: Reference
|
|
Packit Service |
a2ae7a |
This lens tries to keep as close as possible to `man 5 rsyslog.conf` where possible.
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
About: License
|
|
Packit Service |
a2ae7a |
This file is licenced under the LGPL v2+, like the rest of Augeas.
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
About: Lens Usage
|
|
Packit Service |
a2ae7a |
To be documented
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
About: Configuration files
|
|
Packit Service |
a2ae7a |
This lens applies to /etc/rsyslog.conf. See <filter>.
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
About: Examples
|
|
Packit Service |
a2ae7a |
The <Test_Rsyslog> file contains various examples and tests.
|
|
Packit Service |
a2ae7a |
*)
|
|
Packit Service |
a2ae7a |
module Rsyslog =
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
autoload xfm
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let macro_rx = /[^,# \n\t][^#\n]*[^,# \n\t]|[^,# \n\t]/
|
|
Packit Service |
a2ae7a |
let macro = [ key /$[A-Za-z0-9]+/ . Sep.space . store macro_rx . Util.comment_or_eol ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let config_object_param = [ key /[A-Za-z.]+/ . Sep.equal . Quote.dquote
|
|
Packit Service |
a2ae7a |
. store /[^"]+/ . Quote.dquote ]
|
|
Packit Service |
a2ae7a |
(* Inside config objects, we allow embedded comments; we don't surface them
|
|
Packit Service |
a2ae7a |
* in the tree though *)
|
|
Packit Service |
a2ae7a |
let config_sep = del /[ \t]+|[ \t]*#.*\n[ \t]*/ " "
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let config_object =
|
|
Packit Service |
a2ae7a |
[ key /action|global|input|module|parser|timezone|include/ .
|
|
Packit Service |
a2ae7a |
Sep.lbracket .
|
|
Packit Service |
a2ae7a |
config_object_param . ( config_sep . config_object_param )* .
|
|
Packit Service |
a2ae7a |
Sep.rbracket . Util.comment_or_eol ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: users
|
|
Packit Service |
a2ae7a |
Map :omusrmsg: and a list of users, or a single *
|
|
Packit Service |
a2ae7a |
*)
|
|
Packit Service |
a2ae7a |
let omusrmsg = Util.del_str ":omusrmsg:" .
|
|
Packit Service |
a2ae7a |
Syslog.label_opt_list_or "omusrmsg" (store Syslog.word)
|
|
Packit Service |
a2ae7a |
Syslog.comma "*"
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: file_tmpl
|
|
Packit Service |
a2ae7a |
File action with a specified template *)
|
|
Packit Service |
a2ae7a |
let file_tmpl = Syslog.file . [ label "template" . Util.del_str ";" . store Rx.word ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let dynamic = [ Util.del_str "?" . label "dynamic" . store Rx.word ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let namedpipe = Syslog.pipe . Sep.space . [ label "pipe" . store Syslog.file_r ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let action = Syslog.action | omusrmsg | file_tmpl | dynamic | namedpipe
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Cannot use syslog program because rsyslog does not suppport #! *)
|
|
Packit Service |
a2ae7a |
let program = [ label "program" . Syslog.bang .
|
|
Packit Service |
a2ae7a |
( Syslog.opt_plus | [ Build.xchgs "-" "reverse" ] ) .
|
|
Packit Service |
a2ae7a |
Syslog.programs . Util.eol . Syslog.entries ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Cannot use syslog hostname because rsyslog does not suppport #+/- *)
|
|
Packit Service |
a2ae7a |
let hostname = [ label "hostname" .
|
|
Packit Service |
a2ae7a |
( Syslog.plus | [ Build.xchgs "-" "reverse" ] ) .
|
|
Packit Service |
a2ae7a |
Syslog.hostnames . Util.eol . Syslog.entries ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
59f964 |
(* View: actions *)
|
|
Packit Service |
59f964 |
let actions =
|
|
Packit Service |
59f964 |
let prop_act = [ label "action" . action ]
|
|
Packit Service |
59f964 |
in let act_sep = del /[ \t]*\n&[ \t]*/ "\n& "
|
|
Packit Service |
59f964 |
in Build.opt_list prop_act act_sep
|
|
Packit Service |
59f964 |
|
|
Packit Service |
a2ae7a |
(* View: entry
|
|
Packit Service |
a2ae7a |
An entry contains selectors and an action
|
|
Packit Service |
a2ae7a |
*)
|
|
Packit Service |
a2ae7a |
let entry = [ label "entry" . Syslog.selectors . Syslog.sep_tab .
|
|
Packit Service |
59f964 |
actions . Util.eol ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: prop_filter
|
|
Packit Service |
a2ae7a |
Parses property-based filters, which start with ":" and the property name *)
|
|
Packit Service |
a2ae7a |
let prop_filter =
|
|
Packit Service |
a2ae7a |
let sep = Sep.comma . Util.del_opt_ws " "
|
|
Packit Service |
a2ae7a |
in let prop_name = [ Util.del_str ":" . label "property" . store Rx.word ]
|
|
Packit Service |
a2ae7a |
in let prop_oper = [ label "operation" . store /[A-Za-z!-]+/ ]
|
|
Packit Service |
a2ae7a |
in let prop_val = [ label "value" . Quote.do_dquote (store /[^\n"]*/) ]
|
|
Packit Service |
a2ae7a |
in [ label "filter" . prop_name . sep . prop_oper . sep . prop_val .
|
|
Packit Service |
59f964 |
Sep.space . actions . Util.eol ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let entries = ( Syslog.empty | Util.comment | entry | macro | config_object | prop_filter )*
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let lns = entries . ( program | hostname )*
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let filter = incl "/etc/rsyslog.conf"
|
|
Packit Service |
a2ae7a |
. incl "/etc/rsyslog.d/*"
|
|
Packit Service |
a2ae7a |
. Util.stdexcl
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let xfm = transform lns filter
|