Project

General

Profile

Actions

Bug #879

closed

Correct parsing of output by rate

Added by Torben Hørup about 14 years ago. Updated about 14 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
-
Category:
-
Target version:
Start date:
09/06/2010
Due date:
% Done:

100%

Estimated time:
Plus Target Version:
Release Notes:
Affected Version:
2.0
Affected Architecture:

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

bandwidth_by_ip.patch (680 Bytes) bandwidth_by_ip.patch Torben Hørup, 09/07/2010 04:53 AM
Actions

Also available in: Atom PDF