DBARCHIVER

dbarchiver — Database consumer client

Synopsis

dbarchiver [[-V] | [--version]] {[-c file] | [--config file]} [[-h] | [--help]]

DESCRIPTION

dbarchiver is a consumer client that writes the collected data to a relational database as specified in the config file.

The configuration file has the syntax described in the Reference Manual under Monitoring System Configuration. The following main sections are recognized:

Database section.  The Database section defines the database connection parameters. The following variables can be set:

Driver (string)

The database backend driver to use. Currently only PostgreSQL is supported.

Host (string)

The host name where the database server is located.

Name (string)

The name of the database to connect to.

User (string)

The user to connect as.

Password (string)

The password to use for connecting to the database.

Producer section.  A Producer section defines a producer to connect to. The section's title should be the producer's URL. A Producer section may contain the ReconnectDelay (int32) variable which specifies the delay before reconnecting is attempted to this producer and one or more Metric subsections defining the metrics to monitor. The title of a Metric section should be the name of the metric. Metric sections may contain the following items:

Param subsections

The title of a Param subsection should be the name of a metric parameter. The only allowed variable inside a Param subsection is Value, which defines the value of the metric parameter.

Query (string)

The Query variable defines the database query (normally an INSERT SQL statement) to perform when a metric value of the defined metric arrives. It is a string with possible substitution macros. These macros have the format of %{expr} where expr is a valid expression for the data type of the defined metric or one of the following special values:

timestamp

The metric value's timestamp in ISO format

unixtime

The metric value's timestamp in UNIX time format

Restart (boolean)

The Restart variable specifies if the metric should be restarted after failure.

RestartDelay (int32)

The RestartDelay variable specifies the delay before a failed metric is restarted.

Frequency (int32)

If a value is specified for the Frequency variable a GET command is sent with the given frequency. To request automatic periodic measurements specify the frequency metric parameter instead.

Defaults section.  A Defaults section may specify default values for the Restart, RestartDelay and ReconnectDelay variables.

OPTIONS

[-V] | [--verbose]

Print the version number and exit.

[-c file] | [--config file]

Use the specified config file. This option is mandatory.

[-h] | [--help]

Print a short help message on parameters and usage.

EXAMPLES

Example 4. Sample dbarchiver configuration

Database {
	Driver "PostgreSQL";
	Host "localhost";
	Name "dbname";
	User "dbuser";
	Password "dbpass";
}

Defaults {
	Restart yes;
}

Producer["monp://localhost"] {
	Metric["host.loadavg"] {
		Param["host"]::Value "yourhost.yourdomain.org";
		Query "INSERT INTO loadavg (ts, l1, l5, l15) VALUES (%{unixtime}, %{val[0]}, %{val[1]}, %{val[2]})";
		Frequency 3;
		RestartDelay 2;
	}

	Metric["host.mem.avail"] {
		Param["host"]::Value "yourhost.yourdomain.org";
		Param["frequency"]::Value 5.0;
		Query "INSERT INTO memavail (ts, value) VALUES (%{unixtime}, %{val})";
		Restart no;
	}

	Metric["host.cpu.user"] {
		Param["host"]::Value "yourhost.yourdomain.org";
		Param["frequency"]::Value 5.0;
		Param["cpu"]::Value 0;
		Query "INSERT INTO usercpu (ts, value) VALUES (%{unixtime}, %{val})";
	}
}