1 (* BB-hosts module for Augeas *)
2 (* Author: Raphael Pinson <raphink@gmail.com> *)
12 (* Define useful shortcuts *)
15 let eol_no_spc = Util.del_str "\n"
16 let sep_spc = Sep.space
17 let sep_opt_spc = Sep.opt_space
18 let word = store /[^|;# \n\t]+/
19 let value_to_eol = store /[^ \t][^\n]+/
20 let ip = store Rx.ipv4
21 let url = store /https?:[^# \n\t]+/
22 let word_cont = store /[^;# \n\t]+/
24 (* Define comments and empty lines *)
25 let comment = Util.comment
26 let empty = Util.empty
30 let host_ip = [ label "ip" . ip ]
31 let host_fqdn = [ label "fqdn" . sep_spc . word ]
33 let host_test_url = [ label "url" . url ]
34 let host_test_cont (kw:string) = [ store /!?/ . key kw .
36 [ label "url" . word_cont ] .
37 (Util.del_str ";" . [ label "keyword" . word ])?
41 (* DOWNTIME=[columns:]day:starttime:endtime:cause[,day:starttime:endtime:cause] *)
42 let host_test_downtime =
43 let probe = [ label "probe" . store (Rx.word | "*") ]
44 in let probes = Build.opt_list probe Sep.comma
45 in let day = [ label "day" . store (Rx.word | "*") ]
46 in let starttime = [ label "starttime" . store Rx.integer ]
47 in let endtime = [ label "endtime" . store Rx.integer ]
48 in let cause = [ label "cause" . Util.del_str "\"" . store /[^"]*/ . Util.del_str "\"" ]
49 in [ key "DOWNTIME" . Sep.equal
50 . (probes . Sep.colon)?
52 . starttime . Sep.colon
57 let host_test_flag_value = [ label "value" . Util.del_str ":"
60 let host_test_flag (kw:regexp) = [ store /!?/ . key kw
61 . host_test_flag_value? ]
63 let host_test = host_test_cont "cont"
64 | host_test_cont "contInsecure"
65 | host_test_cont "dns"
66 | host_test_flag "BBDISPLAY"
67 | host_test_flag "BBNET"
68 | host_test_flag "BBPAGER"
69 | host_test_flag "CDB"
70 | host_test_flag "GTM"
71 | host_test_flag "XYMON"
72 | host_test_flag "ajp13"
73 | host_test_flag "bbd"
74 | host_test_flag "clamd"
75 | host_test_flag "cupsd"
76 | host_test_flag "front"
77 | host_test_flag /ftps?/
78 | host_test_flag /imap[2-4s]?/
79 | host_test_flag /ldaps?/
80 | host_test_flag /nntps?/
81 | host_test_flag "noconn"
82 | host_test_flag "nocont"
83 | host_test_flag "noping"
84 | host_test_flag "notrends"
85 | host_test_flag "oratns"
86 | host_test_flag /pop-?[2-3]?s?/
87 | host_test_flag "qmqp"
88 | host_test_flag "qmtp"
89 | host_test_flag "rsync"
90 | host_test_flag /smtps?/
91 | host_test_flag "spamd"
92 | host_test_flag /ssh[1-2]?/
93 | host_test_flag /telnets?/
94 | host_test_flag "vnc"
98 let host_test_list = Build.opt_list host_test sep_spc
100 let host_opts = [ label "probes" . sep_spc . Util.del_str "#" . (sep_opt_spc . host_test_list)? ]
102 let host = [ label "host" . host_ip . host_fqdn . host_opts . eol ]
104 (* Define group-compress and group-only *)
105 let group_compress = [ key /group(-compress)?/ . (sep_spc . value_to_eol)? . eol_no_spc .
106 ( comment | empty | host)*
109 let group_only_col = [ label "col" . word ]
110 let group_only_cols = sep_spc . group_only_col . ( Util.del_str "|" . group_only_col )*
111 let group_only = [ key "group-only" . group_only_cols . sep_spc . value_to_eol . eol_no_spc .
112 ( comment | empty | host)*
117 let page_title = [ label "title" . sep_spc . value_to_eol ]
118 let page = [ key "page" . sep_spc . word . page_title? . eol_no_spc .
119 ( comment | empty | host )* . ( group_compress | group_only )*
125 let lns = (comment | empty)* . page*
127 let filter = incl "/etc/bb/bb-hosts"
129 let xfm = transform lns filter