Diferencia entre revisiones de «Servidor de gráficas»
De Guifi.net - Wiki Hispano
(→Como trabaja el cliente SNPServices) |
|||
| Línea 23: | Línea 23: | ||
= Como trabaja el cliente SNPServices = | = Como trabaja el cliente SNPServices = | ||
| + | El cliente SNPServices tiene varios passos a realizar para poder recopilar datos y hacer un escaneo en las direcciones cercanas. | ||
| + | <?php | ||
| + | |||
| + | $rootZone = 52771; | ||
| + | #3671; | ||
| + | |||
| + | $minX = 999; | ||
| + | $minY = 999; | ||
| + | $maxX = -999; | ||
| + | $maxY = -999; | ||
| + | |||
| + | $members = array(); | ||
| + | |||
| + | $hlastnow = @fopen("http://guifi.net/guifi/refresh/maps", "r") or die('Error reading changes\n'); | ||
| + | $last_now = fgets($hlastnow); | ||
| + | fclose($hlastnow); | ||
| + | $hlast= @fopen("/tmp/last_update.cnml", "r"); | ||
| + | if (($hlast) and ($last_now == fgets($hlast))) { | ||
| + | fclose($hlast); | ||
| + | echo "No changes.\n"; | ||
| + | exit(); | ||
| + | } | ||
| + | |||
| + | echo "Getting CNML file\n"; | ||
| + | $hcnml = @fopen("http://guifi.net/guifi/cnml/".$rootZone."/detail", "r"); | ||
| + | $wcnml = @fopen("guifi.cnml", "w+"); | ||
| + | while (!feof($hcnml)) { | ||
| + | $buffer = fgets($hcnml, 4096); | ||
| + | fwrite($wcnml,$buffer); | ||
| + | } | ||
| + | fclose($hcnml); | ||
| + | fclose($wcnml); | ||
| + | |||
| + | $hlast= @fopen("/tmp/last_update.cnml", "w+") or die('Error!'); | ||
| + | fwrite($hlast,$last_now); | ||
| + | fclose($hlast); | ||
| + | ?> | ||
= PMF = | = PMF = | ||
Revisión de 10:59 29 oct 2012
Definicion
El servidor de gráficas se baas en el servicio de GUIFI llamado SNPServices. El servidor SNPServices, y para ser mas exactos cliente SNPServices es un servidor linux, con php, apache, mrtg y rrdtool, no necesita nada mas. Le llamamos cliente porque el servidor Master SNPServices es un servidor que nos enviará informacion a nuestro servidor cliente SNPServices. Aqui tienes un esquema que te hará ver claro esta definicion.
El cliente SNPServices consulta al Master snpservices la lista de nodos a monitorear, con php se parsea la lista y formatea scripts mrtg y los ejecuta (pings y trafico) para generar un rrd y con sonsultas http, se ejecuta un php que convierte los .rrd en imagenes y las muestra.
El servidor WEB de guifi.net conoce la url del servidor de graficas de la zona de un nodo, y cuando visitas un nodo en la web se muestran las graficas/imagenes remotas que hay en los servidores SNPServices cliente.
Manuales
- Servidor de gráficas 1 (Debian/Ubuntu) método apt + configuración virtualhost apache
- Servidor de gráficas 2 (Debian/Ubuntu) método dpkg
- Servidor de gráficas 3 (Debian/Ubuntu) extendido
Como trabaja el cliente SNPServices
El cliente SNPServices tiene varios passos a realizar para poder recopilar datos y hacer un escaneo en las direcciones cercanas. <?php
$rootZone = 52771;
- 3671;
$minX = 999; $minY = 999; $maxX = -999; $maxY = -999;
$members = array();
$hlastnow = @fopen("http://guifi.net/guifi/refresh/maps", "r") or die('Error reading changes\n');
$last_now = fgets($hlastnow);
fclose($hlastnow);
$hlast= @fopen("/tmp/last_update.cnml", "r");
if (($hlast) and ($last_now == fgets($hlast))) {
fclose($hlast);
echo "No changes.\n";
exit();
}
echo "Getting CNML file\n";
$hcnml = @fopen("http://guifi.net/guifi/cnml/".$rootZone."/detail", "r");
$wcnml = @fopen("guifi.cnml", "w+");
while (!feof($hcnml)) {
$buffer = fgets($hcnml, 4096);
fwrite($wcnml,$buffer);
}
fclose($hcnml);
fclose($wcnml);
$hlast= @fopen("/tmp/last_update.cnml", "w+") or die('Error!');
fwrite($hlast,$last_now);
fclose($hlast);
?>
PMF
- Regenerar los ficheros rrd
- tener en cuenta que al connectar un dispositivo por cable ponerlo en Lan o en la ubicacion que sea, sino puede que no grafique correctamente.