From 7e6c53f7b85d9663d8f296dc9a72761ae0976401 Mon Sep 17 00:00:00 2001 From: Joshua Date: Thu, 21 Jul 2022 15:47:56 +1000 Subject: [PATCH] BETA - Table ascii for ntfy --- Dockerfile | 2 +- back/pialert.py | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 02d225a6..e75dcf36 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ ENV USER=pi USER_ID=1000 USER_GID=1000 TZ=Europe/London PORT=20211 RUN apt-get update \ && apt-get install --no-install-recommends ca-certificates curl libwww-perl arp-scan perl apt-utils cron sudo lighttpd php php-cgi php-fpm php-sqlite3 sqlite3 dnsutils net-tools python iproute2 nmap python-pip -y \ - && pip install requests \ + && pip install requests prettytable \ && apt-get clean autoclean \ && apt-get autoremove \ && rm -rf /var/lib/apt/lists/* \ diff --git a/back/pialert.py b/back/pialert.py index 136747fa..1562483d 100644 --- a/back/pialert.py +++ b/back/pialert.py @@ -28,7 +28,7 @@ import io import smtplib import csv import requests - +from prettytable import PrettyTable #=============================================================================== # CONFIG CONSTANTS @@ -1284,7 +1284,8 @@ def email_reporting (): WHERE eve_PendingAlertEmail = 1 AND eve_EventType = 'New Device' ORDER BY eve_DateTime""") - + mail_text_table = PrettyTable() + mail_text_table.field_names = ["MAC", "Time", "IP", "Name", "Additional Info"] for eventAlert in sql : mail_section_new_devices = True mail_text_new_devices += text_line_template.format ( @@ -1295,7 +1296,9 @@ def email_reporting (): REPORT_DEVICE_URL, eventAlert['eve_MAC'], eventAlert['eve_MAC'], eventAlert['eve_DateTime'], eventAlert['eve_IP'], eventAlert['dev_Name'], eventAlert['eve_AdditionalInfo']) + mail_text_table.add_row([eventAlert['eve_MAC'], eventAlert['eve_DateTime'], eventAlert['eve_IP'], eventAlert['dev_Name'],eventAlert['eve_AdditionalInfo']]) + mail_text_new_devices = mail_text_table format_report_section (mail_section_new_devices, 'SECTION_NEW_DEVICES', 'TABLE_NEW_DEVICES', mail_text_new_devices, mail_html_new_devices)