This commit is contained in:
H4nSolo committed 2024-07-03 12:13:48 +02:00
1 parent bd96d4b779
commit d09a433de5
7 files changed
+100 -1

No files matched your search

+10
View File
@@ -0,0 +1,10 @@
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
+2
View File
@@ -0,0 +1,2 @@
# Python Nginx Log Analyzer
+48 -1
View File
@@ -1 +1,48 @@
test
#################################################################################################################
##
## 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)}")
+12
View File
@@ -0,0 +1,12 @@
import sqlite3
class LogDatabase():
def __init__(self,database_host,database_username, database_password, database_name):
self.database_host = database_host
self.database_username = database_username
self.database_password = database_password
self.database_name = database_name
View File
Whitespace-only changes.
+28
View File
@@ -0,0 +1,28 @@
from dotenv import load_dotenv
import os
class ImportDotenv:
def __init__(self):
# Load Environment Variables from .env File
load_dotenv()
# Load Global Variable from .env File
self.dotenv_vars = {
# SSH Connection Variables
"REMOTE_HOST": os.getenv('REMOTE_HOST'),
"REMOTE_PORT": int(os.getenv('REMOTE_PORT')),
"REMOTE_USERNAME": os.getenv('REMOTE_USERNAME'),
"REMOTE_PASSWORD": os.getenv('REMOTE_PASSWORD'),
"REMOTE_LOG_DIR": os.getenv('REMOTE_LOG_DIR'),
"LOCAL_LOG_DIR": os.getenv('LOCAL_LOG_DIR'),
# Local Environments Variables
"DATABASE_FILE": os.getenv('DATABASE_FILE'),
"LOG_MODE": os.getenv('LOG_MODE'),
"LOG_FILE": os.getenv('LOG_FILE')
}
def get_dotenv_vars(self):
return self.dotenv_vars