diff --git a/admin/WebConsole/rest/index.php b/admin/WebConsole/rest/index.php
index 6c13d3de..d796a043 100644
--- a/admin/WebConsole/rest/index.php
+++ b/admin/WebConsole/rest/index.php
@@ -20,7 +20,8 @@ include_once("../includes/CreaComando.php");
@include_once("../includes/constantes.php");
include_once("../includes/comunes.php");
include_once("../clases/SockHidra.php");
-
+// REST functions.
+@include_once("../includes/restfunctions.php");
// Slim framework.
include_once("Slim/Slim.php");
\Slim\Slim::registerAutoloader();
diff --git a/admin/WebConsole/rest/opengnsys-api.html b/admin/WebConsole/rest/opengnsys-api.html
index 7f2085f0..b1560052 100644
--- a/admin/WebConsole/rest/opengnsys-api.html
+++ b/admin/WebConsole/rest/opengnsys-api.html
@@ -455,6 +455,7 @@ font-style: italic;
Content-Type: application/json
{
"ip" : "aeiou",
+ "loggedin" : true,
"id" : 123,
"status" : "aeiou"
}
@@ -1630,6 +1631,7 @@ font-style: italic;
Content-Type: application/json
{
"ip" : "aeiou",
+ "loggedin" : true,
"id" : 123,
"status" : "aeiou"
}
@@ -2056,6 +2058,7 @@ font-style: italic;
status (optional)
nodata
off
ogclient
busy
linux
windows
unknown
+loggedin (optional)
Boolean flag to check if an user is logged in
diff --git a/admin/WebConsole/rest/opengnsys-api.yml b/admin/WebConsole/rest/opengnsys-api.yml
index 16173122..60a3fbd2 100644
--- a/admin/WebConsole/rest/opengnsys-api.yml
+++ b/admin/WebConsole/rest/opengnsys-api.yml
@@ -542,9 +542,9 @@ paths:
description: execution status
type: string
enum: [ "nodata", "off", "ogclient", "busy", "linux", "windows", "unknown" ]
-# usersession:
-# description: flag to check if an user has session oppened
-# type: boolean
+ loggedin:
+ description: flag to check if an user is logged in
+ type: boolean
tags:
- server
- client
diff --git a/admin/WebConsole/rest/server.php b/admin/WebConsole/rest/server.php
index c3789a4f..633eb169 100644
--- a/admin/WebConsole/rest/server.php
+++ b/admin/WebConsole/rest/server.php
@@ -587,10 +587,7 @@ EOD;
if (!$rs->Abrir()) return(false); // Error al abrir recordset
$rs->Primero();
if (checkParameter($rs->campos["idordenador"])) {
- //
- // Probar primero el estado de OGAgent y luego de ogAdmClient
- //
-
+ // First, try to connect to ogAdmCleint service.
$serverip = $rs->campos["ipserveradm"];
$serverport = $rs->campos["portserveradm"];
$clientid = $rs->campos["idordenador"];
@@ -628,8 +625,24 @@ EOD;
$stat = array();
preg_match('/\/[A-Z]*;/', $values["tso"], $stat);
// Check if data exists.
- if (empty($stat[0])) {
- $response['status'] = "nodata";
+ if (empty($stat[0]) or preg_match('/OFF/',$stat[0])) {
+ // If no data, check OGAgent API connection.
+ $url = "https://$clientip:8000/opengnsys/status";
+ $result = multiRequest(Array($url), array(CURLOPT_SSL_VERIFYHOST => false, CURLOPT_SSL_VERIFYPEER => false));
+ if (empty($result[0])) {
+ // Client is off.
+ $response['status'] = "off";
+ } else {
+ // Get status data.
+ $data = json_decode($result[0]);
+ if (isset($data->status)) {
+ $response['status'] = $data->status;
+ $response['loggedin'] = $data->loggedin;
+ } else {
+ // Unknown status.
+ $response['status'] = "unknown";
+ }
+ }
} else {
// Status mapping.
$status = array('OFF'=>"off",