#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-378ad31fedc9remotes/github/debian-pkg
parent
df81ab7809
commit
353c112529
|
@ -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();
|
||||
|
|
|
@ -455,6 +455,7 @@ font-style: italic;
|
|||
<div class="example-data-content-type">Content-Type: application/json</div>
|
||||
<pre class="example"><code>{
|
||||
"ip" : "aeiou",
|
||||
"loggedin" : true,
|
||||
"id" : 123,
|
||||
"status" : "aeiou"
|
||||
}</code></pre>
|
||||
|
@ -1630,6 +1631,7 @@ font-style: italic;
|
|||
<div class="example-data-content-type">Content-Type: application/json</div>
|
||||
<pre class="example"><code>{
|
||||
"ip" : "aeiou",
|
||||
"loggedin" : true,
|
||||
"id" : 123,
|
||||
"status" : "aeiou"
|
||||
}</code></pre>
|
||||
|
@ -2056,6 +2058,7 @@ font-style: italic;
|
|||
<div class="param">status (optional)</div><div class="param-desc"><span class="param-type"><a href="#string">String</a></span> execution status </div>
|
||||
<div class="param-enum-header">Enum:</div>
|
||||
<div class="param-enum">nodata</div><div class="param-enum">off</div><div class="param-enum">ogclient</div><div class="param-enum">busy</div><div class="param-enum">linux</div><div class="param-enum">windows</div><div class="param-enum">unknown</div>
|
||||
<div class="param">loggedin (optional)</div><div class="param-desc"><span class="param-type"><a href="#boolean">Boolean</a></span> flag to check if an user is logged in </div>
|
||||
</div> <!-- field-items -->
|
||||
</div>
|
||||
<div class="model">
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in New Issue