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