summaryrefslogtreecommitdiff
path: root/src/ssh_node5_net.py
diff options
context:
space:
mode:
authoruser <user@node5.net>2024-03-23 18:52:37 +0100
committeruser <user@node5.net>2024-03-23 18:52:37 +0100
commite06d7f926833d6fba19e57cb2211696e0bdbc6ad (patch)
treea3a79b5ec8d0ee254950b53cb9f894e946c7bea9 /src/ssh_node5_net.py
parentf379b1c78cc224581fac16541e5bc3b6ccbc5dd1 (diff)
add login attempts chart
Diffstat (limited to 'src/ssh_node5_net.py')
-rw-r--r--src/ssh_node5_net.py12
1 files changed, 11 insertions, 1 deletions
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)