Comments (4)
It takes a while after the end of each day for its daily stats to populate so that explains why you don't yet see the 5th in the chart. Switch to hourly stats and you will see stats up the last full hour.
Regarding the use of the stat_sessions() method, you do need to provide the correct number of parameters, otherwise, PHP will assume the only provided value must be assigned to the first parameter.
If you do it like so:
//stat_sessions($start = null, $end = null, $mac = null, $type = 'all');
$unifi_connection->stat_sessions(null, null, $mac)
will return the session collection for the device with MAC address $mac for the past week (7*24 hours).
If you wish to see them for a different timeframe, simply pass the required start and end Unix timestamps in seconds.
See the code comments here:
https://github.com/Art-of-WiFi/UniFi-API-client/blob/master/src/Client.php#L859-L871
See this site for some explanation and tools regarding Unix (or epoch) time(stamps):
https://www.epochconverter.com/
from unifi-api-client.
At first glance, your code is fine although I personally would use a foreach() loop which is more straightforward when cycling through all elements in an array.
The difference you see is caused by the fact you're looking at data in the controller which is coming from a different source. The source of the data you were looking at is the sessions collection which is available through the stat_sessions() method/function.
The collection you are going through is used to populate the "Show historical data" for the client, while the view you were looking is available from the "History" tab for the client.
I cannot say why there is a difference between the two in your case. Maybe it has to do with the data retention settings?
These are the data retention settings which we always use (where possible):
from unifi-api-client.
My settings are slightly different, but I think should be fine for this example:
Another look:
You appear to be right in that the Show Historical Data graph, while darn near impossible to actually tabulate since you have to do hovers, seems to have a different amount of data. Here's a GIF that shows Daily Historical for the device. (Left most Y axis is the "3rd", right is the "4th", and then it's blank through the "5th":
Could be a time zone issue, but even so, none of the data shows anything close to the amount of data xferred from the API client test. I tried the stat_sessions
call, but it seems to be ignoring the $mac
and is returning all sessions for all MACs. (Again could be a newb thing...)
$mac = "my_secret_mac";
$result = $unifi_connection->stat_sessions($mac);
At any rate (har har), the data that came back making no sense either.
Hostname rx_bytes/1024
Matched 1219
Matched 69
Matched 0
Matched 65
Matched 73
Matched 85
Matched 1052
Matched 52
Matched 1433
Matched 5530
Matched 141
Matched 2517
Matched 5
Matched 0
Matched 95
Matched 116
Matched 170
Total kbytes rcvd: 12622
Total sessions: 17
At this point I don't know what's what, and may be outside the scope of your responsibilities, but I do appreciate any and all help. :)
from unifi-api-client.
Issue appears to be resolved, now closing. Feel free to re-open if needed.
from unifi-api-client.
Related Issues (20)
- setting a rule HOT 7
- Having issues running script on CentOS 8 HOT 4
- cURL errors on script run HOT 4
- Control PDU Outlets HOT 1
- Controller url HOT 4
- Manually authorize guests HOT 3
- Rate limiting? HOT 26
- Function for changing network on the port of device? HOT 3
- HTTP response status received: 400. Probably a controller login failure HOT 6
- en/disable port HOT 2
- Controller 8.0.2 HOT 13
- UDM SE updated to 3.2.7, cannot re-use cookies anymore HOT 30
- Getting "Couldn't connect to server" error HOT 14
- Suggestion for adding method to provide data from /insights/filtering/watchlist HOT 2
- Breaking change… NULL no longer allowed for version number HOT 4
- Login fails if no site is given since 1.1.84 HOT 5
- Added traffic rule functions HOT 1
- Pulling firewall rules? HOT 1
- Example of list_devices_basic usage HOT 3
- list_clients does not include Teleport VPN clients HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from unifi-api-client.