Imported Upstream version 0.10.0
[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 LGPLv2+, 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
22 (* View: command
23     nrpe.cfg usually has many entries defining commands to run
24
25     > command[check_foo]=/path/to/nagios/plugin -w 123 -c 456
26     > command[check_bar]=/path/to/another/nagios/plugin --option
27 *)
28 let command =
29   let obrkt = del /\[/ "[" in
30   let cbrkt = del /\]/ "]" in
31     [ key "command" .
32     [ obrkt . key /[^]\/\n]+/ . cbrkt . eq
33             . store /[^\n]+/ . del /\n/ "\n" ]
34     ]
35
36
37 (* View: item_re
38      regular entries re *)
39 let item_re = "server_port"
40             | "command_prefix"
41             | "server_address"
42             | "allowed_hosts"
43             | "debug"
44             | "nrpe_user"
45             | "nrpe_group"
46             | "dont_blame_nrpe"
47             | "command_timeout"
48             | "connection_timeout"
49             | "allow_weak_random_seed"
50             | "pid_file"
51             | "log_facility"
52
53 (* View: item
54      regular entries *)
55 let item = [ key item_re . eq . store word . eol ]
56
57
58 (* View: include
59     An include entry.
60
61     nrpe.cfg can include more than one file or directory of files
62
63     > include=/path/to/file1.cfg
64     > include=/path/to/file2.cfg
65 *)
66 let include = [ key "include" .
67   [ label "file" . eq . store word . eol ]
68 ]
69
70 (* View: include_dir
71     > include_dir=/path/to/dir/
72 *)
73 let include_dir = [ key "include_dir" .
74   [ label "dir" . eq . store word . eol ]
75 ]
76
77
78 (* View: comment
79     Nrpe comments must start at beginning of line *)
80 let comment = Util.comment_generic /#[ \t]*/ "# "
81
82 (* blank lines and empty comments *)
83 let empty = Util.empty
84
85 (* View: lns
86     The Nrpe lens *)
87 let lns = ( command | item | include | include_dir | comment | empty ) *
88
89 (* View: filter
90     File filter *)
91 let filter = Util.stdexcl .
92              incl "/etc/nrpe.cfg" .
93              incl "/etc/nagios/nrpe.cfg"
94
95 let xfm = transform lns (filter)
96