Bump to 1.14.1
[platform/upstream/augeas.git] / lenses / nagioscfg.aug
1 (*
2 Module: NagiosConfig
3   Parses /etc/{nagios{3,},icinga}/*.cfg
4
5 Authors: Sebastien Aperghis-Tramoni <sebastien@aperghis.net>
6          RaphaĆ«l Pinson <raphink@gmail.com>
7
8 About: License
9   This file is licenced under the LGPL v2+, like the rest of Augeas.
10
11 About: Lens Usage
12   To be documented
13
14 About: Configuration files
15   This lens applies to /etc/{nagios{3,},icinga}/*.cfg. See <filter>.
16 *)
17
18 module NagiosCfg =
19 autoload xfm
20
21 (************************************************************************
22  * Group: Utility variables/functions
23  ************************************************************************)
24 (* View: param_def
25     define a field *)
26 let param_def =
27      let space_in  = /[^ \t\n][^\n=]*[^ \t\n]|[^ \t\n]/
28   in key /[A-Za-z0-9_]+/
29    . Sep.opt_space . Sep.equal . Sep.opt_space
30    . store space_in
31
32 (* View: macro_def
33     Macro line, as used in resource.cfg *)
34 let macro_def =
35      let macro = /\$[A-Za-z0-9]+\$/
36        in let macro_decl = Rx.word | Rx.fspath
37      in key macro . Sep.space_equal . store macro_decl
38
39 (************************************************************************
40  * Group: Entries
41  ************************************************************************)
42 (* View: param
43     Params can have sub params *)
44 let param =
45      [ Util.indent . param_def
46      . [ Sep.space . param_def ]*
47      . Util.eol ]
48
49 (* View: macro *)
50 let macro = [ Util.indent . macro_def . Util.eol ]
51
52 (************************************************************************
53  * Group: Lens
54  ************************************************************************)
55 (* View: entry
56     Define the accepted entries, such as param for regular configuration
57     files, and macro for resources.cfg .*)
58 let entry = param
59           | macro
60
61 (* View: lns
62     main structure *)
63 let lns = ( Util.empty | Util.comment | entry )*
64
65 (* View: filter *)
66 let filter = incl "/etc/nagios3/*.cfg"
67            . incl "/etc/nagios/*.cfg"
68            . incl "/etc/icinga/*.cfg"
69            . excl "/etc/nagios3/commands.cfg"
70            . excl "/etc/nagios/commands.cfg"
71            . excl "/etc/nagios/nrpe.cfg"
72            . incl "/etc/icinga/commands.cfg"
73
74 let xfm = transform lns filter