diff options
author | ramon <ramongomez@us.es> | 2016-09-28 17:13:52 +0000 |
---|---|---|
committer | ramon <ramongomez@us.es> | 2016-09-28 17:13:52 +0000 |
commit | 353c112529fec25f127b4977e1a74e98eabc6995 (patch) | |
tree | 50930d7878af010d235b278d225b1afba06bcbdd /admin/WebConsole/rest/server.php | |
parent | df81ab780967b8d36a879f55158b746494be92f4 (diff) |
#708: Soportar obtener estado de un cliente iniciado en sistema operativo llamando a la API REST de su OGAgent.
git-svn-id: https://opengnsys.es/svn/branches/version1.1@5019 a21b9725-9963-47de-94b9-378ad31fedc9
Diffstat (limited to 'admin/WebConsole/rest/server.php')
-rw-r--r-- | admin/WebConsole/rest/server.php | 25 |
1 files changed, 19 insertions, 6 deletions
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", |