mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 01:26:11 -08:00
This commit is contained in:
@@ -2,6 +2,23 @@
|
||||
|
||||
Plugin to run regular database cleanup tasks. It is strongly recommended to have an hourly or at least daily schedule running.
|
||||
|
||||
The database cleanup plugin (DBCLNP) helps maintain the system by removing outdated or unnecessary data, ensuring smooth operation. Below are the key settings that control the cleanup process:
|
||||
|
||||
- **`PLUGINS_KEEP_HIST`**:
|
||||
Specifies how many historical records to retain for each plugin. Recommended value: `500` entries.
|
||||
|
||||
- **`HRS_TO_KEEP_NEWDEV`**:
|
||||
Defines how long, in hours, newly discovered device records should be kept. Once the specified time has passed, the records will be deleted if tehy still are marked as NEW. Recommended value: `0` (no auto delete).
|
||||
|
||||
- **`DAYS_TO_KEEP_EVENTS`**:
|
||||
Specifies the number of days to retain event logs. Event entries older than the given number of days will be automatically deleted during cleanup. Recommended value: `30` days.
|
||||
|
||||
- **`PHOLUS_DAYS_DATA`**:
|
||||
Deletes all data older than specified number of days for teh Pholus plugin used for name discovery. Recommended value: `30` days.
|
||||
|
||||
By fine-tuning these settings, you ensure that the database remains optimized, preventing performance degradation in the NetAlertX system.
|
||||
|
||||
|
||||
### Usage
|
||||
|
||||
- Check the Settings page for details.
|
||||
|
||||
@@ -25,24 +25,7 @@
|
||||
"string": "A plugin to schedule database cleanup & upkeep tasks."
|
||||
}
|
||||
],
|
||||
"params": [
|
||||
{
|
||||
"name": "pluginskeephistory",
|
||||
"type": "setting",
|
||||
"value": "PLUGINS_KEEP_HIST"
|
||||
},
|
||||
{
|
||||
"name": "daystokeepevents",
|
||||
"type": "setting",
|
||||
"value": "DAYS_TO_KEEP_EVENTS"
|
||||
},
|
||||
{
|
||||
"name": "hourstokeepnewdevice",
|
||||
"type": "setting",
|
||||
"value": "HRS_TO_KEEP_NEWDEV"
|
||||
}
|
||||
],
|
||||
|
||||
"params": [],
|
||||
"settings": [
|
||||
{
|
||||
"function": "RUN",
|
||||
@@ -89,7 +72,7 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"default_value": "python3 /app/front/plugins/db_cleanup/script.py pluginskeephistory={pluginskeephistory} hourstokeepnewdevice={hourstokeepnewdevice} daystokeepevents={daystokeepevents} pholuskeepdays={pholuskeepdays}",
|
||||
"default_value": "python3 /app/front/plugins/db_cleanup/script.py",
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
@@ -150,14 +133,6 @@
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Only enabled if you select <code>schedule</code> in the <a href=\"#DBCLNP_RUN\"><code>DBCLNP_RUN</code> setting</a>. Make sure you enter the schedule in the correct cron-like format (e.g. validate at <a href=\"https://crontab.guru/\" target=\"_blank\">crontab.guru</a>). For example entering <code>0 4 * * *</code> will run the scan after 4 am in the <a onclick=\"toggleAllSettings()\" href=\"#TIMEZONE\"><code>TIMEZONE</code> you set above</a>. Will be run NEXT time the time passes."
|
||||
},
|
||||
{
|
||||
"language_code": "es_es",
|
||||
"string": "Solo está habilitado si selecciona <code>schedule</code> en la configuración <a href=\"#DBCLNP_RUN\"><code>DBCLNP_RUN</code></a>. Asegúrese de ingresar la programación en el formato similar a cron correcto (por ejemplo, valide en <a href=\"https://crontab.guru/\" target=\"_blank\">crontab.guru</a>). Por ejemplo, ingresar <code>0 4 * * *</code> ejecutará el escaneo después de las 4 a.m. en el <a onclick=\"toggleAllSettings()\" href=\"#TIMEZONE\"><code>TIMEZONE</ código> que configuró arriba</a>. Se ejecutará la PRÓXIMA vez que pase el tiempo."
|
||||
},
|
||||
{
|
||||
"language_code": "de_de",
|
||||
"string": "Nur aktiviert, wenn Sie <code>schedule</code> in der <a href=\"#DBCLNP_RUN\"><code>DBCLNP_RUN</code>-Einstellung</a> auswählen. Stellen Sie sicher, dass Sie den Zeitplan im richtigen Cron-ähnlichen Format eingeben (z. B. validieren unter <a href=\"https://crontab.guru/\" target=\"_blank\">crontab.guru</a>). Wenn Sie beispielsweise <code>0 4 * * *</code> eingeben, wird der Scan nach 4 Uhr morgens in der <a onclick=\"toggleAllSettings()\" href=\"#TIMEZONE\"><code>TIMEZONE</ ausgeführt. Code> den Sie oben festgelegt haben</a>. Wird das NÄCHSTE Mal ausgeführt, wenn die Zeit vergeht."
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -194,14 +169,6 @@
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Maximum time in seconds to wait for the script to finish. If this time is exceeded the script is aborted."
|
||||
},
|
||||
{
|
||||
"language_code": "es_es",
|
||||
"string": "Tiempo máximo en segundos para esperar a que finalice el script. Si se supera este tiempo, el script se cancela."
|
||||
},
|
||||
{
|
||||
"language_code": "de_de",
|
||||
"string": "Maximale Zeit in Sekunden, die auf den Abschluss des Skripts gewartet werden soll. Bei Überschreitung dieser Zeit wird das Skript abgebrochen."
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@@ -32,17 +32,9 @@ pluginName = 'DBCLNP'
|
||||
|
||||
def main():
|
||||
|
||||
parser = argparse.ArgumentParser(description='DB cleanup tasks')
|
||||
parser.add_argument('pluginskeephistory', action="store", help="TBC")
|
||||
parser.add_argument('hourstokeepnewdevice', action="store", help="TBC")
|
||||
parser.add_argument('daystokeepevents', action="store", help="TBC")
|
||||
parser.add_argument('pholuskeepdays', action="store", help="TBC") # unused
|
||||
|
||||
values = parser.parse_args()
|
||||
|
||||
PLUGINS_KEEP_HIST = int(values.pluginskeephistory.split('=')[1])
|
||||
HRS_TO_KEEP_NEWDEV = int(values.hourstokeepnewdevice.split('=')[1])
|
||||
DAYS_TO_KEEP_EVENTS = int(values.daystokeepevents.split('=')[1])
|
||||
PLUGINS_KEEP_HIST = int(get_setting_value("PLUGINS_KEEP_HIST"))
|
||||
HRS_TO_KEEP_NEWDEV = int(get_setting_value("HRS_TO_KEEP_NEWDEV"))
|
||||
DAYS_TO_KEEP_EVENTS = int(get_setting_value("DAYS_TO_KEEP_EVENTS"))
|
||||
PHOLUS_DAYS_DATA = get_setting_value("PHOLUS_DAYS_DATA")
|
||||
CLEAR_NEW_FLAG = get_setting_value("CLEAR_NEW_FLAG")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user