diff options
author | ramon <ramongomez@us.es> | 2016-11-11 13:42:22 +0000 |
---|---|---|
committer | ramon <ramongomez@us.es> | 2016-11-11 13:42:22 +0000 |
commit | 23a72c068eb9c9344a7f058096f1af8c1b9faad9 (patch) | |
tree | 453bd9ddff70e0c9a31b6d5dfb81420610e88a53 /admin/WebConsole/rest/server.php | |
parent | 26c54b632487395b7f89daf0a71dcee5d8e135aa (diff) |
#761: Integrar rutas {{{/status}}} y {{{/ous/:ouid/groups}}} en version 1.1 y documentar ruta {{{/status}}}.
git-svn-id: https://opengnsys.es/svn/branches/version1.1@5088 a21b9725-9963-47de-94b9-378ad31fedc9
Diffstat (limited to 'admin/WebConsole/rest/server.php')
-rw-r--r-- | admin/WebConsole/rest/server.php | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/admin/WebConsole/rest/server.php b/admin/WebConsole/rest/server.php index ab10bb06..7d0f03be 100644 --- a/admin/WebConsole/rest/server.php +++ b/admin/WebConsole/rest/server.php @@ -215,6 +215,23 @@ $app->post('/login', ); /** + * @brief Get the server status + * @note Route: /status, Method: GET + * @param no + * @return JSON array with all data collected from server status. (RAM, %CPU,etc..) + */ +$app->get('/status', function() { + exec("awk '$1~/Mem/ {print $2}' /proc/meminfo",$memInfo); + $memInfo = array("total" => $memInfo[0], "used" => $memInfo[1]); + $cpuInfo = exec("awk '$1==\"cpu\" {printf \"%.2f\",($2+$4)*100/($2+$4+$5)}' /proc/stat"); + $cpuModel = exec("awk -F: '$1~/model name/ {print $2}' /proc/cpuinfo"); + $response["memInfo"] = $memInfo; + $response["cpu"] = array("model" => trim($cpuModel), "usage" => $cpuInfo); + jsonResponse(200, $response); +} +); + +/** * @brief List all defined Organizational Units * @note Route: /ous, Method: GET * @param no @@ -267,6 +284,42 @@ $app->get('/ous/:ouid', 'validateApiKey', } ); +// Listar grupos. +$app->get('/ous/:ouid/groups', 'validateApiKey', function($ouid) { + global $cmd; + global $userid; + + $ouid = htmlspecialchars($ouid); + if(checkAdmin($userid, $ouid) == true){ + // Listar las salas de la UO si el usuario de la apikey es su admin. + // Consulta temporal, + $cmd->texto = "SELECT * FROM grupos WHERE idcentro='$ouid';"; + $rs=new Recordset; + $rs->Comando=&$cmd; + if (!$rs->Abrir()) return(false); // Error al abrir recordset + $rs->Primero(); + // Comprobar que exista la UO. + if (checkParameter($rs->campos["idcentro"])) { + $response = array(); + while (!$rs->EOF) { + $tmp = array(); + $tmp['id'] = $rs->campos["idgrupo"]; + $tmp['name'] = $rs->campos["nombregrupo"]; + $tmp['type'] = $rs->campos["tipo"]; + $tmp['comments'] = $rs->campos["comentarios"]; + if($rs->campos["grupoid"] != 0){ + $tmp['parent']['id'] = $rs->campos["grupoid"]; + } + array_push($response, $tmp); + $rs->Siguiente(); + } + jsonResponse(200, $response); + } + $rs->Cerrar(); + } + } +); + /** * @brief List all labs defined in an OU * @note Route: /ous/id/labs, Method: GET |