Inspector

> Updating file name to `inspector_qbitt`
This commit is contained in:
Eugene Amos 2023-12-04 13:33:06 -08:00
parent cd333fbf7e
commit 41278c17a5
2 changed files with 8 additions and 8 deletions

View File

@ -61,11 +61,11 @@ When done your folders structure should look like this: `/home/[username]/script
## Script
Get the source code from this repo and save it as `inspector.py` in the **inspector** folder created in the previous step.
Get the source code from this repo and save it as `inspector_qbitt.py` in the **inspector** folder created in the previous step.
Next we need to change the permissions of this file so that the server can read it.
1. Right click on `inspector.py` then Properties.
1. Right click on `inspector_qbitt.py` then Properties.
2. Click on `Permissions` tab at top.
@ -79,12 +79,12 @@ Next we need to change the permissions of this file so that the server can read
Now we need to test and run the script.
Make sure your terminal is open to the location of the `inspector.py` file. Should be `~/scripts/inspector`
Make sure your terminal is open to the location of the `inspector_qbitt.py` file. Should be `~/scripts/inspector`
Normally to run a Python script will would use `python3 inspector.py`
Normally to run a Python script will would use `python3 inspector_qbitt.py`
This will still work but because we have <a href="https://linuxhandbook.com/shebang" target="blank">shebang</a> set in the script we can just use
`./inspector.py`
`./inspector_qbitt.py`
You should now see `[INFO]` log with the status of the **qbittorrent** container. In the script we set the run time with `interval_seconds = 60`. This setting tells the script to check the health of the container every minute.

View File

@ -13,7 +13,7 @@ import requests
container_name = 'qbittorrent'
interval_seconds = 60
logs_folder = 'logs/qbittorrent'
logs_folder = 'logs/inspector_qbitt'
cooldown_seconds = 300
max_error_count = 5
@ -22,13 +22,13 @@ if not os.path.exists(logs_folder):
os.makedirs(logs_folder)
def get_log_file_path():
return os.path.join(logs_folder, 'qbittorrent.log')
return os.path.join(logs_folder, 'inspector_qbitt.log')
def rotate_log_files(log_file):
now = datetime.datetime.now()
timestamp = now.strftime('%Y-%m-%d')
rotated_log_file = f'{timestamp}.log'
rotated_log_file = f'qbittorrent_{timestamp}.log'
rotated_log_file = f'inspector_qbitt_{timestamp}.log'
rotated_log_path = os.path.join(logs_folder, rotated_log_file)
# Rename the current log file to the rotated log file