Bump to 1.14.1
[platform/upstream/augeas.git] / lenses / nrpe.aug
1 (*
2 Module: Nrpe
3   Parses nagios-nrpe configuration files.
4
5 Author: Marc Fournier <marc.fournier@camptocamp.com>
6
7 About: License
8   This file is licensed under the LGPL v2+, like the rest of Augeas.
9 *)
10
11 module Nrpe =
12   autoload xfm
13
14
15 let eol = Util.eol
16 let eq = Sep.equal
17
18 (* View: word *)
19 let word = /[^=\n\t ]+/
20
21 (* View: item_re *)
22 let item_re = /[^#=\n\t\/ ]+/ - (/command\[[^]\/\n]+\]/ | "include" | "include_dir")
23
24 (* View: command
25     nrpe.cfg usually has many entries defining commands to run
26
27     > command[check_foo]=/path/to/nagios/plugin -w 123 -c 456
28     > command[check_bar]=/path/to/another/nagios/plugin --option
29 *)
30 let command =
31   let obrkt = del /\[/ "[" in
32   let cbrkt = del /\]/ "]" in
33     [ key "command" .
34     [ obrkt . key /[^]\/\n]+/ . cbrkt . eq
35             . store /[^\n]+/ . del /\n/ "\n" ]
36     ]
37
38
39 (* View: item
40      regular entries
41
42      > allow_bash_command_substitution=0
43 *)
44 let item = [ key item_re . eq . store word . eol ]
45
46 (* View: include
47     An include entry.
48
49     nrpe.cfg can include more than one file or directory of files
50
51     > include=/path/to/file1.cfg
52     > include=/path/to/file2.cfg
53 *)
54 let include = [ key "include" .
55   [ label "file" . eq . store word . eol ]
56 ]
57
58 (* View: include_dir
59     > include_dir=/path/to/dir/
60 *)
61 let include_dir = [ key "include_dir" .
62   [ label "dir" . eq . store word . eol ]
63 ]
64
65
66 (* View: comment
67     Nrpe comments must start at beginning of line *)
68 let comment = Util.comment_generic /#[ \t]*/ "# "
69
70 (* blank lines and empty comments *)
71 let empty = Util.empty
72
73 (* View: lns
74     The Nrpe lens *)
75 let lns = ( command | include | include_dir | item | comment | empty ) *
76
77 (* View: filter
78     File filter *)
79 let filter = incl "/etc/nrpe.cfg" .
80              incl "/etc/nagios/nrpe.cfg"
81
82 let xfm = transform lns (filter)
83