Bug #879
closedCorrect parsing of output by rate
100%
Description
The formating of /usr/local/bin/rate output (called in bandwidth_by_ip.php) sometimes mess up the parser.
For instance this line
192.168.0.2 1.66M 1.31k| 44.31k 756.22 | 1.66M 1.31k| 44.31k 756.22
where there is no space between the "1.31k" and the first pipe character. This both messes with the AWK call and a posibility of sending a extra pipe character to the javascript parser in status_graph.php
this patch fixes the issue:
--- _bandwidth_by_ip.php 2010-09-06 17:49:00.000000000 0200
++ bandwidth_by_ip.php 2010-09-06 17:50:18.000000000 +0200@ -30,7 +30,7
@
//use class A subnet to make sure we capture all traffic on specified interface
$intsubnet = $intip0 . ".0.0.0/8";
-exec("/usr/local/bin/rate -i {$real_interface} -nlq 1 -Aba 20 -c {$intsubnet} | awk '{ printf \"%s:%s:%s:%s:%s\\n\", $1, $2, $5, $8, $11 }'", $listedIPs);
+exec("/usr/local/bin/rate -i {$real_interface} -nlq 1 -Aba 20 -c {$intsubnet} | tr \"|\" \" \" | awk '{ printf \"%s:%s:%s:%s:%s\\n\", $1, $2, $4, $6, $8 }'", $listedIPs);
unset($bandwidthinfo);
unset($receivebytesarray);
Files
Updated by Torben Hørup about 14 years ago
- File bandwidth_by_ip.patch bandwidth_by_ip.patch added
Heres the patch as an attachment instead
Updated by Ermal Luçi about 14 years ago
- Status changed from New to Feedback
- % Done changed from 0 to 100
Applied in changeset f1aad4d1ad04214382ba577360732ae581c51264.
Updated by Jim Pingle about 14 years ago
- Status changed from Feedback to Resolved