-
Notifications
You must be signed in to change notification settings - Fork 4
Instal·lar
##Instal·lar##
Guia d'instal·lació de GPS per a Ubuntu Server 14.04 LTS.
###Dependències###
sudo apt-get install mongodb git collectd collectd-utils build-essential nginx php-fpm php5-fpm unzip php5-mongo snmp libsnmp-base libsnmp-dev snmpd net-snmp snmp-mibs-downloader
###Configurar Collectd###
sudo nano /etc/collectd/collectd.conf
FQDNLookup true LoadPlugin syslog LogLevel info LoadPlugin battery LoadPlugin cpu LoadPlugin df LoadPlugin disk LoadPlugin entropy LoadPlugin exec LoadPlugin interface LoadPlugin irq LoadPlugin load LoadPlugin memory LoadPlugin processes LoadPlugin rrdcached LoadPlugin swap LoadPlugin users Exec "dave:users" "/home/davidrubert/gps/manage.js" "monitor" "links" Exec "dave:users" "/home/davidrubert/gps/manage.js" "monitor" "users" FSType rootfs FSType sysfs FSType proc FSType devtmpfs FSType devpts FSType tmpfs FSType fusectl FSType cgroup IgnoreSelected true DaemonAddress "unix:/var/run/rrdcached.sock" DataDir "/var/lib/rrdcached/db/collectd" CreateFiles true CreateFilesAsync false CollectStatistics true Filter "* .conf"
###Descarregar SNMP MIBS###
sudo download-mibs
- Ara cal editar el fitxer de configuració de SNMP:
sudo nano /etc/snmp/snmp.conf
- I comentar la línia:
mibs :
- Ha de quedar així:
#mibs :
###NodeJS###
curl -sL https://deb.nodesource.com/setup | sudo bash - sudo apt-get install -y nodejs
###Clonar Repositori###
git clone https://github.com/tombatossals/gps.git
###Dependències NodeJS i Bower###
cd gps
npm update
sudo npm install -g bower
bower update
###Inicialitzar Base de Dades????###
##Configurar GPS##
###Centro del Mapa###
nano public/json/center.json
##Configurar Routers##
###Mikrotik###
- Habilitar els serveis API i SSH.
####Usuari####
-
Afegir usuari:
/user group add name#gps policy#"ssh,read,test,winbox,api,!local,!telnet,!ftp,!reboot,!write,!policy,!password,!web,!sniff,!sensitive" /user add name#private_user group#gps password#secret_password
####Script####
- Afegir aquest script:
:local ttx :local rrx :set ttx 0 :set rrx 0 :global ip :global username :global password :global interval :global duration :global proto /tool bandwidth-test $ip user#$username password#$password protocol#$proto \ direction#transmit interval#$interval duration#$duration do#{ :if ($status#"running") do#{ :set ttx $"tx-total-average" } } /tool bandwidth-test $ip user#$username password#$password protocol#$proto \ direction#receive interval#$interval duration#$duration do#{ :if ($status#"running") do#{ :set rrx $"rx-total-average" } } } /tool bandwidth-test $ip user#$username password#$password protocol#$proto \ direction#receive interval#$interval duration#$duration do#{ :if ($status#"running") do#{ :set rrx $"rx-total-average" } } :put ("tx:". $ttx . " rx:" . $rrx )
-
Nom: ''bandwidth''
-
Permisos: ''read,test''
##MongoDB##
- Utilitza MongoDB com a base de dades per guardar la informació. Utilitza el port 27017 TCP.
http://www.charlascylon.com/mongodb
###Genghis###
- També utilitza ''Genghis'' per gestionar la base de dades via web. És una especie de PhpMyadmin per a MongoDB. També hi ha disponible una aplicació per a Android.
####Instal·lar####
####Cal configurar autentificació per poder connectar a l BD?####
-
Descarregar i descomprimir:
mkdir genghis cd genghis wget https://github.com/bobthecow/genghis/archive/v2.3.11.zip unzip v2.3.11.zip mv genghis-2.3.11/genghis.php . rm -rf genghis-2.3.11/
-
Configurar Nginx
sudo nano /etc/nginx/sites-available/gps
location ~ ^/(mongo)/ { #For Basic Auth auth_basic "Restricted"; auth_basic_user_file .htpasswd; #End for basic auth fastcgi_pass unix:/var/run/php5-fpm.sock; include fastcgi_params; set $script 'genghis.php'; fastcgi_split_path_info ^(/mongo)(/?.+)$; fastcgi_param SCRIPT_FILENAME /home/davidrubert/genghis/$script; fastcgi_param SCRIPT_NAME /$1/$script; fastcgi_param PATH_INFO $fastcgi_path_info; }
-
Reiniciar Nginx
sudo service nginx reload
####Autenticació####
-
Cal configurar Nginx amb una autentificació bàsica per evitar que tothom pugui accedir a la base de dades MongoDB i veure les contrasenyes dels usuaris en text pla.
-
Veure Nginx#Autenticaci.C3.B3_b.C3.A0sica
sudo htpasswd -c '''/home/davidrubert/genghis/.htpasswd''' exampleuser sudo chown www-data '''/home/davidrubert/genghis/.htpasswd''' sudo chmod 600 '''/home/davidrubert/genghis/.htpasswd'''
##Nginx##
- Veure Nginx.
###Configuració###
https://github.com/tombatossals/gps/wiki/Configuraci%C3%B3n-Nginx
####HTTP####
sudo nano /etc/nginx/sites-available/gps
location / { #For Basic Auth #auth_basic "Restricted"; #auth_basic_user_file /etc/nginx/.htpasswd; #End for basic auth proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_pass http://app_gps; proxy_redirect off; }
####HTTPS####
-
Veure Nginx#HTTPS
sudo nano /etc/nginx/sites-available/gps_ssl
upstream app_gps_ssl { server 127.0.0.1:3000; } log_format main_ssl '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; server { listen 443 default_server; server_name tortosa.qui.guifi.net; access_log /var/log/nginx/gps.access.log main; location ~ ^/(mongo)/ { #For Basic Auth auth_basic "Restricted"; auth_basic_user_file .htpasswd; #End for basic auth fastcgi_pass unix:/var/run/php5-fpm.sock; include fastcgi_params; set $script 'genghis.php'; fastcgi_split_path_info ^(/mongo)(/?.+)$; fastcgi_param SCRIPT_FILENAME /home/davidrubert/genghis/$script; fastcgi_param SCRIPT_NAME /$1/$script; fastcgi_param PATH_INFO $fastcgi_path_info; } location / { #For Basic Auth #auth_basic "Restricted"; #auth_basic_user_file /etc/nginx/.htpasswd; #End for basic auth proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_pass http://app_gps; set $script 'genghis.php'; fastcgi_split_path_info ^(/mongo)(/?.+)$; fastcgi_param SCRIPT_FILENAME /home/davidrubert/genghis/$script; fastcgi_param SCRIPT_NAME /$1/$script; fastcgi_param PATH_INFO $fastcgi_path_info; } location / { #For Basic Auth #auth_basic "Restricted"; #auth_basic_user_file /etc/nginx/.htpasswd; #End for basic auth proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_pass http://app_gps; proxy_redirect off; } ssl on; ssl_certificate /etc/nginx/ssl/server.crt; ssl_certificate_key /etc/nginx/ssl/server.key; }
##Afegir Nodes##
- Per afegir un node cal crear un fitxer de configuració ''.json'' amb les següents dades:
name: "TortosaPOPEbrecom", interfaces: [], mainip: "10.91.32.129", username: "guest", system: "mikrotik", password: "", latlng: { lat: 40.813794, lng: 0.521193 }
-
Després per afegir-lo a la base de dades:
./manage.js add node node.json