mirror of
				https://github.com/librenms/librenms.git
				synced 2024-10-07 16:52:45 +00:00 
			
		
		
		
	Simple linear port graph prediction (#10520)
* Simple linear port graph prediction Simple linear prediction line for in and out if graph "to" value is in the future Improve graph date handling * thinner line * Make test specify timezone
This commit is contained in:
		@@ -1526,6 +1526,34 @@ function generate_stacked_graphs($transparency = '88')
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Parse AT time spec, does not handle the entire spec.
 | 
			
		||||
 * @param string $time
 | 
			
		||||
 * @return int
 | 
			
		||||
 */
 | 
			
		||||
function parse_at_time($time)
 | 
			
		||||
{
 | 
			
		||||
    if (is_numeric($time)) {
 | 
			
		||||
        return $time < 0 ? time() + $time : intval($time);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (preg_match('/^[+-]\d+[hdmy]$/', $time)) {
 | 
			
		||||
        $units = [
 | 
			
		||||
            'm' => 60,
 | 
			
		||||
            'h' => 3600,
 | 
			
		||||
            'd' => 86400,
 | 
			
		||||
            'y' => 31557600,
 | 
			
		||||
        ];
 | 
			
		||||
        $value = substr($time, 1, -1);
 | 
			
		||||
        $unit = substr($time, -1);
 | 
			
		||||
 | 
			
		||||
        $offset = ($time[0] == '-' ? -1 : 1) * $units[$unit] * $value;
 | 
			
		||||
        return time() + $offset;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return (int)strtotime($time);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Get the ZFS pools for a device... just requires the device ID
 | 
			
		||||
 * an empty return means ZFS is not in use or there are currently no pools
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user