The Aware deamon, awared, is configured by reading a file called a "wire" file. This file describes the handlers and other objects as well as how they are interconnected.
The wire file format is a declarative format, supporting variable binding, and file inclusion. It is not a scripting language. The intention is to keep the implementation light. Adding many script-like features would make the implementation become heavy, at which point you might as well link Aware directly to Perl or Python (which would be easy to do should someone have the energy to create such bindings, hint). However, you might find it useful to use a scripting language to generate a complex wire file driven by many parameters.
Handlers can run on a timed cycle and generate events. For example, you might create a handler to ping a machine on your network every 60 seconds. Handlers may also register to receive events and do something with them. For example, you might generate an alert if the ping handler did not receive a response.
In the wire file you name an event by creating an event object:
Each handler has particular keywords associated with it's function but all handlers have the cycletime: keyword (cron: can also be used) which specifies how often to run:
Handlers may register to receive events and perform some action. Optionally, handlers may generate events of their own:
| create handler execp { cmd: "mail -s \"alert: $n\" sysadmin" input: "Alert:\n\t\$n:\$v at \$t\n\n" regevent: $pingfailed } |
|
/* C style comments are supported */ // and C++ style |
Strings specified in a wire file are defined as a consecutive set of non-white space characters, as the wire format is white space delimited. For example:
| set hostname www.google.com |
| set emailbody 'Alert: /etc/passwd has changed!' |
| print "Creating handler for host $hostname\n" |
You may include other wire files in a manner similar to the C pre-processor. To include another wire file use the include directive:
| include "myhandlers.wire" |
| includeifexists "customizations.wire" |
Strings, numbers and objects may be bound to variables using the set command. A '$' is used to dereference the variable. Curly braces may be used to join 2 non white space seperated strings:
| set filename "${device}.${interface}.rrd" |
The following variables are predefined:
The print will print the string or varable to the console. You may specify multiple arguments:
| print "Created event" $event "\n" |
The set command will bind a string, number or object to a variable:
| set the handler cycletime set cycletime 30 set the url set url 'http://exchange.mydomain.net' |
The list command will bind a set of variables to another variable:
| list failevents $pingfail $httpfail $wwwfail |
The create command is used to create an object.
Events are used to connect handlers. Event creation takes 3 arguments:
| set freememory create event { name: "freemem" priority: 1 } |
Loggers output error/warning messages. By default a logger will output messages to the console (stderr) and prepend the date. Logger creation takes 6 arguments (all optional):
| set alertlogger create logger { filename: /usr/log/alert.log rotate: day } |
The list of all handlers can be found here. Each handler has its own specific set of arguments but all handlers have these 9 (note cycletime:,and cron: are mutally exclusive):
| field | allowed values |
|---|---|
| minute | 0-59 |
| hour | 0-23 |
| day of month | 1-31 |
| month | 1-12 |
| day of week | 0-6 |
A field may be an asterisk (*), which always stands for ``first-last''.
Ranges of numbers are allowed. Ranges are two numbers separated with a hyphen. The specified range is inclusive. For example, 8-11 for an ``hours'' entry specifies execution at hours 8, 9, 10 and 11.
Lists are allowed. A list is a set of numbers (or ranges) separated by commas. Examples: ``1,2,5,9'', ``0-4,8-12''.