summaryrefslogtreecommitdiff
path: root/src/openwrt_log_analyzer.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/openwrt_log_analyzer.py')
-rwxr-xr-xsrc/openwrt_log_analyzer.py28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/openwrt_log_analyzer.py b/src/openwrt_log_analyzer.py
index bdfeb6c..a55aaf8 100755
--- a/src/openwrt_log_analyzer.py
+++ b/src/openwrt_log_analyzer.py
@@ -30,11 +30,14 @@ limit = 10
"""
-def main(mac: str, title: str) -> int:
+def main(mac: str,
+ title: str,
+ ap: int) -> int:
db = BotsDatabase()
data = db.get_openwrt_logs(filter_text=mac,
min_id=state['last_id'],
+ access_point=ap,
limit=config['openwrt_log_analyzer']['limit'])
if not data:
return 0
@@ -45,22 +48,25 @@ def main(mac: str, title: str) -> int:
max_id = log.id
text = '\n'.join(map(lambda s: str(s), data))
- telegram.send_message(f'<b>{title}</b>\n\n' + text)
+ telegram.send_message(f'<b>{title} (AP #{ap})</b>\n\n' + text)
return max_id
if __name__ == '__main__':
config.load('openwrt_log_analyzer')
+ for ap in config['aps']:
+ state_file = config['simple_state']['file']
+ state_file = state_file.replace('.txt', f'-{ap}.txt')
- state = SimpleState(file=config['simple_state']['file'],
- default={'last_id': 0})
+ state = SimpleState(file=state_file,
+ default={'last_id': 0})
- max_last_id = 0
- for name, mac in config['devices'].items():
- last_id = main(mac, title=name)
- if last_id > max_last_id:
- max_last_id = last_id
+ max_last_id = 0
+ for name, mac in config['devices'].items():
+ last_id = main(mac, title=name, ap=ap)
+ if last_id > max_last_id:
+ max_last_id = last_id
- if max_last_id:
- state['last_id'] = max_last_id
+ if max_last_id:
+ state['last_id'] = max_last_id