feature: Allow customisation of rrd step/heartbeat when creating new rrd files (#5947)

* feature: Allow customisation of rrd step/heartbeat when creating new rrd files

* revert defaults

* added docs + webui config option

* Move RrdDefinition to an Object to make them easier to create and remove the possibility of typos.

* Fix style/lint issues and missing use statements

* 3 more missing use statements

* updated doc + moved schema file
This commit is contained in:
Neil Lathwood
2017-02-23 22:45:50 +00:00
committed by GitHub
parent 0997172b37
commit fad5aca1b7
110 changed files with 1475 additions and 1119 deletions

View File

@@ -371,7 +371,7 @@ function rrdtool_tune($type, $filename, $max)
* rrdtool backend implementation of data_update
*
* Tags:
* rrd_def array|string: (required) an array of rrd field definitions example: "DS:dataName:COUNTER:600:U:100000000000"
* rrd_def RrdDefinition
* rrd_name array|string: the rrd filename, will be processed with rrd_name()
* rrd_oldname array|string: old rrd filename to rename, will be processed with rrd_name()
* rrd_step int: rrd step, defaults to 300
@@ -386,7 +386,7 @@ function rrdtool_data_update($device, $measurement, $tags, $fields)
global $config;
$rrd_name = $tags['rrd_name'] ?: $measurement;
$step = $tags['rrd_step'] ?: 300;
$step = $tags['rrd_step'] ?: $config['rrd']['step'];
$oldname = $tags['rrd_oldname'];
if (!empty($oldname)) {
rrd_file_rename($device, $oldname, $rrd_name);
@@ -399,10 +399,8 @@ function rrdtool_data_update($device, $measurement, $tags, $fields)
$rrd = rrd_name($device['hostname'], $rrd_name);
}
if ($tags['rrd_def'] && !rrdtool_check_rrd_exists($rrd)) {
$rrd_def = is_array($tags['rrd_def']) ? $tags['rrd_def'] : array($tags['rrd_def']);
// add the --step and the rra definitions to the command
$newdef = "--step $step " . implode(' ', $rrd_def) . $config['rrd_rra'];
if (isset($tags['rrd_def']) && !rrdtool_check_rrd_exists($rrd)) {
$newdef = "--step $step " . $tags['rrd_def'] . $config['rrd_rra'];
rrdtool('create', $rrd, $newdef);
}