diff --git a/assets/html/indexpage.twig b/assets/html/indexpage.twig
index 89b370d..6759042 100755
--- a/assets/html/indexpage.twig
+++ b/assets/html/indexpage.twig
@@ -12,7 +12,7 @@
| {{T_.name}} |
- {{T_.status}} |
+ {{T_.status_uptime}} |
{{T_.last_check}} |
{{T_.last_err}} |
@@ -47,7 +47,7 @@
{{T_.status_empty}}
{%endif%}
{#END IF/SWITCH#}
-
+ ({{ check.uptime}}%)
{% if check.status is defined %}{#Only if records exists#}
diff --git a/assets/translations/en.php b/assets/translations/en.php
index 1250a2d..364b803 100755
--- a/assets/translations/en.php
+++ b/assets/translations/en.php
@@ -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';
diff --git a/assets/translations/es.php b/assets/translations/es.php
index 18b4fb4..8190912 100755
--- a/assets/translations/es.php
+++ b/assets/translations/es.php
@@ -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';
diff --git a/functions.php b/functions.php
index 914ee5b..59dcba7 100755
--- a/functions.php
+++ b/functions.php
@@ -28,7 +28,11 @@ function checkStatus($db_conn,$ID_C){
}
function checkUptime($db_conn,$ID_C,$precision = 0){
- $time = $precision;
+ 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;
diff --git a/index.php b/index.php
index b04dc4b..a258884 100755
--- a/index.php
+++ b/index.php
@@ -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;
|