Bump to 1.14.1
[platform/upstream/augeas.git] / lenses / nagiosobjects.aug
1 (*
2 Module: NagiosObjects
3   Parses /etc/{nagios{3,},icinga}/objects/*.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
16   This lens applies to /etc/{nagios{3,},icinga}/objects/*.cfg. See <filter>.
17 *)
18
19 module NagiosObjects =
20     autoload xfm
21
22     (* basic atoms *)
23     let eol = Util.eol
24     let ws  = Sep.space
25
26     let keyword      = key /[A-Za-z0-9_]+/
27
28     (* optional, but preferred, whitespace *)
29     let opt_ws = del Rx.opt_space " "
30
31     (* define an empty line *)
32     let empty = Util.empty
33
34     (* define a comment *)
35     let comment = Util.comment_generic /[ \t]*[#;][ \t]*/ "# "
36
37     (* define a field *)
38     let object_field    =
39        let field_name      = keyword in
40        let field_value     = store Rx.space_in in
41           [ Util.indent . field_name . ws
42                         . field_value . eol ]
43
44     (* define an object *)
45     let object_def  =
46        let object_type = keyword in
47           [ Util.indent
48           . Util.del_str "define" . ws
49           . object_type . opt_ws
50           . Util.del_str "{" . eol
51           . ( empty | comment | object_field )*
52           . Util.indent . Util.del_str "}" . eol ]
53
54     (* main structure *)
55     let lns = ( empty | comment | object_def )*
56
57     let filter = incl "/etc/nagios3/objects/*.cfg"
58                . incl "/etc/nagios/objects/*.cfg"
59                . incl "/etc/icinga/objects/*.cfg"
60
61     let xfm = transform lns filter
62