mirror of
https://github.com/tomaae/homeassistant-mikrotik_router.git
synced 2025-07-12 18:34:30 +02:00
Adding logging for near or exceeded accounting entries compared to set threshold. Should help with debugging broken accounting calculations
This commit is contained in:
parent
55f8ad2fb4
commit
2ebf894c3c
1 changed files with 13 additions and 0 deletions
|
@ -1179,6 +1179,19 @@ 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():
|
for item in accounting_data.values():
|
||||||
source_ip = str(item.get("src-address")).strip()
|
source_ip = str(item.get("src-address")).strip()
|
||||||
destination_ip = str(item.get("dst-address")).strip()
|
destination_ip = str(item.get("dst-address")).strip()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue