|
Packit Service |
a2ae7a |
(*
|
|
Packit Service |
a2ae7a |
Module: Xymon_Alerting
|
|
Packit Service |
a2ae7a |
Parses xymon alerting files
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
Author: Francois Maillard <fmaillard@gmail.com>
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
About: Reference
|
|
Packit Service |
a2ae7a |
This lens tries to keep as close as possible to `man 5 alerts.cfg` where possible.
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
About: License
|
|
Packit Service |
a2ae7a |
This file is licenced under the LGPL v2+, like the rest of Augeas.
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
About: Lens Usage
|
|
Packit Service |
a2ae7a |
To be documented
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
About: Not supported
|
|
Packit Service |
a2ae7a |
File inclusion are not followed
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
About: Configuration files
|
|
Packit Service |
a2ae7a |
This lens applies to /etc/xymon/alerts.d/*.cfg and /etc/xymon/alerts.cfg. See <filter>.
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
About: Examples
|
|
Packit Service |
a2ae7a |
The <Test_Xymon_Alerting> file contains various examples and tests.
|
|
Packit Service |
a2ae7a |
*)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
module Xymon_Alerting =
|
|
Packit Service |
a2ae7a |
autoload xfm
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* Group: USEFUL PRIMITIVES
|
|
Packit Service |
a2ae7a |
*************************************************************************)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: store_word *)
|
|
Packit Service |
a2ae7a |
let store_word = store /[^ =\t\n#]+/
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: comparison The greater and lesser than operators *)
|
|
Packit Service |
a2ae7a |
let comparison = store /[<>]/
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: equal *)
|
|
Packit Service |
a2ae7a |
let equal = Sep.equal
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: ws *)
|
|
Packit Service |
a2ae7a |
let ws = Sep.space
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: eol *)
|
|
Packit Service |
a2ae7a |
let eol = Util.eol
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: ws_or_eol *)
|
|
Packit Service |
a2ae7a |
let ws_or_eol = del /([ \t]+|[ \t]*\n[ \t]*)/ " "
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: comment *)
|
|
Packit Service |
a2ae7a |
let comment = Util.comment
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: empty *)
|
|
Packit Service |
a2ae7a |
let empty = Util.empty
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: include *)
|
|
Packit Service |
a2ae7a |
let include = [ key "include" . ws . store_word . eol ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* Group: MACRO DEFINITION
|
|
Packit Service |
a2ae7a |
*************************************************************************)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: macrodefinition
|
|
Packit Service |
a2ae7a |
A string that starts with $ and that is assigned something *)
|
|
Packit Service |
a2ae7a |
let macrodefinition = [ key /\$[^ =\t\n#\/]+/ . Sep.space_equal . store Rx.space_in . eol ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: flag
|
|
Packit Service |
a2ae7a |
A flag value *)
|
|
Packit Service |
a2ae7a |
let flag (kw:string) = Build.flag kw
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: kw_word
|
|
Packit Service |
a2ae7a |
A key=value value *)
|
|
Packit Service |
a2ae7a |
let kw_word (kw:regexp) = Build.key_value kw equal store_word
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* Group: FILTERS
|
|
Packit Service |
a2ae7a |
*************************************************************************)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: page
|
|
Packit Service |
a2ae7a |
The (ex)?page filter definition *)
|
|
Packit Service |
a2ae7a |
let page = kw_word /(EX)?PAGE/
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: group
|
|
Packit Service |
a2ae7a |
The (ex)?group filter definition *)
|
|
Packit Service |
a2ae7a |
let group = kw_word /(EX)?GROUP/
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: host
|
|
Packit Service |
a2ae7a |
The (ex)?host filter definition *)
|
|
Packit Service |
a2ae7a |
let host = kw_word /(EX)?HOST/
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: service
|
|
Packit Service |
a2ae7a |
The (ex)?service filter definition *)
|
|
Packit Service |
a2ae7a |
let service = kw_word /(EX)?SERVICE/
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: color
|
|
Packit Service |
a2ae7a |
The color filter definition *)
|
|
Packit Service |
a2ae7a |
let color = kw_word "COLOR"
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: time
|
|
Packit Service |
a2ae7a |
The time filter definition *)
|
|
Packit Service |
a2ae7a |
let time = kw_word "TIME"
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: duration
|
|
Packit Service |
a2ae7a |
The duration filter definition *)
|
|
Packit Service |
a2ae7a |
let duration = [ key "DURATION" . [ label "operator" . comparison ] . [ label "value" . store_word ] ]
|
|
Packit Service |
a2ae7a |
(* View: recover
|
|
Packit Service |
a2ae7a |
The recover filter definition *)
|
|
Packit Service |
a2ae7a |
let recover = flag "RECOVER"
|
|
Packit Service |
a2ae7a |
(* View: notice
|
|
Packit Service |
a2ae7a |
The notice filter definition *)
|
|
Packit Service |
a2ae7a |
let notice = flag "NOTICE"
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: rule_filter
|
|
Packit Service |
a2ae7a |
Filters are made out of any of the above filter definitions *)
|
|
Packit Service |
a2ae7a |
let rule_filter = page | group | host | service
|
|
Packit Service |
a2ae7a |
| color | time | duration | recover | notice
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: filters
|
|
Packit Service |
a2ae7a |
One or more filters *)
|
|
Packit Service |
a2ae7a |
let filters = [ label "filters" . Build.opt_list rule_filter ws ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: filters_opt
|
|
Packit Service |
a2ae7a |
Zero, one or more filters *)
|
|
Packit Service |
a2ae7a |
let filters_opt = [ label "filters" . (ws . Build.opt_list rule_filter ws)? ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: kw_word_filters_opt
|
|
Packit Service |
a2ae7a |
A <kw_word> entry with optional filters *)
|
|
Packit Service |
a2ae7a |
let kw_word_filters_opt (kw:string) = [ key kw . equal . store_word . filters_opt ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: flag_filters_opt
|
|
Packit Service |
a2ae7a |
A <flag> with optional filters *)
|
|
Packit Service |
a2ae7a |
let flag_filters_opt (kw:string) = [ key kw . filters_opt ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* Group: RECIPIENTS
|
|
Packit Service |
a2ae7a |
*************************************************************************)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: mail
|
|
Packit Service |
a2ae7a |
The mail recipient definition *)
|
|
Packit Service |
a2ae7a |
let mail = [ key "MAIL" . ws . store_word . filters_opt ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: script
|
|
Packit Service |
a2ae7a |
The script recipient definition *)
|
|
Packit Service |
a2ae7a |
let script = [ key "SCRIPT" . ws . [ label "script" . store_word ]
|
|
Packit Service |
a2ae7a |
. ws . [ label "recipient" . store_word ] . filters_opt ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: ignore
|
|
Packit Service |
a2ae7a |
The ignore recipient definition *)
|
|
Packit Service |
a2ae7a |
let ignore = flag_filters_opt "IGNORE"
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: format
|
|
Packit Service |
a2ae7a |
The format recipient definition *)
|
|
Packit Service |
a2ae7a |
let format = kw_word_filters_opt "FORMAT"
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: repeat
|
|
Packit Service |
a2ae7a |
The repeat recipient definition *)
|
|
Packit Service |
a2ae7a |
let repeat = kw_word_filters_opt "REPEAT"
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: unmatched
|
|
Packit Service |
a2ae7a |
The unmatched recipient definition *)
|
|
Packit Service |
a2ae7a |
let unmatched = flag_filters_opt "UNMATCHED"
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: stop
|
|
Packit Service |
a2ae7a |
The stop recipient definition *)
|
|
Packit Service |
a2ae7a |
let stop = flag_filters_opt "STOP"
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: macro
|
|
Packit Service |
a2ae7a |
The macro recipient definition *)
|
|
Packit Service |
a2ae7a |
let macro = [ key /\$[^ =\t\n#\/]+/ . filters_opt ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: recipient
|
|
Packit Service |
a2ae7a |
Recipients are made out of any of the above recipient definitions *)
|
|
Packit Service |
a2ae7a |
let recipient = mail | script | ignore | format | repeat | unmatched
|
|
Packit Service |
a2ae7a |
| stop | macro
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let recipients = [ label "recipients" . Build.opt_list recipient ws_or_eol ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* Group: RULES
|
|
Packit Service |
a2ae7a |
*************************************************************************)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: rule
|
|
Packit Service |
a2ae7a |
Rules are made of rule_filter and then recipients sperarated by a whitespace *)
|
|
Packit Service |
a2ae7a |
let rule = [ seq "rules" . filters . ws_or_eol . recipients . eol ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: lns
|
|
Packit Service |
a2ae7a |
The Xymon_Alerting lens *)
|
|
Packit Service |
a2ae7a |
let lns = ( rule | macrodefinition | include | empty | comment )*
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Variable: filter *)
|
|
Packit Service |
a2ae7a |
let filter = incl "/etc/xymon/alerts.d/*.cfg"
|
|
Packit Service |
a2ae7a |
. incl "/etc/xymon/alerts.cfg"
|
|
Packit Service |
a2ae7a |
. Util.stdexcl
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let xfm = transform lns filter
|
|
Packit Service |
a2ae7a |
|