Ntpd

Parses OpenNTPD’s ntpd.conf

Author: Jasper Lievisse Adriaanse jas.nosp@m.per@jasp.nosp@m.er.la

Summary
NtpdParses OpenNTPD’s ntpd.conf
ReferenceThis lens is used to parse OpenNTPD’s configuration file, ntpd.conf.
Usage ExampleTo be documented
LicenseThis file is licensed under the LGPL v2+, like the rest of Augeas.
Configuration filesThis lens applies to /etc/ntpd.conf.
Utility variables/functions
comment
empty
eol
space
word
device_re
address_re
stratum_revalue between 1 and 15
refid_restring with length < 5
weight_revalue between 1 and 10
rtable_re
correction_reshould actually only match between -127000000 and 127000000
key_opt_rtable_lineA subnode with a keyword, an optional routing table id and an end of line.
key_opt_weight_rtable_lineA subnode with a keyword, an optional routing table id, an optional weight-value and an end of line.
opt_valueA subnode for optional values.
Keywords
listenlisten on address [rtable table-id]
serverserver address [weight weight-value] [rtable table-id]
serversservers address [weight weight-value] [rtable table-id]
sensorsensor device [correction microseconds] [weight weight-value] [refid string] [stratum stratum-value]
Lens
keyword
lns
filter

Reference

This lens is used to parse OpenNTPD’s configuration file, ntpd.conf.  http://openntpd.org/

Usage Example

To be documented

License

This file is licensed under the LGPL v2+, like the rest of Augeas.

Configuration files

This lens applies to /etc/ntpd.conf.  See filter.

Utility variables/functions

comment

let comment = Util.comment

empty

let empty = Util.empty

eol

let eol = Util.eol

space

let space = Sep.space

word

let word = Rx.word

device_re

let device_re = Rx.device_name | /\*/

address_re

let address_re = Rx.ip | /\*/ | Rx.hostname

stratum_re

let stratum_re = /1[0-5]|[1-9]/

value between 1 and 15

refid_re

let refid_re = /[A-Za-z0-9_.-]{1,5}/

string with length < 5

weight_re

let weight_re = /10|[1-9]/

value between 1 and 10

rtable_re

let rtable_re = Rx.byte
0RT_TABLE_MAX

correction_re

let correction_re = Rx.relinteger_noplus

should actually only match between -127000000 and 127000000

key_opt_rtable_line

let key_opt_rtable_line (kw:regexp) (sto:lens) = let rtable = [ Util.del_str "rtable" . space . label "rtable" . store rtable_re ] in [ key kw . space . sto . (space . rtable)? . eol ]

A subnode with a keyword, an optional routing table id and an end of line.

Parameters

kw:regexpthe pattern to match as key
sto:lensthe storing lens

key_opt_weight_rtable_line

let key_opt_weight_rtable_line (kw:regexp) (sto:lens) = let rtable = [ Util.del_str "rtable" . space . label "rtable" . store rtable_re ] in let weight = [ Util.del_str "weight" . space . label "weight" . store weight_re ] in [ key kw . space . sto . (space . weight)? . (space . rtable)? . eol ]

A subnode with a keyword, an optional routing table id, an optional weight-value and an end of line. of line.

Parameters

kw:regexpthe pattern to match as key
sto:lensthe storing lens

opt_value

let opt_value (s:string) (r:regexp) = Build.key_value s space (store r)

A subnode for optional values.

Parameters

s:stringthe option name and subtree label
r:regexpthe pattern to match as store

Keywords

listen

let listen = let addr = [ label "address" . store address_re ] in key_opt_rtable_line "listen on" addr

listen on address [rtable table-id]

server

let server = let addr = [ label "address" . store address_re ] in key_opt_weight_rtable_line "server" addr

server address [weight weight-value] [rtable table-id]

servers

let servers = let addr = [ label "address" . store address_re ] in key_opt_weight_rtable_line "servers" addr

servers address [weight weight-value] [rtable table-id]

sensor

let sensor = let device = [ label "device" . store device_re ] in let correction = opt_value "correction" correction_re in let weight = opt_value "weight" weight_re in let refid = opt_value "refid" refid_re in let stratum = opt_value "stratum" stratum_re in [ key "sensor" . space . device . (space . correction)? . (space . weight)? . (space . refid)? . (space . stratum)? . eol ]

sensor device [correction microseconds] [weight weight-value] [refid string] [stratum stratum-value]

Lens

keyword

let keyword = listen | server | servers | sensor

lns

let lns = ( empty | comment | keyword )*

filter

let comment = Util.comment
let empty = Util.empty
let eol = Util.eol
let space = Sep.space
let word = Rx.word
let device_re = Rx.device_name | /\*/
let address_re = Rx.ip | /\*/ | Rx.hostname
let stratum_re = /1[0-5]|[1-9]/
value between 1 and 15
let refid_re = /[A-Za-z0-9_.-]{1,5}/
string with length < 5
let weight_re = /10|[1-9]/
value between 1 and 10
let rtable_re = Rx.byte
let correction_re = Rx.relinteger_noplus
should actually only match between -127000000 and 127000000
let key_opt_rtable_line (kw:regexp) (sto:lens) = let rtable = [ Util.del_str "rtable" . space . label "rtable" . store rtable_re ] in [ key kw . space . sto . (space . rtable)? . eol ]
A subnode with a keyword, an optional routing table id and an end of line.
let key_opt_weight_rtable_line (kw:regexp) (sto:lens) = let rtable = [ Util.del_str "rtable" . space . label "rtable" . store rtable_re ] in let weight = [ Util.del_str "weight" . space . label "weight" . store weight_re ] in [ key kw . space . sto . (space . weight)? . (space . rtable)? . eol ]
A subnode with a keyword, an optional routing table id, an optional weight-value and an end of line.
let opt_value (s:string) (r:regexp) = Build.key_value s space (store r)
A subnode for optional values.
let listen = let addr = [ label "address" . store address_re ] in key_opt_rtable_line "listen on" addr
listen on address [rtable table-id]
let server = let addr = [ label "address" . store address_re ] in key_opt_weight_rtable_line "server" addr
server address [weight weight-value] [rtable table-id]
let servers = let addr = [ label "address" . store address_re ] in key_opt_weight_rtable_line "servers" addr
servers address [weight weight-value] [rtable table-id]
let sensor = let device = [ label "device" . store device_re ] in let correction = opt_value "correction" correction_re in let weight = opt_value "weight" weight_re in let refid = opt_value "refid" refid_re in let stratum = opt_value "stratum" stratum_re in [ key "sensor" . space . device . (space . correction)? . (space . weight)? . (space . refid)? . (space . stratum)? . eol ]
sensor device [correction microseconds] [weight weight-value] [refid string] [stratum stratum-value]
let keyword = listen | server | servers | sensor
let lns = ( empty | comment | keyword )*
Close