1
0
mirror of https://gitlab.com/JKANetwork/CheckServer.git synced 2026-02-21 12:33:47 +01:00

Version 0.9.2

This commit is contained in:
2018-01-09 22:36:45 +01:00
parent f1b58a03f3
commit cb20328a6a
7 changed files with 64 additions and 31 deletions

View File

@@ -3,7 +3,7 @@
require_once "connect.php";
require_once 'lib/loadTwig.php';
function checkUptime($db_conn,$ID_C,$precision = 0){
function getUptime($db_conn,$ID_C,$precision = 0){
if ($precision == 0){
$time = time()-30*7*3600; //Last week
}else{
@@ -26,7 +26,32 @@ function checkUptime($db_conn,$ID_C,$precision = 0){
return 100;
}
}
}
function getStatus($db_conn,$T_,$ID_C){
$resql = dbw_query($db_conn,"SELECT code FROM CHKHIST WHERE ID_C='$ID_C' ORDER BY `timestamp` DESC LIMIT 5");
$err = 0;
while ($x = dbw_fetch_array($db_conn,$resql)){
if ($x['code'] != 0){
$err++;
}
}
switch ($err){
case 0:
case 1:
return array($T_['status_right'],'green');
break;
case 2:
return array($T_['status_lproblems'],'blue');
break;
case 3:
case 4:
return array($T_['status_problems'],'orange');
break;
default: // > 4
return array($T_['status_outofserv'],'red');
break;
}
}