mk-dmon-work - generate dmon work-files
Usage: mk-dmon-work [-v] [-q] [-d] [-f] [-h] [-l] [-w conf] [-c conf] option v : be verbose option q : be quiet option d : show debug info option f : action ; otherwise dry-run option h : show help ; exit option l : show item-list ; exit default : show : item-name with -v : show : item-name kind probe default-args with -d : show as json object option w : use work-config file <conf> ; default [ work.conf, /etc/dmon/work ] option c : use dmon-config file <conf> ; default [ dmon.conf, /etc/dmon/conf ]
Program mk-dmon-work reads a work-config file and generates a work-file for the dmon-server, each dmon-client and the dmon-pagemaker.
The work-config-file is described below ; see WORK.CONF.
The work-files are generated into a staging directory (note the .tmp) :
/var/dmon/works.tmp/
If -f is specified, mk-dmon-work rsyncs (preserving timestamps) into :
/var/dmon/works.tmp/ => /var/dmon/works/
Note : rsync
uses -c --no-t, copying only files with a changed checksum,
and preserving last-change time-stamps on others.
The last-change time-stamps on work-files matter ; dmon assumes that a newer file indicates updated content.
On startup, a dmon-client issues a WORK-command to the server, which responds with a work-file-text and a last-modified timestamp.
Later, periodicly (default every 10 minutes), the client examines
the last-modified timestamp of the client's work-file on the server.
The timestamp is sent be the server in response to a client's REPORT
command. If that is not available, the client issues a WORK_LM
command to the server, which responds with the client's
work-file timestamp.
If the timestamp has changed, the client reloads itself.
be quiet
be verbose
show debug info ; internals
show help ; exit
show the list of item-names, one name per line ; then exit. With -v, also show the item's probe and default probe-arguments. With -d, show all items as a JSON-object.
use work-config conf ; default : work.conf
, /etc/dmon/work
use dmon-config conf ; default : dmon.conf
, /etc/dmon/conf
The default locations of the config file are :
A work-config file looks like this :
+-------------------------------------------------- |# lines that start with '#' are comment |# blank lines are ignored too |# tabs are replaced by a space | |# the config entries are 'keyword' and 'value' pairs |# a 'keyword' begins in column 1 |# the 'value' is the rest of the line |somekey part1 part2 part3 ... |otherkey part1 part2 part3 ... | |# indented lines are glued |# the next three lines mean 'somekey part1 part2 part3' |somekey part1 | part2 | part3 +--------------------------------------------------
In the sections below, we use the following notation :
⟦ X ⟧ means X is optional ;
X ∥ Y means either X or Y ;
❪ ... ❫ is used for grouping.
The main purpose of the work-config is to specify which items each host must monitor.
There are many items and usually there are many hosts, so a plain (host,item)-list would be very long. To condense the list, we use grouping of hosts and items.
hosts linux_hosts host1 host2 host3 ... items linux_items cpu_load uptime root_avail root_usage ...
To specify that all linux_hosts must monitor all linux_items you can simply write :
get @linux_hosts @linux_items
You can build larger groups out of atoms and smaller groups :
hosts ftpd_servers host1 host2 ... hosts http_servers host3 host4 @ftp_servers ...
The host (item) lists are really set-expressions
(read '+
' as set-union) :
hosts group-name A B C hosts group-name A + B + C # same thing
Exceptions can be made with operator '–' (read as set-subtraction) :
# all www-servers also serve ftp, except host1, host2 hosts ftp_servers @www_servers – host1 – host2
In general :
::
host ∥ @host-group ∥ alias
::
'(' ⟦ HOST-EXPR ⟧ ')'
::
HOST ⟦ ⟦ '+' ∥ '–' ⟧ HOST ⟧ ...
::
item ∥ @item-group
::
'(' ⟦ ITEM-EXPR ⟧ ')'
::
ITEM ⟦ ⟦ '+' ∥ '–' ⟧ ITEM ⟧ ...
USER- and FIT_LEVEL-groups : same as ITEM.
The default operator is '+
' :
A B C # same as : A + B + C A - B C # same as : A - B + C
host
– define a host and aliases
Syntax : host
hostname ⟦ alias ... ⟧
hostname must be fully qualified (contain at least 1 dot ['.']), and must exist in DNS.
The default alias is the hostname, up to the first dot.
In the work-config, any alias can be used to refer to hostname.
In the report-pages, the first alias is used as a short-name for hostname.
hosts
– define a host-group
syntax : hosts
group_name HOST-EXPR
The members of the group can be refered to as : @
group_name.
item
– define an item
syntax : item
item-name kind probe default-probe-args
item-name must be alphanumeric
kind must be a built-in kind.
probe must be a built-in probe.
items
– define a item-group
syntax : items
group_name ITEM-EXPR
The members of the group can be refered to as : @
group_name.
ival
– set the probe interval for specific items
syntax : ival
interval_spec ITEM-EXPR
An interval_spec is : ❪ ⟦+∥-⟧ NUM ⟦ s ∥ m ∥ h ∥ d ∥ w ⟧ ❫ ...
using seconds, minutes, hours, days, weeks
Example :
# get the ups_temp only every 15 minutes ival 15m ups_temp
# get a certificate's time-to-live only once a day ival 1d ttl_cert_httpd ttl_cert_ldap
For all items, the default probe interval is one minute.
syntax : arg
HOST ITEM arg ...
Recall that each item has a probe and probe-arguments, used to compute the value for an item.
If/when N arguments are supplied,
then arg
replaces the last N default host-item probe-arguments,
with the supplied arguments.
Example :
# on host mysql, for item data_usage # monitor /var/lib/mysql instead of (default) /data arg mysql data_usage /var/lib/mysql
syntax : fit_level
name ⟦ longname ⟧
Example :
fit_level fine fit_level soso fit_level sick fit_level crit critical fit_level dead
The first fitness_level is the default fitness.
fit_levels
– define a fit_level-group
syntax : fit_levels
group_name FIT_LEVEL-EXPR
The members of the group can be refered to as : @
group_name.
Example :
fit_levels GOOD fine soso fit_levels BAD sick crit dead
syntax : fitter
name expression
The expression (in variable X) must yield a fit_level name.
Example :
# defined a fitter 'daemon' fitter daemon X == 1 ? fine : dead # use : fit ssh_daemon, ftp_daemon as 'daemon' fit ssh_daemon daemon fit ftp_daemon daemon
:
item
syntax : fit
⟦ HOST : ⟧ ITEM ❪ expression ∥ fitter ❫
The expression (in variable X) must yield a fit_level name.
Example :
# set the default fit for item 'ups_temp' fit ups_temp X<=35 ? fine : X<=40 ? soso : X<=45 ? crit : dead # override for host ups13 fit ups13:ups_temp X<=45 ? fine : X<=50 ? soso : X<=55 ? crit : dead
syntax : works
smart-host HOST-EXPR
The smart-host monitors the other (dumb) hosts remotely ; for instance a UPS with SNMP.
Example :
# let my-host monitor the ups-en works my-host @upsen
pmaker
– set the pagemaker
syntax : pmaker
host
Note : for server, mk-dmon-work
uses the configured server ;
from (-c
) dmon-config.
syntax : get
HOST ITEM-EXPR
Example :
get @linux_servers @linux_items
user
– define a user
syntax : user
user_name user_mail
user_name must be alphanumeric
user_mail must be an email-address (contain '@
')
Example :
user johann me@bach.org user frank me@zappa.org
users
– define a user-group
syntax : users
group_name USER-EXPR
The members of the group can be refered to as : @
group_name.
alert
– define an alert
syntax : alert
USER <LEVEL_1> <LEVEL_2> ⟦ HOST ⟦ ITEM ⟧ ⟧
Default HOST : empty set ()
; meaning : no restrictions ; all hosts.
Default ITEM : empty set ()
; meaning : no restrictions ; all items.
Users USER are alerted if the fitness (of some host-item) changes from LEVEL_1 to LEVEL_2 (or vice versa).
Example :
users admins tom dick harry fit_levels GOOD fine soso fit_levels BAD sick crit dead
# alert admins when an item goes from GOOD to BAD or from BAD to GOOD alert @admins @GOOD @BAD
# alert admins when an item goes from one BAD state to another BAD state alert @admins @BAD @BAD
You may distribute under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl 5.10.0 README file.