1
0
mirror of https://gitlab.com/JKANetwork/CheckServer.git synced 2026-02-14 17:21:35 +01:00

View uptime in index page

This commit is contained in:
Kevin Puertas
2017-11-04 18:58:17 +01:00
parent 3574ecf257
commit 1be1751a3d
5 changed files with 11 additions and 4 deletions

View File

@@ -12,7 +12,7 @@
<tr>
<!--<th>#</th>-->
<th>{{T_.name}}</th>
<th>{{T_.status}}</th>
<th>{{T_.status_uptime}}</th>
<th>{{T_.last_check}}</th>
<th>{{T_.last_err}}</th>
</tr>
@@ -47,7 +47,7 @@
<span class='grey' data-tooltip='Type of check: {{check.nameCheck}}' data-tooltip-position='top'>{{T_.status_empty}}</span>
{%endif%}
{#END IF/SWITCH#}
({{ check.uptime}}%)
</td>
{% if check.status is defined %}{#Only if records exists#}
<td>

View File

@@ -6,6 +6,7 @@ define('T_ENGVERSION',1);
$T_['statdif1'] = 'Status of different checks';
$T_['name'] = 'Name';
$T_['status'] = 'Status';
$T_['status_uptime'] = 'Status (Uptime)';
$T_['failed'] = 'Failed';
$T_['last_check'] = 'Last check';
$T_['last_err'] = 'Last error';

View File

@@ -6,6 +6,7 @@ define('T_VERSION',1);
$T_['statdif1'] = 'Estado de los diferentes servicios';
$T_['name'] = 'Nombre';
$T_['status'] = 'Estado';
$T_['status_uptime'] = 'Estado (Uptime)';
$T_['failed'] = 'Erróneo';
$T_['last_check'] = 'Última comprobación';
$T_['last_err'] = 'Último error';

View File

@@ -28,7 +28,11 @@ function checkStatus($db_conn,$ID_C){
}
function checkUptime($db_conn,$ID_C,$precision = 0){
if ($precision == 0){
$time = time()-30*24*3600; //Last month
}else{
$time = $precision;
}
if ($precision != 0){
$good = dbw_query_fetch_array($db_conn,"SELECT COUNT(*) FROM CHKHIST WHERE ID_C = '$ID_C' AND code == 0 AND `timestamp` > $time")[0];
$all = dbw_query_fetch_array($db_conn,"SELECT COUNT(*) FROM CHKHIST WHERE ID_C = '$ID_C' AND `timestamp` > $time")[0];
@@ -37,7 +41,7 @@ function checkUptime($db_conn,$ID_C,$precision = 0){
$all = dbw_query_fetch_array($db_conn,"SELECT COUNT(*) FROM CHKHIST WHERE ID_C = '$ID_C'")[0];
}
if ($all != 0){
$uptime = ($good/$all)*100;
$uptime = round(($good/$all)*100,2);
return $uptime;
}else{
return 100;

View File

@@ -34,6 +34,7 @@ while ($onechk = dbw_fetch_array($db_conn,$results)){
$ID_TC = $chks[$idchk]['ID_TC'];
$chks[$idchk]['nameCheck'] = textTypeChk($T_,$ID_TC);
$chks[$idchk]['uptime'] = checkUptime($db_conn,$ID_C);
}
break;