diff --git a/back/pialert.py b/back/pialert.py index 64bd27d3..b2f74a9d 100755 --- a/back/pialert.py +++ b/back/pialert.py @@ -2347,7 +2347,7 @@ def send_notifications (): if 'plugins' in INCLUDED_SECTIONS: # Compose Plugins Section - sqlQuery = """SELECT * from Plugins_Events where Status == 'new'""" + sqlQuery = """SELECT Plugin, Object_PrimaryId, Object_SecondaryId, DateTimeChanged, Watched_Value1, Watched_Value2, Watched_Value3, Watched_Value4, Status from Plugins_Events""" notiStruc = construct_notifications(sqlQuery, "Plugins") @@ -2357,6 +2357,9 @@ def send_notifications (): mail_text = mail_text.replace ('', notiStruc.text + '\n') mail_html = mail_html.replace ('', notiStruc.html) + # check if we need to report something + plugins_report = plugin_check_smth_to_report(json_plugins) + json_final = { "internet": json_internet, @@ -2373,11 +2376,12 @@ def send_notifications (): mail_html = generate_mac_links (mail_html, deviceUrl) # Write output emails for debug + write_file (logPath + '/report_output.json', json.dumps(json_final)) write_file (logPath + '/report_output.txt', mail_text) write_file (logPath + '/report_output.html', mail_html) # Send Mail - if json_internet != [] or json_new_devices != [] or json_down_devices != [] or json_events != [] or json_ports != [] or debug_force_notification: + if json_internet != [] or json_new_devices != [] or json_down_devices != [] or json_events != [] or json_ports != [] or debug_force_notification or plugins_report: update_api(True) @@ -2430,6 +2434,9 @@ def send_notifications (): """, (datetime.datetime.now(),) ) sql.execute ("""UPDATE Events SET eve_PendingAlertEmail = 0 WHERE eve_PendingAlertEmail = 1""") + + # clear plugin events + sql.execute ("DELETE FROM Plugins_Events") changedPorts_json_struc = None @@ -2457,22 +2464,22 @@ def construct_notifications(sqlQuery, tableTitle, skipText = False, suppliedJson else: json_struc = suppliedJsonStruct - json = json_struc.json + jsn = json_struc.json html = "" text = "" - if json["data"] != []: + if len(jsn["data"]) > 0: text = tableTitle + "\n---------\n" - html = convert(json, build_direction=build_direction, table_attributes=table_attributes) - + html = convert(jsn, build_direction=build_direction, table_attributes=table_attributes) html = format_table(html, "data", headerProps, tableTitle).replace('