Check for incorrect heartbeats in rrdtstep.php script (#9041)

Also, fix some incorrect config names (rrd_step -> rrd.step)

DO NOT DELETE THIS TEXT

#### Please note

> Please read this information carefully. You can run `./scripts/pre-commit.php` to check your code before submitting.

- [x] Have you followed our [code guidelines?](http://docs.librenms.org/Developing/Code-Guidelines/)

#### Testers

If you would like to test this pull request then please run: `./scripts/github-apply <pr_id>`, i.e `./scripts/github-apply 5926`
This commit is contained in:
Tony Murray
2018-08-21 16:21:55 -05:00
committed by Neil Lathwood
parent 2720ca5f1f
commit d83b675090
4 changed files with 21 additions and 9 deletions

View File

@@ -79,12 +79,24 @@ foreach ($files as $file) {
}
$rrd_info = shell_exec("$rrdtool info $file");
preg_match('/step = (\d+)/', $rrd_info, $matches);
preg_match('/step = (\d+)/', $rrd_info, $step_matches);
if ($matches[1] == $step) {
d_echo("Skipping $file, step is already $step.\n");
$skipped++;
continue;
if ($step_matches[1] == $step) {
preg_match_all('/minimal_heartbeat = (\d+)/', $rrd_info, $heartbeat_matches);
try {
foreach ($heartbeat_matches[1] as $ds_heartbeat) {
if ($ds_heartbeat != $heartbeat) {
throw new Exception("Mismatched heartbeat. {$ds_heartbeat} != $heartbeat");
}
}
// all heartbeats ok
d_echo("Skipping $file, step is already $step.\n");
$skipped++;
continue;
} catch (Exception $e) {
echo $e->getMessage() . PHP_EOL;
}
}
echo "Converting $file: ";