Merge remote-tracking branch 'origin/master'

This commit is contained in:
tomaae 2020-05-20 16:01:45 +02:00
commit b53c346dc6
2 changed files with 21 additions and 0 deletions

View file

@ -65,6 +65,8 @@ Control simple queues.
More information about simple queues can be found on [Mikrotik support page](https://wiki.mikrotik.com/wiki/Manual:Queue#Simple_Queues).
NOTE: FastTracked packets are not processed by Simple Queues.
![Queue switch](https://raw.githubusercontent.com/tomaae/homeassistant-mikrotik_router/master/docs/assets/images/ui/queue_switch.png)
## Host Tracking
@ -87,6 +89,8 @@ Feature is present in Winbox IP-Accounting. Make sure that threshold is set to r
More information about Accounting can be found on [Mikrotik support page](https://wiki.mikrotik.com/wiki/Manual:IP/Accounting).
NOTE: Accounting does not count in FastTracked packets.
![Accounting sensor](https://raw.githubusercontent.com/tomaae/homeassistant-mikrotik_router/master/docs/assets/images/ui/accounting_sensor.png)
# Install integration

View file

@ -1179,6 +1179,23 @@ class MikrotikControllerData:
],
)
threshold = self.api.path("/ip/accounting")[0].get("threshold")
entry_count = len(accounting_data)
if entry_count is threshold:
_LOGGER.warning(
f"Accounting entries count reached the threshold of {threshold}!"
" Some entries were not saved by Mikrotik so accounting calculation won't be correct."
" Consider shortening update interval or"
" increasing the accounting threshold value in Mikrotik."
)
elif entry_count > threshold * 0.9:
_LOGGER.info(
f"Accounting entries count ({entry_count} reached 90% of the threshold,"
f" currently set to {threshold}! Consider shortening update interval or"
" increasing the accounting threshold value in Mikrotik."
)
for item in accounting_data.values():
source_ip = str(item.get("src-address")).strip()
destination_ip = str(item.get("dst-address")).strip()