mirror of
				https://github.com/librenms/librenms.git
				synced 2024-10-07 16:52:45 +00:00 
			
		
		
		
	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:
		
				
					committed by
					
						
						Neil Lathwood
					
				
			
			
				
	
			
			
			
						parent
						
							2720ca5f1f
						
					
				
				
					commit
					d83b675090
				
			@@ -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);
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -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)";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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: ";
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user