deelab.org | There's no place like 127.0.0.1

mar/08

8

myminstat.sh

uno scriptino utile su cui sto lavorando nel tempo libero.

codice:
#!/bin/bash
#v1=$(uptime | awk '{print "uptime: "$3}')
v1=$((`cut -f1 -d' ' /proc/uptime | cut -f1 -d.` / 60))
v2=$(cat /proc/net/dev | grep eth0 | tr ":" " " | awk '{ print "download: " $2/1024/1024 " MB, upload: " $10/1024/1024 " MB"}')
echo uptime: $v1 mins, $v2.

#!/bin/bash
v1=$((`cut -f1 -d’ ‘ /proc/uptime | cut -f1 -d.` / 60))
v2=$(echo “scale=2;$(cat /proc/net/dev | grep eth0 | tr “:” ” ” | awk ‘{ print $2 }’)/1024/1024″ |bc)
v3=$(echo “scale=2;$(cat /proc/net/dev | grep eth0 | tr “:” ” ” | awk ‘{ print $10 }’)/1024/1024″ |bc)
echo uptime: $v1 mins, downloads: $v2 MB, uploads: $v3 MB.

output:
$ sh myminstat.sh
uptime: 151 mins, download: 88.5834 MB, upload: 2112.35 MB.

uptime: 947 mins, downloads: 177.64 MB, uploads: 886.35 MB.

TODO:
1) approssimazione a due cifre dopo la virgola;
2) loggin su file;
3) statistiche;
4) parametrizzazione:
default: current tripla valori;
-x: differenza tra current e ultima tripla di valori presa;
-y: differenza tra current e prima tripla valori presa;
-m: media sull’intero log delle triple di valori prese.

Share and Enjoy:
  • Print
  • PDF
  • Slashdot
  • Technorati
  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Identi.ca
  • Twitter

RSS Feed

Non c'è ancora nessun commento.

Leave a comment!

<<

>>

deelab.org owned by

Dario Vilardi
2006 ~ 2010

Stats

  • Pagine mostrate: 153114
  • Visitatori unici: 101361
  • Pagine visitate nelle ultime 24 ore: 78
  • Visitatori unici nelle ultime 24 ore: 46