49 lines
1.5 KiB
Python
49 lines
1.5 KiB
Python
#################################################################################################################
|
|
##
|
|
## Python Log Analyser for Nginx ProxyManager
|
|
## Including import to Database File & Filter Option for duplicating Entrys
|
|
##
|
|
## by H4nSolo (Christian Bergs)
|
|
## Version: 0.3a
|
|
##
|
|
## Git: http://github.com/H4nSolo/Python_Log_Analyser_for_Nginx_Proxy_Manager
|
|
##
|
|
#################################################################################################################
|
|
|
|
## Import Libaries & Local Modules
|
|
import logging
|
|
from modules.class_import_dotenv import ImportDotenv
|
|
|
|
## Run Script
|
|
if __name__ == "__main__":
|
|
|
|
# Import .ENV Informations from Module
|
|
dotenv_importer = ImportDotenv()
|
|
variables = dotenv_importer.get_dotenv_vars()
|
|
|
|
# Run Main Script
|
|
try:
|
|
# Set Debug for Level 1 (Logging Mode)
|
|
if variables["LOG_MODE"] == "1":
|
|
logging.basicConfig(filename=variables['LOG_FILE'], level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
|
|
|
# Create Database (SQLite DB)
|
|
|
|
# Check SSH Connection
|
|
|
|
# Download Log Files
|
|
|
|
# Analyse Log Files (incl. Archive Log Files) & Insert into Database
|
|
# Use Regex & Filter for Duplicated Entries
|
|
|
|
|
|
|
|
except Exception as e:
|
|
if variables["LOG_MODE"] == "1":
|
|
logging.error(f"Fehler beim Ausführen des Skripts: {str(e)}")
|
|
elif variables["LOG_MODE"] == "2":
|
|
print(f"Fehler beim Ausführen des Skripts: {str(e)}")
|
|
|
|
|
|
|