mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
Move of LOG folder from /app/front/log to app/log
This commit is contained in:
2
.github/ISSUE_TEMPLATE/i-have-an-issue.yml
vendored
2
.github/ISSUE_TEMPLATE/i-have-an-issue.yml
vendored
@@ -74,7 +74,7 @@ body:
|
||||
***Generally speaking, all bug reports should have logs provided.***
|
||||
Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in.
|
||||
Additionally, any additional info? Screenshots? References? Anything that will give us more context about the issue you are encountering!
|
||||
You can use `tail -100 /app/front/log/app.log` in the container if you have trouble getting to the log files.
|
||||
You can use `tail -100 /app/log/app.log` in the container if you have trouble getting to the log files.
|
||||
validations:
|
||||
required: false
|
||||
- type: checkboxes
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -7,6 +7,7 @@ db/*
|
||||
db/pialert.db
|
||||
db/app.db
|
||||
front/log/*
|
||||
/log/*
|
||||
front/api/*
|
||||
/api/*
|
||||
**/plugins/**/*.log
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
export INSTALL_DIR=/app
|
||||
|
||||
LOG_FILE="${INSTALL_DIR}/front/log/execution_queue.log"
|
||||
LOG_FILE="${INSTALL_DIR}/log/execution_queue.log"
|
||||
|
||||
# Check if there are any entries with cron_restart_backend
|
||||
if grep -q "cron_restart_backend" "$LOG_FILE"; then
|
||||
|
||||
@@ -16,7 +16,7 @@ services:
|
||||
# - ${APP_DATA_LOCATION}/netalertx_dev/db:/app/db
|
||||
- ${APP_DATA_LOCATION}/netalertx/db:/app/db
|
||||
# (optional) useful for debugging if you have issues setting up the container
|
||||
# - ${LOGS_LOCATION}:/app/front/log
|
||||
# - ${LOGS_LOCATION}:/app/log
|
||||
# ---------------------------------------------------------------------------
|
||||
# DELETE START anyone trying to use this file: comment out / delete BELOW lines, they are only for development purposes
|
||||
- ${APP_DATA_LOCATION}/netalertx/dhcp_samples/dhcp1.leases:/mnt/dhcp1.leases
|
||||
|
||||
@@ -55,7 +55,7 @@ docker run -d --rm --network=host \
|
||||
| :------------- | :------------- | :-------------|
|
||||
| ✅ | `:/app/config` | Folder which will contain the `app.conf` & `devices.csv` ([read about devices.csv](https://github.com/jokob-sk/NetAlertX/blob/main/docs/DEVICES_BULK_EDITING.md)) files (see below for details). |
|
||||
| ✅ | `:/app/db` | Folder which will contain the `app.db` file |
|
||||
| | `:/app/front/log` | Logs folder useful for debugging if you have issues setting up the container |
|
||||
| | `:/app/log` | Logs folder useful for debugging if you have issues setting up the container |
|
||||
| | `:/etc/pihole/pihole-FTL.db` | PiHole's `pihole-FTL.db` database file. Required if you want to use PiHole DB mapping. |
|
||||
| | `:/etc/pihole/dhcp.leases` | PiHole's `dhcp.leases` file. Required if you want to use PiHole `dhcp.leases` file. This has to be matched with a corresponding `DHCPLSS_paths_to_check` setting entry (the path in the container must contain `pihole`)|
|
||||
| | `:/app/api` | A simple [API endpoint](https://github.com/jokob-sk/NetAlertX/blob/main/docs/API.md) containing static (but regularly updated) json and other files. |
|
||||
@@ -129,7 +129,7 @@ services:
|
||||
- local/path/config:/app/config
|
||||
- local/path/db:/app/db
|
||||
# (optional) useful for debugging if you have issues setting up the container
|
||||
- local/path/logs:/app/front/log
|
||||
- local/path/logs:/app/log
|
||||
environment:
|
||||
- TZ=Europe/Berlin
|
||||
- PORT=20211
|
||||
@@ -178,7 +178,7 @@ services:
|
||||
- ${APP_DATA_LOCATION}/netalertx/config:/app/config
|
||||
- ${APP_DATA_LOCATION}/netalertx/db/:/app/db/
|
||||
# (optional) useful for debugging if you have issues setting up the container
|
||||
- ${LOGS_LOCATION}:/app/front/log
|
||||
- ${LOGS_LOCATION}:/app/log
|
||||
environment:
|
||||
- TZ=${TZ}
|
||||
- PORT=${PORT}
|
||||
|
||||
@@ -106,15 +106,15 @@ fi
|
||||
|
||||
# Create an empty log files
|
||||
# Create the execution_queue.log and app_front.log files if they don't exist
|
||||
touch "${INSTALL_DIR}"/front/log/{app.log,execution_queue.log,app_front.log,app.php_errors.log,stderr.log,stdout.log,db_is_locked.log}
|
||||
touch "${INSTALL_DIR}"/log/{app.log,execution_queue.log,app_front.log,app.php_errors.log,stderr.log,stdout.log,db_is_locked.log}
|
||||
touch "${INSTALL_DIR}"/api/user_notifications.json
|
||||
|
||||
echo "[INSTALL] Fixing permissions after copied starter config & DB"
|
||||
chown -R nginx:www-data "${INSTALL_DIR}"/{config,front/log,db,api}
|
||||
chown -R nginx:www-data "${INSTALL_DIR}"/{config,log,db,api}
|
||||
chown -R nginx:www-data "${INSTALL_DIR}"/api/user_notifications.json
|
||||
|
||||
chmod 750 "${INSTALL_DIR}"/{config,front/log,db}
|
||||
find "${INSTALL_DIR}"/{config,front/log,db} -type f -exec chmod 640 {} \;
|
||||
chmod 750 "${INSTALL_DIR}"/{config,log,db}
|
||||
find "${INSTALL_DIR}"/{config,log,db} -type f -exec chmod 640 {} \;
|
||||
|
||||
# Check if buildtimestamp.txt doesn't exist
|
||||
if [ ! -f "${INSTALL_DIR}/front/buildtimestamp.txt" ]; then
|
||||
|
||||
@@ -64,7 +64,7 @@ Sometimes specific log sections are needed to debug issues. The Devices and Curr
|
||||
|
||||
### Permissions
|
||||
|
||||
* If facing issues (AJAX errors, can't write to DB, empty screen, etc,) make sure permissions are set correctly, and check the logs under `/app/front/log`.
|
||||
* If facing issues (AJAX errors, can't write to DB, empty screen, etc,) make sure permissions are set correctly, and check the logs under `/app/log`.
|
||||
* To solve permission issues you can try setting the owner and group of the `app.db` by executing the following on the host system: `docker exec netalertx chown -R www-data:www-data /app/db/app.db`.
|
||||
* If still facing issues, try to map the app.db file (⚠ not folder) to `:/app/db/app.db` (see [docker-compose Examples](https://github.com/jokob-sk/NetAlertX/blob/main/dockerfiles/README.md#-docker-composeyml-examples) for details)
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ services:
|
||||
- local/path/config:/app/config # ⚠ This has changed (🔺required)
|
||||
- local/path/db:/app/db # ⚠ This has changed (🔺required)
|
||||
# (optional) useful for debugging if you have issues setting up the container
|
||||
- local/path/logs:/app/front/log # ⚠ This has changed (🟡optional)
|
||||
- local/path/logs:/app/log # ⚠ This has changed (🟡optional)
|
||||
environment:
|
||||
- TZ=Europe/Berlin
|
||||
- PORT=20211
|
||||
@@ -135,7 +135,7 @@ services:
|
||||
- local/path/config/app.conf:/app/config/app.conf # ⚠ This has changed (🔺required)
|
||||
- local/path/db/app.db:/app/db/app.db # ⚠ This has changed (🔺required)
|
||||
# (optional) useful for debugging if you have issues setting up the container
|
||||
- local/path/logs:/app/front/log # ⚠ This has changed (🟡optional)
|
||||
- local/path/logs:/app/log # ⚠ This has changed (🟡optional)
|
||||
environment:
|
||||
- TZ=Europe/Berlin
|
||||
- PORT=20211
|
||||
|
||||
@@ -40,7 +40,7 @@ services:
|
||||
volumes:
|
||||
- /home/netalertx/config:/app/config
|
||||
- /home/netalertx/db:/app/db
|
||||
- /home/netalertx/log:/app/front/log
|
||||
- /home/netalertx/log:/app/log
|
||||
environment:
|
||||
- TZ=Europe/Berlin
|
||||
- PORT=20211
|
||||
@@ -66,7 +66,7 @@ services:
|
||||
volumes:
|
||||
- ./config/app.conf:/app/config/app.conf
|
||||
- ./db:/app/db
|
||||
- ./log:/app/front/log
|
||||
- ./log:/app/log
|
||||
- ./config/resolv.conf:/etc/resolv.conf # Mapping the /resolv.conf file for better name resolution
|
||||
environment:
|
||||
- TZ=Europe/Berlin
|
||||
|
||||
@@ -43,7 +43,7 @@ services:
|
||||
- local/path/config:/app/config
|
||||
- local/path/db:/app/db
|
||||
# (optional) useful for debugging if you have issues setting up the container
|
||||
- local/path/logs:/app/front/log
|
||||
- local/path/logs:/app/log
|
||||
environment:
|
||||
- TZ=Europe/Berlin
|
||||
- PORT=20211
|
||||
@@ -60,7 +60,7 @@ services:
|
||||
- /volume1/app_storage/netalertx/config:/app/config
|
||||
- /volume1/app_storage/netalertx/db:/app/db
|
||||
# (optional) useful for debugging if you have issues setting up the container
|
||||
# - local/path/logs:/app/front/log <- commented out with # ⚠
|
||||
# - local/path/logs:/app/log <- commented out with # ⚠
|
||||
```
|
||||
|
||||

|
||||
|
||||
@@ -41,7 +41,7 @@ In the container execute:
|
||||
|
||||
`cat /var/log/nginx/error.log`
|
||||
|
||||
`cat /app/front/log/app.php_errors.log`
|
||||
`cat /app/log/app.php_errors.log`
|
||||
|
||||
## 8. Make sure permissions are correct
|
||||
|
||||
|
||||
@@ -780,7 +780,7 @@ function handleLoadingDialog(needsReload = false)
|
||||
// console.log('needsReload:');
|
||||
// console.log(needsReload);
|
||||
|
||||
$.get('log/execution_queue.log?nocache=' + Date.now(), function(data) {
|
||||
$.get('/php/server/query_logs.php?file=execution_queue.log&nocache=' + Date.now(), function(data) {
|
||||
|
||||
if(data.includes("update_api|devices"))
|
||||
{
|
||||
|
||||
@@ -85,7 +85,7 @@ function renderList(
|
||||
// Check if database is locked
|
||||
function checkDbLock() {
|
||||
$.ajax({
|
||||
url: "log/db_is_locked.log", // Replace with the actual path to your PHP file
|
||||
url: "/php/server/query_logs.php?file=db_is_locked.log",
|
||||
type: "GET",
|
||||
|
||||
success: function (response) {
|
||||
|
||||
@@ -314,7 +314,7 @@ function updateModalState() {
|
||||
setTimeout(function() {
|
||||
// Fetch the content from the log file using an AJAX request
|
||||
$.ajax({
|
||||
url: '/log/execution_queue.log',
|
||||
url: '/php/server/query_logs.php?file=execution_queue.log',
|
||||
type: 'GET',
|
||||
success: function(data) {
|
||||
// Update the content of the HTML element (e.g., a div with id 'logContent')
|
||||
|
||||
@@ -20,12 +20,12 @@ function renderLogArea($params) {
|
||||
$content = file_get_contents($filePath);
|
||||
}
|
||||
|
||||
// Prepare the download button HTML if filePath starts with /app/front
|
||||
// Prepare the download button HTML if filePath starts with /app
|
||||
$downloadButtonHtml = '';
|
||||
if (strpos($filePath, '/app/front') === 0) {
|
||||
if (strpos($filePath, '/app') === 0) {
|
||||
$downloadButtonHtml = '
|
||||
<span class="span-padding">
|
||||
<a href="' . htmlspecialchars(str_replace('/app/front', '', $filePath)) . '" target="_blank">
|
||||
<a href="' . htmlspecialchars(str_replace('/app/log/', '/php/server/query_logs.php?file=', $filePath)) . '" target="_blank">
|
||||
<i class="fa fa-download"></i>
|
||||
</a>
|
||||
</span>';
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
}
|
||||
],
|
||||
"fileName": "app.log",
|
||||
"filePath": "/app/front/log/app.log",
|
||||
"filePath": "/app/log/app.log",
|
||||
"textAreaCssClass": "logs"
|
||||
|
||||
},
|
||||
@@ -23,7 +23,7 @@
|
||||
}
|
||||
],
|
||||
"fileName": "app_front.log",
|
||||
"filePath": "/app/front/log/app_front.log",
|
||||
"filePath": "/app/log/app_front.log",
|
||||
"textAreaCssClass": "logs logs-small"
|
||||
},
|
||||
{
|
||||
@@ -34,7 +34,7 @@
|
||||
}
|
||||
],
|
||||
"fileName": "app.php_errors.log",
|
||||
"filePath": "/app/front/log/app.php_errors.log",
|
||||
"filePath": "/app/log/app.php_errors.log",
|
||||
"textAreaCssClass": "logs logs-small"
|
||||
},
|
||||
{
|
||||
@@ -45,7 +45,7 @@
|
||||
}
|
||||
],
|
||||
"fileName": "execution_queue.log",
|
||||
"filePath": "/app/front/log/execution_queue.log",
|
||||
"filePath": "/app/log/execution_queue.log",
|
||||
"textAreaCssClass": "logs logs-small"
|
||||
},
|
||||
{
|
||||
@@ -55,17 +55,6 @@
|
||||
"filePath": "/var/log/nginx/error.log",
|
||||
"textAreaCssClass": "logs logs-small"
|
||||
},
|
||||
{
|
||||
"buttons": [
|
||||
{
|
||||
"labelStringCode": "Maint_PurgeLog",
|
||||
"event": "logManage('app_front.log', 'cleanLog')"
|
||||
}
|
||||
],
|
||||
"fileName": "app_front.log",
|
||||
"filePath": "/app/front/log/app_front.log",
|
||||
"textAreaCssClass": "logs logs-small"
|
||||
},
|
||||
{
|
||||
"buttons": [
|
||||
{
|
||||
@@ -74,7 +63,7 @@
|
||||
}
|
||||
],
|
||||
"fileName": "db_is_locked.log",
|
||||
"filePath": "/app/front/log/db_is_locked.log",
|
||||
"filePath": "/app/log/db_is_locked.log",
|
||||
"textAreaCssClass": "logs logs-small"
|
||||
},
|
||||
{
|
||||
@@ -85,7 +74,7 @@
|
||||
}
|
||||
],
|
||||
"fileName": "stdout.log",
|
||||
"filePath": "/app/front/log/stdout.log",
|
||||
"filePath": "/app/log/stdout.log",
|
||||
"textAreaCssClass": "logs logs-small"
|
||||
},
|
||||
{
|
||||
@@ -96,7 +85,7 @@
|
||||
}
|
||||
],
|
||||
"fileName": "stderr.log",
|
||||
"filePath": "/app/front/log/stderr.log",
|
||||
"filePath": "/app/log/stderr.log",
|
||||
"textAreaCssClass": "logs logs-small"
|
||||
}
|
||||
]
|
||||
@@ -11,7 +11,7 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// DB File Path
|
||||
$DBFILE = dirname(__FILE__).'/../../../db/app.db';
|
||||
$DBFILE_LOCKED_FILE = dirname(__FILE__).'/../../../front/log/db_is_locked.log';
|
||||
$DBFILE_LOCKED_FILE = dirname(__FILE__).'/../../../log/db_is_locked.log';
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// check if authenticated
|
||||
|
||||
38
front/php/server/query_logs.php
Normal file
38
front/php/server/query_logs.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
// ---- IMPORTS ----
|
||||
//------------------------------------------------------------------------------
|
||||
// Check if authenticated
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/php/templates/security.php';
|
||||
// Get init.php
|
||||
require dirname(__FILE__).'/../server/init.php';
|
||||
// ---- IMPORTS ----
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Handle incoming requests
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
// Get query string parameter ?file=settings_table.json
|
||||
$file = isset($_GET['file']) ? $_GET['file'] : null;
|
||||
|
||||
// Check if file parameter is provided
|
||||
if ($file) {
|
||||
// Define the folder where files are located
|
||||
$filePath = "/app/log/" . basename($file);
|
||||
|
||||
// Check if the file exists
|
||||
if (file_exists($filePath)) {
|
||||
// Send the response back to the client
|
||||
header('Content-Type: text/plain');
|
||||
echo file_get_contents($filePath);
|
||||
} else {
|
||||
// File not found response
|
||||
http_response_code(404);
|
||||
echo json_encode(["error" => "File not found"]);
|
||||
}
|
||||
} else {
|
||||
// Missing file parameter response
|
||||
http_response_code(400);
|
||||
echo json_encode(["error" => "Missing 'file' parameter"]);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
$configFolderPath = dirname(__FILE__)."/../../../config/";
|
||||
$config_file = "app.conf";
|
||||
$logFolderPath = dirname(__FILE__)."/../../log/";
|
||||
$logFolderPath = "/app/log/";
|
||||
$log_file = "app_front.log";
|
||||
|
||||
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
|
||||
# Schedule cron jobs
|
||||
* * * * * /app/back/cron_script.sh
|
||||
#* * * * * echo "$(date +'%Y-%m-%d %H:%M:%S') - Cron job ran" >> /app/front/log/cron_timestamp.log
|
||||
#* * * * * echo "$(date +'%Y-%m-%d %H:%M:%S') - Cron job ran" >> /app/log/cron_timestamp.log
|
||||
|
||||
@@ -99,7 +99,7 @@ fi
|
||||
# Create an empty log files
|
||||
|
||||
# Create the execution_queue.log file if it doesn't exist
|
||||
touch "${INSTALL_DIR}"/front/log/{app.log,execution_queue.log,app_front.log,app.php_errors.log,stderr.log,stdout.log,db_is_locked.log}
|
||||
touch "${INSTALL_DIR}"/log/{app.log,execution_queue.log,app_front.log,app.php_errors.log,stderr.log,stdout.log,db_is_locked.log}
|
||||
touch "${INSTALL_DIR}"/api/{user_notifications.json}
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ chmod -R a+rwx $WEB_UI_DIR
|
||||
|
||||
echo "[INSTALL] Fixing INSTALL_DIR: ${INSTALL_DIR}"
|
||||
|
||||
chmod -R a+rw $INSTALL_PATH/front/log
|
||||
chmod -R a+rw $INSTALL_PATH/log
|
||||
chmod -R a+rwx $INSTALL_DIR
|
||||
|
||||
echo "[INSTALL] Copy starter $DB_FILE and $CONF_FILE if they don't exist"
|
||||
|
||||
0
front/log/.gitignore → log/.gitignore
vendored
0
front/log/.gitignore → log/.gitignore
vendored
@@ -7,13 +7,11 @@ applicationPath = '/app'
|
||||
dbFileName = 'app.db'
|
||||
confFileName = 'app.conf'
|
||||
confPath = "/config/" + confFileName
|
||||
|
||||
dbPath = '/db/' + dbFileName
|
||||
|
||||
|
||||
pluginsPath = applicationPath + '/front/plugins'
|
||||
logPath = applicationPath + '/front/log'
|
||||
# apiPath = applicationPath + '/api/'
|
||||
logPath = applicationPath + '/log'
|
||||
apiPath = applicationPath + '/api/'
|
||||
reportTemplatesPath = applicationPath + '/front/report_templates/'
|
||||
fullConfFolder = applicationPath + '/config'
|
||||
|
||||
@@ -115,8 +115,7 @@ class Query(ObjectType):
|
||||
device["devParentChildrenCount"] = get_number_of_children(device["devMac"], devices_data)
|
||||
device["devIpLong"] = format_ip_long(device.get("devLastIP", ""))
|
||||
|
||||
total_count = len(devices_data)
|
||||
|
||||
|
||||
mylog('none', f'[graphql_schema] devices_data: {devices_data}')
|
||||
|
||||
|
||||
@@ -161,14 +160,7 @@ class Query(ObjectType):
|
||||
elif status == "offline":
|
||||
devices_data = [device for device in devices_data if device["devPresentLastScan"] == 0]
|
||||
|
||||
# sorting
|
||||
if options.sort:
|
||||
for sort_option in options.sort:
|
||||
devices_data = sorted(
|
||||
devices_data,
|
||||
key=lambda x: mixed_type_sort_key(x.get(sort_option.field)),
|
||||
reverse=(sort_option.order.lower() == "desc")
|
||||
)
|
||||
|
||||
|
||||
# Filter data if a search term is provided
|
||||
if options.search:
|
||||
@@ -189,6 +181,18 @@ class Query(ObjectType):
|
||||
)
|
||||
]
|
||||
|
||||
# sorting
|
||||
if options.sort:
|
||||
for sort_option in options.sort:
|
||||
devices_data = sorted(
|
||||
devices_data,
|
||||
key=lambda x: mixed_type_sort_key(x.get(sort_option.field)),
|
||||
reverse=(sort_option.order.lower() == "desc")
|
||||
)
|
||||
|
||||
# capture total count after all the filtering and searching
|
||||
total_count = len(devices_data)
|
||||
|
||||
# Then apply pagination
|
||||
if options.page and options.limit:
|
||||
start = (options.page - 1) * options.limit
|
||||
|
||||
Reference in New Issue
Block a user