mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
Merge pull request #52 from Final-Hawk/main
Fix timezone issues and duplicate down notifications
This commit is contained in:
@@ -1184,6 +1184,11 @@ def email_reporting ():
|
|||||||
(
|
(
|
||||||
SELECT dev_MAC FROM Devices WHERE dev_AlertEvents = 0
|
SELECT dev_MAC FROM Devices WHERE dev_AlertEvents = 0
|
||||||
)""")
|
)""")
|
||||||
|
sql.execute ("""UPDATE Events SET eve_PendingAlertEmail = 0
|
||||||
|
WHERE eve_PendingAlertEmail = 1 AND eve_EventType = 'Device Down' AND eve_MAC IN
|
||||||
|
(
|
||||||
|
SELECT dev_MAC FROM Devices WHERE dev_AlertDeviceDown = 0
|
||||||
|
)""")
|
||||||
|
|
||||||
# Open text Template
|
# Open text Template
|
||||||
template_file = open(PIALERT_BACK_PATH + '/report_template.txt', 'r')
|
template_file = open(PIALERT_BACK_PATH + '/report_template.txt', 'r')
|
||||||
@@ -1200,7 +1205,7 @@ def email_reporting ():
|
|||||||
mail_text = mail_text.replace ('<REPORT_DATE>', timeFormated)
|
mail_text = mail_text.replace ('<REPORT_DATE>', timeFormated)
|
||||||
mail_html = mail_html.replace ('<REPORT_DATE>', timeFormated)
|
mail_html = mail_html.replace ('<REPORT_DATE>', timeFormated)
|
||||||
|
|
||||||
mail_text = mail_text.replace ('<SCAN_CYCLE>', cycle )
|
# mail_text = mail_text.replace ('<SCAN_CYCLE>', cycle )
|
||||||
mail_html = mail_html.replace ('<SCAN_CYCLE>', cycle )
|
mail_html = mail_html.replace ('<SCAN_CYCLE>', cycle )
|
||||||
|
|
||||||
mail_text = mail_text.replace ('<SERVER_NAME>', socket.gethostname() )
|
mail_text = mail_text.replace ('<SERVER_NAME>', socket.gethostname() )
|
||||||
|
|||||||
@@ -1,12 +1,6 @@
|
|||||||
Report Date: <REPORT_DATE>
|
Report Date: <REPORT_DATE>
|
||||||
Scan Cycle: <SCAN_CYCLE>
|
|
||||||
Server: <SERVER_NAME>
|
Server: <SERVER_NAME>
|
||||||
|
<SECTION_NEW_DEVICES>
|
||||||
<SECTION_INTERNET>
|
|
||||||
Internet
|
|
||||||
----------------------
|
|
||||||
<TABLE_INTERNET>
|
|
||||||
</SECTION_INTERNET><SECTION_NEW_DEVICES>
|
|
||||||
New Devices
|
New Devices
|
||||||
----------------------
|
----------------------
|
||||||
<TABLE_NEW_DEVICES>
|
<TABLE_NEW_DEVICES>
|
||||||
@@ -18,4 +12,8 @@ Devices Down
|
|||||||
Events
|
Events
|
||||||
----------------------
|
----------------------
|
||||||
<TABLE_EVENTS>
|
<TABLE_EVENTS>
|
||||||
</SECTION_EVENTS>
|
</SECTION_EVENTS><SECTION_INTERNET>
|
||||||
|
Internet
|
||||||
|
----------------------
|
||||||
|
<TABLE_INTERNET>
|
||||||
|
</SECTION_INTERNET>
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
VERSION = '3.5_leiweibau'
|
VERSION = '3.5_leiweibau'
|
||||||
VERSION_YEAR = '2022'
|
VERSION_YEAR = '2022'
|
||||||
VERSION_DATE = '2022-07-07'
|
VERSION_DATE = '2022-07-07'
|
||||||
TZ = 'Europe/London'
|
|
||||||
@@ -8,6 +8,13 @@
|
|||||||
// Puche 2021 pi.alert.application@gmail.com GNU GPLv3
|
// Puche 2021 pi.alert.application@gmail.com GNU GPLv3
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// ## TimeZone processing
|
||||||
|
$config_file = "../../../config/pialert.conf";
|
||||||
|
$config_file_lines = file($config_file);
|
||||||
|
$config_file_lines_timezone = array_values(preg_grep('/^TIMEZONE\s.*/', $config_file_lines));
|
||||||
|
$timezone_line = explode("'", $config_file_lines_timezone[0]);
|
||||||
|
$Pia_TimeZone = $timezone_line[1];
|
||||||
|
date_default_timezone_set($Pia_TimeZone);
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// DB File Path
|
// DB File Path
|
||||||
@@ -58,4 +65,4 @@ function OpenDB () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -7,6 +7,13 @@
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Puche 2021 pi.alert.application@gmail.com GNU GPLv3
|
// Puche 2021 pi.alert.application@gmail.com GNU GPLv3
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
// ## TimeZone processing
|
||||||
|
$config_file = "../../../config/pialert.conf";
|
||||||
|
$config_file_lines = file($config_file);
|
||||||
|
$config_file_lines_timezone = array_values(preg_grep('/^TIMEZONE\s.*/', $config_file_lines));
|
||||||
|
$timezone_line = explode("'", $config_file_lines_timezone[0]);
|
||||||
|
$Pia_TimeZone = $timezone_line[1];
|
||||||
|
date_default_timezone_set($Pia_TimeZone);
|
||||||
|
|
||||||
foreach (glob("../../../db/setting_language*") as $filename) {
|
foreach (glob("../../../db/setting_language*") as $filename) {
|
||||||
$pia_lang_selected = str_replace('setting_language_','',basename($filename));
|
$pia_lang_selected = str_replace('setting_language_','',basename($filename));
|
||||||
@@ -116,8 +123,10 @@ function getDeviceData() {
|
|||||||
$row = $result -> fetchArray (SQLITE3_NUM);
|
$row = $result -> fetchArray (SQLITE3_NUM);
|
||||||
$deviceData['dev_DownAlerts'] = $row[0];
|
$deviceData['dev_DownAlerts'] = $row[0];
|
||||||
|
|
||||||
|
// Get current date using php, sql datetime does not return time respective to timezone.
|
||||||
|
$currentdate = date("Y-m-d H:i:s");
|
||||||
// Presence hours
|
// Presence hours
|
||||||
$sql = 'SELECT CAST(( MAX (0, SUM (julianday (IFNULL (ses_DateTimeDisconnection, DATETIME("now","localtime")))
|
$sql = 'SELECT CAST(( MAX (0, SUM (julianday (IFNULL (ses_DateTimeDisconnection,"'. $currentdate .'" ))
|
||||||
- julianday (CASE WHEN ses_DateTimeConnection < '. $periodDate .' THEN '. $periodDate .'
|
- julianday (CASE WHEN ses_DateTimeConnection < '. $periodDate .' THEN '. $periodDate .'
|
||||||
ELSE ses_DateTimeConnection END)) *24 )) AS INT)
|
ELSE ses_DateTimeConnection END)) *24 )) AS INT)
|
||||||
FROM Sessions
|
FROM Sessions
|
||||||
|
|||||||
@@ -7,7 +7,13 @@
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Puche 2021 pi.alert.application@gmail.com GNU GPLv3
|
// Puche 2021 pi.alert.application@gmail.com GNU GPLv3
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
// ## TimeZone processing
|
||||||
|
$config_file = "../../../config/pialert.conf";
|
||||||
|
$config_file_lines = file($config_file);
|
||||||
|
$config_file_lines_timezone = array_values(preg_grep('/^TIMEZONE\s.*/', $config_file_lines));
|
||||||
|
$timezone_line = explode("'", $config_file_lines_timezone[0]);
|
||||||
|
$Pia_TimeZone = $timezone_line[1];
|
||||||
|
date_default_timezone_set($Pia_TimeZone);
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// External files
|
// External files
|
||||||
@@ -275,7 +281,7 @@ function getDevicePresence() {
|
|||||||
END AS ses_DateTimeConnectionCorrected,
|
END AS ses_DateTimeConnectionCorrected,
|
||||||
|
|
||||||
CASE
|
CASE
|
||||||
WHEN ses_EventTypeDisconnection = "<missing event>" THEN
|
WHEN ses_EventTypeDisconnection = "<missing event>" OR ses_EventTypeDisconnection = NULL THEN
|
||||||
(SELECT MIN(ses_DateTimeConnection) FROM Sessions AS SES2 WHERE SES2.ses_MAC = SES1.ses_MAC AND SES2.ses_DateTimeConnection > SES1.ses_DateTimeConnection)
|
(SELECT MIN(ses_DateTimeConnection) FROM Sessions AS SES2 WHERE SES2.ses_MAC = SES1.ses_MAC AND SES2.ses_DateTimeConnection > SES1.ses_DateTimeConnection)
|
||||||
ELSE ses_DateTimeDisconnection
|
ELSE ses_DateTimeDisconnection
|
||||||
END AS ses_DateTimeDisconnectionCorrected
|
END AS ses_DateTimeDisconnectionCorrected
|
||||||
|
|||||||
@@ -8,6 +8,13 @@
|
|||||||
// Puche 2021 pi.alert.application@gmail.com GNU GPLv3
|
// Puche 2021 pi.alert.application@gmail.com GNU GPLv3
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// ## TimeZone processing
|
||||||
|
$config_file = "../../../config/pialert.conf";
|
||||||
|
$config_file_lines = file($config_file);
|
||||||
|
$config_file_lines_timezone = array_values(preg_grep('/^TIMEZONE\s.*/', $config_file_lines));
|
||||||
|
$timezone_line = explode("'", $config_file_lines_timezone[0]);
|
||||||
|
$Pia_TimeZone = $timezone_line[1];
|
||||||
|
date_default_timezone_set($Pia_TimeZone);
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Formatting data functions
|
// Formatting data functions
|
||||||
|
|||||||
Reference in New Issue
Block a user