-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WAN Interface missing in JSON array... #3
Comments
Are you saying that you have a second WAN interface (besides "wan_dhcp") that's not showing? If so, make sure it has a name (not even sure it can't, but just in case). All the script is doing is calling pfsense's https://github.com/pfsense/pfsense/blob/master/src/etc/inc/gwlb.inc The only other thing I can think of is that the script removes the "gw_" header (if there is one), which goes back to the original idea. If there is no name,
|
Hi again, no, I don't have another WAN. But the one showing is not showing any traffic. When in fact traffic is both coming in and being sent. :) PS: In between these posts I had a complete crash of my PfSense box, reinstalled it restored the settings and added the php file again... But same result as above. No traffic on the WAN... Am I missing something? :) |
It seems one reason I had removed my "gw_" header is that interface statistics are not returned with it. I believe the "gw_" can be changed, and perhaps your version of "gw_" is "wan_". See if removing that from your interface name solves the problem.
|
Hmm... If I add under the foreach statement the following... foreach ($gateways_status as $a_gateway) {
print_r($a_gateway); This is the (only) array I get: Array (
[monitorip] => 81.233.82.1
[srcip] => 81.233.82.162
[name] => WAN_DHCP
[delay] => 69.481ms
[stddev] => 43.64ms
[loss] => 12%
[status] => loss
) So, then I added a new line under if ($_GET['rates'] == 1) {: if ($_GET['rates'] == 1) {
$iface = "wan"; Forcing the interface name, and tada! It works. :) {
"lan":{
"inKbps":813.62255664651,
"outKbps":159.44097443015},
"wan":{
"inKbps":247.99436511482,
"outKbps":47.978611709496,
"name":"wan",
"status":"okay",
"monitorip":"X.X.X.X",
"sourceip":"X.X.X.X",
"delay":"51.083ms",
"loss":"0.0%"
}
} Update: if (substr($iface,3,7) == "_dhcp") $iface = substr($iface,0,3); It's of course basically the same as "forcing" it to "wan". :) |
Glad you got it working! If you want to try it, to make things simpler I also changed the code slightly to ignore the names altogether and just iterate directly through the "real" interface names em0, em1, etc. |
Oh, well. That is not the name of my devices actually... :) |
I gave it one last try. I think this version should hopefully solve the problem for good! Seems em is used for intel, and bge for broadcom chipsets. But with this new version, none of it should matter since I should be accessing the correct names directly. It also shows you all the names, interfaces, etc for reference. |
Hi again, looking good. :) Now it works without any alterations. Great work! Result: {
"lan": {
"inKbps":200.06687090799,
"outKbps":553.31116912934,
"interface":"bge1"
},
"wan": {
"inKbps":1074.477155649,
"outKbps":376.96074702806,
"interface":"bge0",
"friendlyiface":"wan",
"name":"WAN_DHCP",
"status":"okay",
"monitorip":"X.X.X.X",
"sourceip":"X.X.X.X",
"delay":"40.233ms",
"loss":"2%"
}
} |
Hi! Thank you for this little script.
I'm going to use it on my "MagicMirror" to display the current in/outgoing data rates on my "WAN" interface. However my "WAN" interface does not show up in the json array.
I looks like this (I removed the IP:s):
Any idea whats going on? :)
Best regards Erik
The text was updated successfully, but these errors were encountered: