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:
Tony Murray
2019-08-19 22:53:48 -05:00
committed by GitHub
parent d3243bd32e
commit 8d669a8a39
6 changed files with 67 additions and 20 deletions

View File

@@ -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