source: admin/WebConsole/principal/sondeo.php @ dd890f1

918-git-images-111dconfigfileconfigure-oglivegit-imageslgromero-new-oglivemainmaint-cronmount-efivarfsmultivmmultivm-ogboot-installerogClonningEngineogboot-installer-jenkinsoglive-ipv6test-python-scriptsticket-301ticket-50ticket-50-oldticket-577ticket-585ticket-611ticket-612ticket-693ticket-700ubu24tplunification2use-local-agent-oglivevarios-instalacion
Last change on this file since dd890f1 was 560455a, checked in by OpenGnSys Support Team <soporte-og@…>, 6 years ago

#915 adapt web console to use new REST API in OgAdmServer?

Use new REST API in ogAdmServer.

This allows us to start removing the old SockHidra? code.

  • Property mode set to 100644
File size: 3.4 KB
Line 
1<?php
2// *************************************************************************************************************************************************
3// Aplicación WEB: ogAdmWebCon
4// Autor: José Manuel Alonso (E.T.S.I.I.) Universidad de Sevilla
5// Fecha Creación: Año 2009-2010
6// Fecha Última modificación: Agosto-2010
7// Nombre del fichero: sondeo.php
8// Descripción :
9//              Consulta el estado de los ordenadores
10// Version 1.1: De la salida del sondeo del agente antiguo se eliminan los que han respondido con el agente nuevo
11// Autor: Irina Gomez - ETSII Universidad Sevilla
12// Fecha: 2017/11/03
13// *************************************************************************************************************************************************
14        include_once("../includes/ctrlacc.php");
15        include_once("../includes/restfunctions.php");
16        include_once("../clases/SockHidra.php");
17        include_once("../clases/AdoPhp.php");
18        include_once("../includes/constantes.php");
19        include_once("../includes/comunes.php");
20        include_once("../includes/CreaComando.php");
21        include_once("../includes/RecopilaIpesMacs.php");
22        //________________________________________________________________________________________________________
23        $ambito=0;
24        $idambito=0;
25        $sw=0;  // Swich para conmutar entre sondeo a clientes o sólo consulta a la tabla de sockets
26
27        if (isset($_POST["ambito"])) $ambito=$_POST["ambito"];
28        if (isset($_POST["idambito"])) $idambito=$_POST["idambito"];
29        if (isset($_POST["sw"])) $sw=$_POST["sw"];
30        //________________________________________________________________________________________________________
31        $cmd=CreaComando($cadenaconexion);
32        if (!$cmd)
33                Header('Location: '.$pagerror.'?herror=2'); // Error de conexión con servidor B.D.
34        //________________________________________________________________________________________________________
35        $funcion="Sondeo"; // Nombre de la función que procesa la petición
36        if($sw==2)
37                $funcion="respuestaSondeo"; // Nombre de la función que procesa la petición
38        $atributos="";
39        $aplicacion=""; // Ámbito de aplicación (cadena de ipes separadas por ";" y de identificadores de ordenadores por ","
40        $acciones=""; // Cadena de identificadores de acciones separadas por ";" para seguimiento
41        //________________________________________________________________________________________________________
42        // Ámbito de aplicación de la petición
43        //________________________________________________________________________________________________________
44        $cadenaid="";
45        $cadenaip="";
46        $cadenamac="";
47        RecopilaIpesMacs($cmd,$ambito,$idambito); // Ámbito de aplicación
48
49        $ips = explode (';', $cadenaip);
50
51        $trama_notificacion = clients($sw, $ips);
52
53        // Send REST requests to new OGAgent clients.
54        $urls = array();
55        // Compose array of REST URLs.
56        foreach ($ips as $ip) {
57                $urls[$ip] = "https://$ip:8000/opengnsys/status";
58        }
59        // Launch concurrent requests.
60        $responses = multiRequest($urls);
61        // Process responses array (IP as array index).
62        foreach ($responses as $ip => $resp) {
63                if (isset($resp['data'])) {
64                        $data = json_decode($resp['data']);
65                        // If user session is oppened, then append "S" to client status.
66                        if (isset($data->status) and isset($data->loggedin)) {
67                                // Output format: IP1/Status1;...
68                                echo "$ip/".$data->status.($data->loggedin?"S;":";");
69                                // eliminamos los equipos repetidos en el agente antiguo y nuevo.
70                                $trama_notificacion=preg_replace("/$ip\/\w{3}/",'',$trama_notificacion);
71
72                        }
73                }
74        }
75        echo $trama_notificacion;
76
77
Note: See TracBrowser for help on using the repository browser.