diff --git a/back/pialert.py b/back/pialert.py index 61946a70..90fb7819 100755 --- a/back/pialert.py +++ b/back/pialert.py @@ -3929,8 +3929,8 @@ def process_plugin_events(plugin): index = 0 for plugObj in pluginObjects: # find corresponding object for the event and merge - if plugObj.idsHash == eveObj.idsHash: - pluginObjects[index] = combine_plugin_objects(plugObj, eveObj) + if plugObj.idsHash == eveObj.idsHash: + pluginObjects[index] = combine_plugin_objects(plugObj, eveObj) index += 1 @@ -3948,9 +3948,7 @@ def process_plugin_events(plugin): 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 )) else: - q = f"UPDATE Plugins_Objects set Plugin = '{plugObj.pluginPref}', DateTimeChanged = '{plugObj.changed}', Watched_Value1 = '{plugObj.watched1}', Watched_Value2 = '{plugObj.watched2}', Watched_Value3 = '{plugObj.watched3}', Watched_Value4 = '{plugObj.watched4}', Status = '{plugObj.status}', Extra = '{plugObj.extra}', ForeignKey = '{plugObj.foreignKey}' WHERE 'Index' = {plugObj.index}" - - sql.execute (q) + sql.execute (f"UPDATE Plugins_Objects set Plugin = '{plugObj.pluginPref}', DateTimeChanged = '{plugObj.changed}', Watched_Value1 = '{plugObj.watched1}', Watched_Value2 = '{plugObj.watched2}', Watched_Value3 = '{plugObj.watched3}', Watched_Value4 = '{plugObj.watched4}', Status = '{plugObj.status}', Extra = '{plugObj.extra}', ForeignKey = '{plugObj.foreignKey}' WHERE \"Index\" = {plugObj.index}") # Update the Plugins_Events with the new statuses sql.execute ("DELETE FROM Plugins_Events") @@ -3964,7 +3962,7 @@ def process_plugin_events(plugin): 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 )) - commitDB() + commitDB() #------------------------------------------------------------------------------- class plugin_object_class: diff --git a/docs/img/plugins.png b/docs/img/plugins.png new file mode 100755 index 00000000..c7d2d724 Binary files /dev/null and b/docs/img/plugins.png differ diff --git a/docs/img/plugins_settings.png b/docs/img/plugins_settings.png new file mode 100755 index 00000000..1b67340d Binary files /dev/null and b/docs/img/plugins_settings.png differ diff --git a/front/plugins.php b/front/plugins.php index b4674134..16b82b6a 100755 --- a/front/plugins.php +++ b/front/plugins.php @@ -64,7 +64,7 @@ function getFormControl(dbColumnDef, value, index) { result = `${value}`; break; case 'devicemac': - result = `${value}`; + result = `${value}`; break; case 'threshold': $.each(dbColumnDef.options, function(index, obj) { @@ -111,11 +111,6 @@ function saveData (id) { { showMessage('') } - - // if (result) { - // period = result; - // $('#period').val(period); - // } }); } @@ -208,10 +203,7 @@ function generateTabs() $.each(pluginDefinitions, function(index, obj) { - - - headersHtml = "" - // headers = [] + headersHtml = "" colDefinitions = [] evRows = "" obRows = "" @@ -222,7 +214,7 @@ function generateTabs() if(colDef.show == true) // select only the ones to show { colDefinitions.push(colDef) - headersHtml += `${localize(colDef, "name" )}` + headersHtml += `${localize(colDef, "name" )}` } }); @@ -247,7 +239,7 @@ function generateTabs() var histCount = 0 var histCountDisplayed = 0 - for(i=0;i= 0;i--) // from latest to the oldest { if(pluginHistory[i].Plugin == obj.unique_prefix) { @@ -377,8 +369,7 @@ function generateTabs() activetab = '' // only first tab is active }); - initTabs() - + initTabs() } // -------------------------------------------------------- diff --git a/front/plugins/README.md b/front/plugins/README.md index 832af2b4..45901b94 100755 --- a/front/plugins/README.md +++ b/front/plugins/README.md @@ -6,7 +6,7 @@ Highly experimental feature. Follow the below very carefully and check example p These issues will be hopefully fixed with time, so please don't report them. Instead, if you know how, feel free to investigate and submit a PR to fix the below. Keep the PRs small as it's easier to approve them: -* Existing plugin objects sometimes not interpreted correctly and a new object is created instead, resulting in dupliucat entries. +* Existing plugin objects sometimes not interpreted correctly and a new object is created instead, resulting in duplicate entries. * Occasional (experienced twice) hanging of processing plugin script file. * UI displaying outdated values until the API endpoints get refreshed. @@ -245,7 +245,7 @@ The UI will adjust how columns are displayed in the UI based on the definition o - The `options` property is used in conjunction with these types: - `threshold` - The `options` array contains objects from lowest `maximum` to highest with corresponding `hexColor` used for the value background color if it's less than the specified `maximum`, but more than the previous one in the `options` array - `replace` - The `options` array contains objects with an `equals` property, that is compared to the "value" and if the values are the same, the string in `replacement` is displayed in the UI instead of the actual "value" - - `devicemac` - The value is considered to be a mac adress and a link pointing to the device with teh given mac address is generated. + - `devicemac` - The value is considered to be a mac adress and a link pointing to the device with the given mac address is generated. - `url` - The value is considered to be a url so a link is generated. diff --git a/front/plugins/nmap_services/config.json b/front/plugins/nmap_services/config.json index 6ab8e50c..46a1e341 100755 --- a/front/plugins/nmap_services/config.json +++ b/front/plugins/nmap_services/config.json @@ -21,6 +21,7 @@ [ { "column": "Index", + "css_classes": "col-sm-2", "show": false, "type": "label", "default_value":"", @@ -33,6 +34,7 @@ } , { "column": "Plugin", + "css_classes": "col-sm-2", "show": false, "type": "label", "default_value":"", @@ -45,6 +47,7 @@ }, { "column": "Object_PrimaryID", + "css_classes": "col-sm-2", "show": true, "type": "label", "default_value":"", @@ -57,6 +60,7 @@ }, { "column": "Object_SecondaryID", + "css_classes": "col-sm-2", "show": true, "type": "url", "default_value":"", @@ -69,6 +73,7 @@ } , { "column": "DateTimeCreated", + "css_classes": "col-sm-2", "show": true, "type": "label", "default_value":"", @@ -81,6 +86,7 @@ }, { "column": "DateTimeChanged", + "css_classes": "col-sm-2", "show": true, "type": "label", "default_value":"", @@ -93,6 +99,7 @@ }, { "column": "Watched_Value1", + "css_classes": "col-sm-1", "show": true, "type": "label", "default_value":"", @@ -104,6 +111,7 @@ }, { "column": "Watched_Value2", + "css_classes": "col-sm-1", "show": true, "type": "label", "default_value":"", @@ -116,6 +124,7 @@ }, { "column": "Watched_Value3", + "css_classes": "col-sm-2", "show": false, "type": "label", "default_value":"", @@ -128,6 +137,7 @@ } , { "column": "Watched_Value4", + "css_classes": "col-sm-2", "show": false, "type": "label", "default_value":"", @@ -140,6 +150,7 @@ } , { "column": "Extra", + "css_classes": "col-sm-3", "show": true, "type": "label", "default_value":"", @@ -152,6 +163,7 @@ }, { "column": "ForeignKey", + "css_classes": "col-sm-2", "show": true, "type": "devicemac", "default_value":"", @@ -164,6 +176,7 @@ }, { "column": "Status", + "css_classes": "col-sm-1", "show": true, "type": "replace", "default_value":"", diff --git a/front/plugins/website_monitor/config.json b/front/plugins/website_monitor/config.json index 3b940c80..52889a17 100755 --- a/front/plugins/website_monitor/config.json +++ b/front/plugins/website_monitor/config.json @@ -14,7 +14,7 @@ }], "description": [{ "language_code":"en_us", - "string" : "This plugin is to monitor status changes of different services or websites." + "string" : "This plugin is to monitor status changes of services or websites." }], "params" : [{ "name" : "macs", @@ -35,6 +35,7 @@ [ { "column": "Index", + "css_classes": "col-sm-2", "show": false, "type": "label", "default_value":"", @@ -47,6 +48,7 @@ } , { "column": "Plugin", + "css_classes": "col-sm-2", "show": false, "type": "label", "default_value":"", @@ -59,6 +61,7 @@ }, { "column": "Object_PrimaryID", + "css_classes": "col-sm-2", "show": true, "type": "url", "default_value":"", @@ -71,6 +74,7 @@ }, { "column": "Object_SecondaryD", + "css_classes": "col-sm-2", "show": false, "type": "label", "default_value":"", @@ -83,6 +87,7 @@ } , { "column": "DateTimeCreated", + "css_classes": "col-sm-2", "show": true, "type": "label", "default_value":"", @@ -95,6 +100,7 @@ }, { "column": "DateTimeChanged", + "css_classes": "col-sm-2", "show": true, "type": "label", "default_value":"", @@ -107,6 +113,7 @@ }, { "column": "Watched_Value1", + "css_classes": "col-sm-2", "show": true, "type": "threshold", "default_value":"", @@ -140,6 +147,7 @@ }, { "column": "Watched_Value2", + "css_classes": "col-sm-2", "show": true, "type": "label", "default_value":"", @@ -152,6 +160,7 @@ }, { "column": "Watched_Value3", + "css_classes": "col-sm-2", "show": false, "type": "label", "default_value":"", @@ -164,6 +173,7 @@ } , { "column": "Watched_Value4", + "css_classes": "col-sm-2", "show": false, "type": "label", "default_value":"", @@ -176,6 +186,7 @@ } , { "column": "UserData", + "css_classes": "col-sm-2", "show": true, "type": "textboxsave", "default_value":"", @@ -188,6 +199,7 @@ }, { "column": "Status", + "css_classes": "col-sm-1", "show": true, "type": "replace", "default_value":"", @@ -213,6 +225,7 @@ }, { "column": "Extra", + "css_classes": "col-sm-3", "show": false, "type": "label", "default_value":"",