]>
git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - html/cgi-bin/speed.cgi
3436dd3b3a7e455677f8279bfbea1109a18bfcc4
5 # This code is distributed under the terms of the GPL
10 my $data_last = $ENV{'QUERY_STRING'};
14 my (@fields, $field, $name, $value);
15 @fields = split(/&/, $data_last);
16 foreach $field (@fields) {
17 ($name, $value) = split(/=/, $field);
19 $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
20 if ("$name" eq "rxb_last") {
22 } elsif ("$name" eq "txb_last") {
27 my @data_now = `ip -s link show red0`;
33 if ( $lastline =~ /RX/ ) {
34 @fields = split(/ /, $_);
35 $rxb_now = $fields[4];
36 } elsif ( $lastline =~ /TX/ ) {
37 @fields = split(/ /, $_);
38 $txb_now = $fields[4];
43 my ($rx_kbs, $tx_kbs);
44 my $rxb_diff = $rxb_now - $rxb_last;
45 my $txb_diff = $txb_now - $txb_last;
47 if(( $rxb_diff == $rxb_now ) && ( $txb_diff == $txb_now ))
54 $rx_kbs = $rxb_diff / 1024;
55 $rx_kbs = $rx_kbs / 2.2;
56 $rx_kbs = int($rx_kbs);
57 $tx_kbs = $txb_diff / 1024;
58 $tx_kbs = $tx_kbs / 2.2;
59 $tx_kbs = int($tx_kbs);
62 print "Content-type: text/xml\n\n";
63 print "<?xml version=\"1.0\"?>\n";
66 <rx_kbs>$tx_kbs kb/s</rx_kbs>
67 <tx_kbs>$rx_kbs kb/s</tx_kbs>