ndejong / pfsense_fauxapi

REST based API interface for pfSense 2.3.x and 2.4.x to facilitate devops

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Get traffic bandwidth on wan interface

mcodo opened this issue · comments

Hi
Is there a way to get the consumed speed on wan interface like the data we get under Status -> Traffic Graph?
Bandwidth In and Bandwidth Out

Thanks

Hi mcodo -

This is probably a nice feature request actually, I'll keep the ticket open until implemented.

In the mean time I've taken a look through pfSense code to figure out where this data is actually coming from in the underlaying system for which there is an interesting exec call made by pfSense in bandwidth_by_ip.php - see below:-

$_grb = exec("/usr/local/bin/rate -i {$real_interface} -nlq 1 -Aba 20 {$sort_method} {$ratesubnet} | tr \"|\" \" \" | awk '{ printf \"%s:%s:%s:%s:%s\\n\", $1,  $2,  $4,  $6,  $8 }'", $listedIPs);

I expect you'll be able to use /usr/local/bin/rate to get the data you are looking for.

Following up on this

A new function interface_stats has been added that partly answers your requirement here, the issue however is that the way bandwidth usage is computed in the pfSense GUI in these graphs under Status -> Traffic is via client side javascript that computes rates based on the cumulative total bytes that pfSense provides underneath.

In short, you can achieve the same effect but you'll have to do the same as the pfSense GUI does by polling (fauxapi) and computing the bandwidth rates you are looking for.

Release 1.3 due shortly

N