Device Availability Calculation (#11784)

* Device Availability Calculation

* Travis fix

* .

* schema corrections

* flexible duration

* travis

* .

* .

* .

* .

* remove not needed code

* line Text to RRD

* update humantime

* .

* only set up again if device was marked as down

* set RRD area transparency

* save uptime also, to keep last availability as good as possible

* file description correction

* look for outages even if uptime > duration
This commit is contained in:
SourceDoctor
2020-06-22 22:57:30 +02:00
committed by GitHub
parent 7264ab7ff7
commit 4e6a7291a2
14 changed files with 490 additions and 17 deletions

View File

@@ -83,4 +83,54 @@ class Time
return $result;
}
/*
* @param integer seconds of a time period
* @return string human readably time period
*/
public static function humanTime($s)
{
$ret = [];
if ($s >= 86400) {
$d = floor($s / 86400);
$s -= $d * 86400;
if ($d == 1) {
$ret[] = $d . " day";
} else {
$ret[] = $d . " days";
}
}
if ($s >= 3600) {
$h = floor($s / 3600);
$s -= $h * 3600;
if ($h == 1) {
$ret[] = $h . " hour";
} else {
$ret[] = $h . " hours";
}
}
if ($s >= 60) {
$m = floor($s / 60);
$s -= $m * 60;
if ($m == 1) {
$ret[] = $m . " minute";
} else {
$ret[] = $m . " minutes";
}
}
if ($s > 0) {
if ($s == 1) {
$ret[] = $s . " second";
} else {
$ret[] = $s . " seconds";
}
}
return implode(' ,', $ret);
}
}