snmpacc: SNMP accounting data collection package

<< Previous Contents Next >>

6.2. Configuration Files

6.2.1. Configuration File Format

This section describes the format of the configuration files used by the collector and merge programs.
6.2.1.1. Syntax
Most configuration of snmpacc is done through its configuration file, by default snmpacc.cf (or snmpmerge.cf for the merge program) in the current directory.

The configuration file consists of a series of statements, with each statement keyword followed by parameters separated by whitespace, and the statement terminated by either the end of the line or a '#' comment marker. Comments continue from the '#' to the end of the line.

Blank lines are permitted.

Parameters containing spaces may be quoted with double quotes. A parameter starting with '$' is translated through a symbol name. Note that only parameters starting with '$' will be recognised and the entire parameter replaced; to embed a symbol value in a parameter, use a set statement to construct a symbol first.

6.2.1.2. Symbols
Predefined symbols are as follows:

$file  Current configuration file name
$masterfile  Configuration file name as specified on command line (or default)
$collector  Host name as specified in -h option, default system host name

Symbols can be created using the set statement. This takes the form:

Note that each data element is appended together, thus set x a b c assigns ``abc'' to the symbol x.

6.2.1.3. Include Files
Files may be included by the use of a '@' sign, with @! indicating that the include is a shell command rather than a file.

Each non-blank line read from an include file is appended to the line preceding the '@'. For example, if the configuration file contains:

and the file ns1-objects contains

what is processed is:

6.2.1.4. Lexical Control: if / elseif / else / end if
The configuration file can be parsed conditionally via the if / elseif / else / end if constructions.

The if statement is in the form if <cond>, with <cond> defined as <parameter> <relop> <parameter> [<logop> <cond> ...]. <relop> can be one of:

Equal to
!=  Not equal to
Less than
Greater than
<=  Less than or equal to
>=  Greater than or equal to

Note that all comparisons are strings, thus ``9'' is greater than ``10''; the comparison should be between ``09'' and ``10''.

<logop> can be one of and or or.

6.2.1.5. Interval Specifications
Some parameters are specified as intervals. These parameters can be specified as integer numbers of seconds, or by using 'm', 'h', 'd' or 'w' as multipliers for minutes, hours, days or weeks respectively. Several multipliers can be used, e.g. 1h30m specifies one hour and thirty minutes.

snmpmerge extends this model further for the -e (end time) option and aggregate intervals, in that when the interval is an exact multiple of a day, the interval is treated as days aligned at midnight local time rather than seconds, as seconds truncated to a multiple of 24 hours would result in days aligned at midnight GMT, not midnight local time. Note that this means that when daylight saving starts and ends, a "day" can be 23 or 25 hours (assuming a one hour daylight saving offset). The days number calculation is arranged so that if 7 days is requested, the week starts oat midnight Monday morning.

Additionally, if a multiple of 30 days is requested, it is treated as actual calendar months, not intervals of 30 days. That is, an interval of 90 days would indicate periods starting on 1 January, 1 April, 1 July and 1 October.

6.2.1.6. Quantity Specifications
Values requiring large quantities may take a single 'k', 'm' or 'g' suffix to multiply by 1,000, 1,000,000 or 1,000,000,000 respectively. This may be used with a decimal point or trailing digits to specify a partial quantity, e.g. 9,600 may be specified as 9600, 9k6 or 9.6k.

6.2.1.7. Time-based file names
Output file names (including data files, log files etc) may be specified containing time component substitution strings corresponding with those provided by the Unix strftime() library call. The time applied, for data files, is the start time of the sample being written, while for log files, the time the file is opened is used.

For example, to output files in the form out-YYYYMMDD-HHMM.dat, one could use out-%Y%m%d-%H%M.dat.

Common time substitution strings include:

%d  Day of month, zero filled, e.g. 01, 31
%H  Hour of day, zero-filled, e.g. 01, 23.
%m  Month of year, zero filled, e.g. 01, 12.
%M  Minute of hour, zero-filled, e.g. 00, 59.
%y  Two digit, zero-filled year, e.g. 00, 01, 99.
%Y  Four digit year, e.g. 1999, 2000.
%%  Insert a percent sign.

For more information, see the Unix manual pages for strftime(3).
<< Previous Contents Next >>