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

@@ -107,7 +107,7 @@ class Poller extends BaseValidation
private function checkDeviceLastPolled(Validator $validator)
{
$overdue = (int)(Config::get('rrd_step', 300) * 1.2);
$overdue = (int)(Config::get('rrd.step', 300) * 1.2);
if (count($devices = dbFetchColumn("SELECT `hostname` FROM `devices` WHERE (`last_polled` < DATE_ADD(NOW(), INTERVAL - $overdue SECOND) OR `last_polled` IS NULL) AND `ignore` = 0 AND `disabled` = 0 AND `status` = 1")) > 0) {
$result = ValidationResult::warn("Some devices have not been polled in the last 5 minutes. You may have performance issues.")
->setList('Devices', $devices);
@@ -126,7 +126,7 @@ class Poller extends BaseValidation
private function checkDevicePollDuration(Validator $validator)
{
$period = (int)Config::get('rrd_step', 300);
$period = (int)Config::get('rrd.step', 300);
if (count($devices = dbFetchColumn("SELECT `hostname` FROM `devices` WHERE last_polled_timetaken > $period AND `ignore` = 0 AND `disabled` = 0 AND `status` = 1")) > 0) {
$result = ValidationResult::fail("Some devices have not completed their polling run in 5 minutes, this will create gaps in data.")
->setList('Devices', $devices);

View File

@@ -81,7 +81,7 @@ class PingCheck implements ShouldQueue
$cmd = ['fping', '-f', '-', '-e', '-t', $timeout, '-r', $retries];
$wait = Config::get('rrd_step', 300) * 2;
$wait = Config::get('rrd.step', 300) * 2;
$this->process = new Process($cmd, null, null, null, $wait);
}

View File

@@ -22,7 +22,7 @@ if (isset($searchPhrase) && !empty($searchPhrase)) {
}
if ($vars['type'] == "unpolled") {
$overdue = (int)(Config::get('rrd_step', 300) * 1.2);
$overdue = (int)(Config::get('rrd.step', 300) * 1.2);
$sql .= " AND `last_polled` <= DATE_ADD(NOW(), INTERVAL - $overdue SECOND)";
}

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 ($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
if ($matches[1] == $step) {
d_echo("Skipping $file, step is already $step.\n");
$skipped++;
continue;
} catch (Exception $e) {
echo $e->getMessage() . PHP_EOL;
}
}
echo "Converting $file: ";