vnstati – la rete in una immagine

Delle varie macchine che ho attive mi piace vedere il traffico giornaliero sulla scheda di rete, così da diverso tempo uso vnstat di cui in passato avevo già parlato, ma non sempre l’accesso via shell è comodo, così ho pensato di usare vnstati, che appoggiandosi a vnstat genera un’ immagine.

Il pacchetto è disponibile sia per debian che raspbian, ed è molto semplice da usare.

Qui un esempio con raspberry PI3 per video sorveglianza con motioneye .

Cerchiamo ora di rendere la cosa più fruibile e interessante.

A priori occorre avere vnstat ( che è una dipendenza) attivo e funzionante dato che i dati vengono raccolti da lui e trasformati da vnstati in immagine.

L’uso è molto semplice e il comando si riassume :

$ vnstati 
 vnStat image output 1.15 by Teemu Toivola <tst at iki dot fi> 
 
         -h,  --hours          output hours 
         -d,  --days           output days 
         -m,  --months         output months 
         -t,  --top10          output top10 
         -s,  --summary        output summary 
         -hs, --hsummary       output horizontal summary with hours 
         -vs, --vsummary       output vertical summary with hours 
         -nh, --noheader       remove header from output 
         -ne, --noedge         remove edge from output 
         -nl, --nolegend       remove legend from output 
         -ru, --rateunit       swap configured rate unit 
         -o,  --output         select output filename 
         -c,  --cache          update output only when too old 
         -i,  --iface          used interface (default: eth0) 
         -?,  --help           this help 
         -D,  --debug          show some additional debug information 
         -v,  --version        show version 
         --dbdir               select database directory 
         --style               select output style (0-3) 
         --locale              set locale 
         --config              select config file 
         --altdate             use alternative date location 
         --headertext          specify header text string 
         --transparent         toggle background transparency 
 
See also "man vnstati".

un semplice comando e possiamo generare un’ immagine dove vogliamo:

$ vnstati -vs -o /home/pippa/data/tmp/puppa.png

Se però il luogo non è raggiungibile facilmente possiamo inviarci l’immagine come allegato in una email, io l’ho preferito e giornalmente mi faccio inviare un’ instantanea con i dati del traffico.

Per automatizzare il processo ho scelto mutt, di cui basta anche una configurazione minimale che sia in grado di inviare la posta in modo corretto e una riga in crontab.

56 23 * * * vnstati -vs -o /home/pippa/data/tmp/puppa.png |mutt -s traffic-PI-1 -a /home/pippa/data/tmp/puppa.png -- silvio@libero.it

in questo modo riesco a vedere il traffico sul mio server di posta

e il traffico del raspberry PI-B che funge da server IRC su TOR e come torrent station.

Se non vi piace mutt potete sempre trovare qualche altro modo per inviare l’immagine che viene sovrascritta giornalmente.

 

Barbatrucco

A chi piace la shell lascio alcuni comandi interessanti per vedere le previsioni del tempo oppure la fase della luna.

https://github.com/chubin/wttr.in

Usato per le previsioni

