wiki.pl: Port some fixes from upstream
[Orgmuse.git] / traffic
blob03506ab5dfec270c4b6bb02d4030d3353456f513
1 #!/usr/bin/perl
2 # traffic -- summarize bandwidth usage
3 # Copyright (C) 2006 Alex Schroeder <alex@emacswiki.org>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the
17 # Free Software Foundation, Inc.
18 # 59 Temple Place, Suite 330
19 # Boston, MA 02111-1307 USA
21 # $Id: traffic,v 1.2 2006/09/01 11:14:34 as Exp $</p>'
23 while (<STDIN>) {
24 # 304 responses have - as bytes
25 $bytes += $1 if m/\[.*?\] ".*?" \d+ (\d+)/;
27 printf "%d %dK %.1fM %.2fG\n", $bytes, $bytes/1024, $bytes/1024000, $bytes/1024000000;