Español   Català  

Graphserver 1

From Guifi - Media-pool Common Repository

Introduction

SNP services are a set of tools that allow you to capture the graphs of nodes and supernodes that are configured on this server.

This machine must have one exit to guifi.net and one to the internet as soon as the guifi.net server is accessible only by internet. The server of guifi.net ask our server via web for the graphs of the nodes that are configured on it.


Create a server at guif.net

Previously we have have to add a device type server to our supernode and assign the guifi IP (supernode device > edit > cable connections section > range of IPs assigned to the server (will be created if it doesn't exist) > plug > link device > device creates > Save and modify.

  1. Create contents
  2. guifi.net service
    1. Service name: Graph Server BCNRossello208
    2. Short Name: BCNRossello208-GRAF
    3. Contact: the email address of the administrator
    4. Device: start with typing the name of our server and leave the names of the servers that are beeing created
    5. Service: SNP Graph Server
    6. Status: Status of service
  3. Save.
    Once saved, we will modify and change some values:
  4. Version: 2.0
  5. Url: URL to which you will return to the graph web application, usually http://<server-ip>/snpservices
  6. Save

Methodology

We connect via ssh to the machine and add the Guifi apt repositories:

  1. Configure the Guifi apt repositories
  2. install the snp services package
    # apt-get install snpservices

    We get a Setup menu that we fill with some data:
  3. SNP Graph Server Id. (Default: bandoler=6559) The id number of the service that we have created a the Guifi website

Translated until here

  1. rootZone: which is the ROOT zone. (Default: 3671) Deixem el valor per defecte 3671
  2. SNPDataServer_url: without ending backslash, the url where the data is. (Default: http://snpservices.guifi.net) Deixem el valor per defecte http://snpservices.guifi.net
  3. MRTGConfigSource: mrtg csv data. (Only URL, Graph Server Id will be concatenated) Deixem el valor per defecte http://www.guifi.net/snpservices/graphs/cnml2mrtgcsv.php?server=
  4. CNMLSource: url for CNML node query, use sprintf syntax. Deixem el valor per defecte http://www.guifi.net/snpservices/common/qnodes.php?nodes=%s_
  5. rrddb path. Deixem el valor per defecte /var/lib/snpservices/rrdb/
  6. rddimg path. Deixem el valor per defecte /var/lib/snpservices/rrimg/
  7. rddtool version. Deixem el valor per defecte 1.3
  8. Force to fetch mrtg.cfg now. Yes

I començarà a descarregar el fitxer mrtg.cfg corresponent al servidor de gràfiques definit en el punt 1.

En aquest punt ja podem accedir al servei snpservices via web a aquesta url:

http://ipdelservidor/snpservices

Si no funciona comprova que tinguis un enllaç simbòlic a /var/www que es digui snpservices i apunti a /usr/share/snpservices, si no existeix, crea'l.

# ln -s /usr/share/snpservices /var/www/snpservices

Ampliació

El servidor va desant la informació que li envien els nodes gràcies a uns scripts que veiem a /etc/cron.d/snpservices

fermat:~# cat /etc/cron.d/snpservices
*/30 *  * * *   root    if [ -x /var/www/snpservices/graphs ]; then cd /var/www/snpservices/graphs ; fi; if [ -x /usr/bin/php ] && [ -r /var/www/snpservices/graphs/mrtgcsv2mrtgcfg.php ]; then env LANG=C /usr/bin/php mrtgcsv2mrtgcfg.php >> /var/log/snpservices/mrtgccfg.log 2>&1;fi
*/5 *   * * *   root    if [ ! -x /var/lock/mrtg ]; then mkdir /var/lock/mrtg ; fi; if [ -x /usr/bin/mrtg ] && [ -r /var/lib/snpservices/data/mrtg.cfg ]; then env LANG=C /usr/bin/mrtg /var/lib/snpservices/data/mrtg.cfg --lock-file /var/lock/mrtg/guifi_l >> /var/log/snpservices/mrtg.log 2>&1; fi

El snpservices de la nostra màquina està configurat per tal de preguntar-li a la web de guifi quins nodes n'ha de guardar les gràfiques. Els scripts s'executen cada 5 minuts per a recollir les dades i cada mitja hora per a saber quins nodes s'han de graficar.

Si volem fer un backup de les dades que està recol·lectant el servidor de gràfiques copiem el contingut del directori /var/lib/snpservices. A /usr/share/snpservices hi ha els fitxers de l'aplicació.


Configurar un virtualhost d'apache per al servei

Com ens agrada complicar les coses (o deixar-les una mica ordenades), crearem un subdomini que es dirà graf1, vaig al DNS i apunto el subdomini a la ip d'internet d'aquesta màquina i configuro el virtualhost apuntant al directori snpservices que és un link simbòlic (important afegir la opció FollowSymLinks). Aquest pas és opcional.

# vi /etc/apache2/sites-available/graf1.marsupi.org
<VirtualHost *:80>
ServerAdmin marsupi@marsupi.org
ServerAlias graf1.marsupi.org *.graf1.marsupi.org
ServerName graf1.marsupi.org

DocumentRoot /usr/share/snpservices

#habilitar en cas de debugging
#ErrorLog /var/log/apache2/graf1.marsupi.org_error.log
#LogLevel warn
#CustomLog /var/log/apache2/graf1.marsupi.org_access.log combined

<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /usr/share/snpservices>
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

Carreguemt el fitxer de configuració a l'apache

# a2ensite graf1.marsupi.org

I reiniciem el servei

# service apache2 restart


Agraïments

Thnks Zunbado i Locke.

Personal tools