$ curl http://wttr.in/Roma 
Weather report: Rome, Italy 
 
    \  /       Partly cloudy 
  _ /"".-.     14-15 °C 
    \_(   ).   ← 4 km/h 
    /(___(__)  14 km 
               0.0 mm 
                                                       ┌─────────────┐ 
┌──────────────────────────────┬───────────────────────┤  Thu 17 May ├───────────────────────┬──────────────────────────────┐ 
│            Morning           │             Noon      └──────┬──────┘     Evening           │             Night            │ 
├──────────────────────────────┼──────────────────────────────┼──────────────────────────────┼──────────────────────────────┤ 
│    \  /       Partly cloudy  │    \  /       Partly cloudy  │    \  /       Partly cloudy  │    \  /       Partly cloudy  │ 
│  _ /"".-.     19 °C          │  _ /"".-.     22-23 °C       │  _ /"".-.     20 °C          │  _ /"".-.     17 °C          │ 
│    \_(   ).   ↖ 6-7 km/h     │    \_(   ).   ↑ 11-13 km/h   │    \_(   ).   ↗ 8-11 km/h    │    \_(   ).   ↘ 5-8 km/h     │ 
│    /(___(__)  19 km          │    /(___(__)  18 km          │    /(___(__)  17 km          │    /(___(__)  17 km          │ 
│               0.0 mm | 0%    │               0.0 mm | 0%    │               0.0 mm | 0%    │               0.0 mm | 0%    │ 
└──────────────────────────────┴──────────────────────────────┴──────────────────────────────┴──────────────────────────────┘ 
                                                       ┌─────────────┐ 
┌──────────────────────────────┬───────────────────────┤  Fri 18 May ├───────────────────────┬──────────────────────────────┐ 
│            Morning           │             Noon      └──────┬──────┘     Evening           │             Night            │ 
├──────────────────────────────┼──────────────────────────────┼──────────────────────────────┼──────────────────────────────┤ 
│     \   /     Sunny          │    \  /       Partly cloudy  │    \  /       Partly cloudy  │    \  /       Partly cloudy  │ 
│      .-.      22 °C          │  _ /"".-.     25 °C          │  _ /"".-.     22 °C          │  _ /"".-.     19 °C          │ 
│   ― (   ) ―   ↗ 4-5 km/h     │    \_(   ).   → 8-9 km/h     │    \_(   ).   → 11-15 km/h   │    \_(   ).   ↘ 6-11 km/h    │ 
│      `-’      20 km          │    /(___(__)  19 km          │    /(___(__)  17 km          │    /(___(__)  18 km          │ 
│     /   \     0.0 mm | 0%    │               0.0 mm | 0%    │               0.0 mm | 0%    │               0.0 mm | 0%    │ 
└──────────────────────────────┴──────────────────────────────┴──────────────────────────────┴──────────────────────────────┘ 
                                                       ┌─────────────┐ 
┌──────────────────────────────┬───────────────────────┤  Sat 19 May ├───────────────────────┬──────────────────────────────┐ 
│            Morning           │             Noon      └──────┬──────┘     Evening           │             Night            │ 
├──────────────────────────────┼──────────────────────────────┼──────────────────────────────┼──────────────────────────────┤ 
│    \  /       Partly cloudy  │    \  /       Partly cloudy  │    \  /       Partly cloudy  │    \  /       Partly cloudy  │ 
│  _ /"".-.     23 °C          │  _ /"".-.     26 °C          │  _ /"".-.     23-25 °C       │  _ /"".-.     20 °C          │ 
│    \_(   ).   ↑ 5-6 km/h     │    \_(   ).   ↗ 10-11 km/h   │    \_(   ).   → 9-12 km/h    │    \_(   ).   ↘ 5-9 km/h     │ 
│    /(___(__)  20 km          │    /(___(__)  19 km          │    /(___(__)  18 km          │    /(___(__)  18 km          │ 
│               0.0 mm | 0%    │               0.0 mm | 0%    │               0.0 mm | 0%    │               0.0 mm | 0%    │ 
└──────────────────────────────┴──────────────────────────────┴──────────────────────────────┴──────────────────────────────┘ 
 
New feature: multilingual location names wttr.in/станция+Восток (in UTF-8) and location search wttr.in/~Kilimanjaro (just add ~ before) 
Follow @igor_chubin for wttr.in updates

oppure sulla fase lunare :

$ curl http://wttr.in/Moon 
                             -.   
                                  .       
                                    -.    
                                       -.         
                                         \        
                                          \.      
                                            \     
                                           @ \    
                                            @|    
                                              \  New Moon + 
                                              |  1 10:53:32 
                                              |  First Quarter - 
                                              |  5  5:07:17 
                                            o /   
                                             |    
                                           . /    
                                            /     
                                          /'      
                                         /        
                                       -'         
                                    -'    
                                  '       
                             -'   
 
 
Follow @igor_chubin for wttr.in updates

Ora non resta che divertirsi     🙂

 

PS. Comunità scomparsa ?

Qualcosa è andato storto ?

L’enfant prodige ha demolito tutto e ora resta con i cocci in mano, il tempo lascia verdetti poco piacevoli ……….. 

3 risposte a “vnstati – la rete in una immagine”

  1. Maremma a buho ritto
    codesta si che l’è na notizia
    debianizzati è agonizzante ?

  2. Che nostalgia dei vecchi tempi…

    Era preannunciato, ma dispiace comunque tanto. Mi mancano soprattutto le edizioni dell’ezine 🙁

Rispondi

Questo sito usa Akismet per ridurre lo spam. Scopri come i tuoi dati vengono elaborati.