diff --git a/docs/SETTINGS_SYSTEM.md b/docs/SETTINGS_SYSTEM.md
old mode 100644
new mode 100755
diff --git a/front/php/templates/build.php b/front/php/templates/build.php
old mode 100644
new mode 100755
diff --git a/front/php/templates/language/en_us.json b/front/php/templates/language/en_us.json
index 2a07cef1..1d289470 100755
--- a/front/php/templates/language/en_us.json
+++ b/front/php/templates/language/en_us.json
@@ -271,6 +271,7 @@
"Maintenance_lang_es_es" : "Spanish (ES)",
"Maintenance_lang_selector_text" : "The change takes place on the client side, so it affects only the current browser.",
"Maintenance_lang_selector_apply" : "Apply",
+ "Maintenance_Status" : "Status",
"Maintenance_Tools_Tab_Settings" : "Settings",
"Maintenance_Tools_Tab_UISettings" : "UI Settings",
"Maintenance_Tools_Tab_Tools" : "Tools",
diff --git a/front/php/templates/version.php b/front/php/templates/version.php
old mode 100644
new mode 100755
diff --git a/front/report.php b/front/report.php
old mode 100644
new mode 100755
diff --git a/front/systeminfo.php b/front/systeminfo.php
old mode 100644
new mode 100755
index dd973b3b..be34e2d5
--- a/front/systeminfo.php
+++ b/front/systeminfo.php
@@ -371,7 +371,7 @@ for ($x = 0; $x < sizeof($hdd_devices); $x++) {
echo '
';
echo '
"' . lang('Systeminfo_Storage_Usage_Mount') . ' ' . $hdd_devices_mount[$x] . '"
';
echo '
' . lang('Systeminfo_Storage_Usage_Total') . ' ' . $temp_total . ' GB
';
- echo '
' . lang('Systeminfo_Storage_Usage_Used') . ' ' . $temp_used . ' GB (' . number_format($hdd_devices_percent[$x], 1, ',', '.') . '%)
';
+ echo '
' . lang('Systeminfo_Storage_Usage_Used') . ' ' . $temp_used . ' GB (' . $hdd_devices_percent[$x]. ')
';
echo '
' . lang('Systeminfo_Storage_Usage_Free') . ' ' . $temp_free . ' GB
';
echo '
';
}
diff --git a/pialert/plugin.py b/pialert/plugin.py
index 6d4ee50f..f61ad2bd 100755
--- a/pialert/plugin.py
+++ b/pialert/plugin.py
@@ -221,11 +221,7 @@ def execute_plugin(db, plugin, pluginsState = plugins_state() ):
# if the script produced some outpout, clean it up to ensure it's the correct format
# cleanup - select only lines containing a separator to filter out unnecessary data
- newLines = list(filter(lambda x: '|' in x, newLines))
-
- # # regular logging
- # for line in newLines:
- # append_line_to_file (pluginsPath + '/plugin.log', line +'\n')
+ newLines = list(filter(lambda x: '|' in x, newLines))
for line in newLines:
columns = line.split("|")
@@ -521,36 +517,69 @@ def process_plugin_events(db, plugin, pluginsState):
# Update the DB
# ----------------------------
# Update the Plugin_Objects
- for plugObj in pluginObjects:
-
- createdTime = plugObj.created
+ # Create lists to hold the data for bulk insertion
+ objects_to_insert = []
+ events_to_insert = []
+ for plugObj in pluginObjects:
+ createdTime = plugObj.changed if plugObj.status == 'new' else plugObj.created
+ values = (
+ plugObj.pluginPref, plugObj.primaryId, plugObj.secondaryId, createdTime,
+ plugObj.changed, plugObj.watched1, plugObj.watched2, plugObj.watched3,
+ plugObj.watched4, plugObj.status, plugObj.extra, plugObj.userData,
+ plugObj.foreignKey
+ )
+
if plugObj.status == 'new':
-
- createdTime = plugObj.changed
-
- sql.execute ("INSERT INTO Plugins_Objects (Plugin, Object_PrimaryID, Object_SecondaryID, DateTimeCreated, DateTimeChanged, Watched_Value1, Watched_Value2, Watched_Value3, Watched_Value4, Status, Extra, UserData, ForeignKey) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)", (plugObj.pluginPref, plugObj.primaryId , plugObj.secondaryId , createdTime, plugObj.changed , plugObj.watched1 , plugObj.watched2 , plugObj.watched3 , plugObj.watched4 , plugObj.status , plugObj.extra, plugObj.userData, plugObj.foreignKey ))
+ objects_to_insert.append(values)
else:
- sql.execute ("UPDATE Plugins_Objects set Plugin = ?, DateTimeChanged = ?, Watched_Value1 = ?, Watched_Value2 = ?, Watched_Value3 = ?, Watched_Value4 = ?, Status = ?, Extra = ?, ForeignKey = ? WHERE \"Index\" = ?", (plugObj.pluginPref, plugObj.changed, plugObj.watched1, plugObj.watched2, plugObj.watched3, plugObj.watched4, plugObj.status, plugObj.extra, plugObj.foreignKey, plugObj.index))
+ objects_to_insert.append(values + (plugObj.index,)) # Include index for UPDATE
- # Update the Plugins_Events with the new statuses
- sql.execute ('DELETE FROM Plugins_Events where Plugin = ?', (pluginPref,))
-
- for plugObj in pluginEvents:
-
- createdTime = plugObj.created
-
- # use the same datetime for created and changed if a new entry
if plugObj.status == 'new':
- createdTime = plugObj.changed
+ events_to_insert.append(values)
+ elif plugObj.status in get_plugin_setting_value(plugin, "REPORT_ON"):
+ events_to_insert.append(values)
- # insert only events if they are to be reported on
- if plugObj.status in get_plugin_setting_value(plugin, "REPORT_ON"):
+ # Bulk insert/update objects
+ if objects_to_insert:
+ sql.executemany(
+ """
+ INSERT INTO Plugins_Objects
+ ("Plugin", "Object_PrimaryID", "Object_SecondaryID", "DateTimeCreated",
+ "DateTimeChanged", "Watched_Value1", "Watched_Value2", "Watched_Value3",
+ "Watched_Value4", "Status", "Extra", "UserData", "ForeignKey", "Index")
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
+ ON CONFLICT("Index") DO UPDATE
+ SET "Plugin" = excluded.Plugin,
+ "DateTimeChanged" = excluded.DateTimeChanged,
+ "Watched_Value1" = excluded.Watched_Value1,
+ "Watched_Value2" = excluded.Watched_Value2,
+ "Watched_Value3" = excluded.Watched_Value3,
+ "Watched_Value4" = excluded.Watched_Value4,
+ "Status" = excluded.Status,
+ "Extra" = excluded.Extra,
+ "ForeignKey" = excluded.ForeignKey
+ """, objects_to_insert
+ )
- sql.execute ("INSERT INTO Plugins_Events (Plugin, Object_PrimaryID, Object_SecondaryID, DateTimeCreated, DateTimeChanged, Watched_Value1, Watched_Value2, Watched_Value3, Watched_Value4, Status, Extra, UserData, ForeignKey) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)", (plugObj.pluginPref, plugObj.primaryId , plugObj.secondaryId , createdTime, plugObj.changed , plugObj.watched1 , plugObj.watched2 , plugObj.watched3 , plugObj.watched4 , plugObj.status , plugObj.extra, plugObj.userData, plugObj.foreignKey ))
+ # Bulk insert events
+ if events_to_insert:
+ sql.executemany(
+ """
+ INSERT INTO Plugins_Events
+ ("Plugin", "Object_PrimaryID", "Object_SecondaryID", "DateTimeCreated",
+ "DateTimeChanged", "Watched_Value1", "Watched_Value2", "Watched_Value3",
+ "Watched_Value4", "Status", "Extra", "UserData", "ForeignKey")
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
+ """, events_to_insert
+ )
+
+ # Delete old events
+ sql.execute('DELETE FROM Plugins_Events where Plugin = ?', (pluginPref,))
+
+ # Commit changes to the database
+ db.commitDB()
- # Commit the transaction
- conn.commit()
except Exception as e:
# Rollback the transaction in case of an error
diff --git a/pialert/scheduler.py b/pialert/scheduler.py
index f61333f5..ff2685ff 100755
--- a/pialert/scheduler.py
+++ b/pialert/scheduler.py
@@ -28,15 +28,15 @@ class schedule_class:
# (maybe the following check is unnecessary:)
# if the last run is past the last time we run a scheduled Pholus scan
# if nowTime > self.last_next_schedule and self.last_run < self.last_next_schedule:
- if nowTime > self.last_next_schedule and self.last_run < self.last_next_schedule:
+ if nowTime > self.last_next_schedule:
mylog('debug',f'[Scheduler] - Scheduler run for {self.service}: YES')
self.was_last_schedule_used = True
result = True
else:
mylog('debug',f'[Scheduler] - Scheduler run for {self.service}: NO')
- mylog('debug',f'[Scheduler] - nowTime {nowTime}')
- mylog('debug',f'[Scheduler] - self.last_next_schedule {self.last_next_schedule}')
- mylog('debug',f'[Scheduler] - self.last_run {self.last_run}')
+ # mylog('debug',f'[Scheduler] - nowTime {nowTime}')
+ # mylog('debug',f'[Scheduler] - self.last_next_schedule {self.last_next_schedule}')
+ # mylog('debug',f'[Scheduler] - self.last_run {self.last_run}')
if self.was_last_schedule_used:
self.was_last_schedule_used = False