From e06d7f926833d6fba19e57cb2211696e0bdbc6ad Mon Sep 17 00:00:00 2001 From: user Date: Sat, 23 Mar 2024 18:52:37 +0100 Subject: add login attempts chart --- src/ssh_node5_net.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/ssh_node5_net.py') diff --git a/src/ssh_node5_net.py b/src/ssh_node5_net.py index 3da31cc..1247603 100644 --- a/src/ssh_node5_net.py +++ b/src/ssh_node5_net.py @@ -1,4 +1,5 @@ import logging +import datetime import flask @@ -37,6 +38,7 @@ logger.root.addHandler(stream_handler) app = flask.Flask(__name__, template_folder='templates', static_folder='static', static_url_path='') + @app.route("/password_of_the_month") @app.route("/password of the month") @app.route("/passwd") @@ -45,13 +47,21 @@ def password_of_the_month(): return password +def format_time(input: datetime.datetime) -> str: + return input.strftime('%e %b %Y %H:%M') + @app.route("/") def index(): latest_loging_attempts = db_handler.get_latest_login_attempts() top_usernames = db_handler.get_top('username') top_passwords = db_handler.get_top('password') + histogram = db_handler.get_histogram() + histogram_data = [a['total_count'] for a in histogram] + histogram_labels = [format_time(a['date']) for a in histogram] return flask.render_template( 'index.html', latest_login_attempts=latest_loging_attempts, top_usernames=top_usernames, - top_passwords=top_passwords) + top_passwords=top_passwords, + histogram_data=histogram_data, + histogram_labels=histogram_labels) -- cgit v1.2.3