mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 01:26:11 -08:00
Docs, small fixes
This commit is contained in:
@@ -22,7 +22,7 @@ If direct scans are not possible (Wi-Fi Extenders, VPNs and inaccessible network
|
|||||||
|
|
||||||
* **Examples for one and two subnets:**
|
* **Examples for one and two subnets:**
|
||||||
* One subnet: `SCAN_SUBNETS = ['192.168.1.0/24 --interface=eth0']`
|
* One subnet: `SCAN_SUBNETS = ['192.168.1.0/24 --interface=eth0']`
|
||||||
* Two subnets: `SCAN_SUBNETS = ['192.168.1.0/24 --interface=eth0','192.168.1.0/24 --interface=eth1 -vlan=107']`
|
* Two subnets: `SCAN_SUBNETS = ['192.168.1.0/24 --interface=eth0','192.168.1.0/24 --interface=eth1 --vlan=107']`
|
||||||
|
|
||||||
If you get timeout messages, decrease the network mask (e.g.: from `/16` to `/24`) or increase the `TIMEOUT` setting (e.g.: `ARPSCAN_RUN_TIMEOUT` to `300` (5-minute timeout)) for the plugin and the interval between scans (e.g.: `ARPSCAN_RUN_SCHD` to `*/10 * * * *` (scans every 10 minutes)).
|
If you get timeout messages, decrease the network mask (e.g.: from `/16` to `/24`) or increase the `TIMEOUT` setting (e.g.: `ARPSCAN_RUN_TIMEOUT` to `300` (5-minute timeout)) for the plugin and the interval between scans (e.g.: `ARPSCAN_RUN_SCHD` to `*/10 * * * *` (scans every 10 minutes)).
|
||||||
|
|
||||||
@@ -89,7 +89,6 @@ By default, Hyper-V only allows untagged packets through to the VM interface, bl
|
|||||||
2. Within the VM, set up sub-interfaces for each VLAN to enable scanning. On Ubuntu 22.04, Netplan can be used. In /etc/netplan/00-installer-config.yaml, add VLAN definitions:
|
2. Within the VM, set up sub-interfaces for each VLAN to enable scanning. On Ubuntu 22.04, Netplan can be used. In /etc/netplan/00-installer-config.yaml, add VLAN definitions:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
|
|
||||||
network:
|
network:
|
||||||
ethernets:
|
ethernets:
|
||||||
eth0:
|
eth0:
|
||||||
|
|||||||
@@ -201,35 +201,61 @@ function mapIndx(oldIndex)
|
|||||||
// Query total numbers of Devices by status
|
// Query total numbers of Devices by status
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
function getDevicesTotals() {
|
function getDevicesTotals() {
|
||||||
|
maxDelay = 180; //cap at 180 seconds
|
||||||
|
|
||||||
// Fetch data via AJAX
|
let maxRetries = Math.ceil(Math.log2(maxDelay)); // Calculate maximum retries to cap at maxDelay seconds
|
||||||
$.ajax({
|
let attempt = 0;
|
||||||
url: '/php/server/query_json.php',
|
let calledUpdateAPI = false;
|
||||||
type: "GET",
|
|
||||||
dataType: "json",
|
|
||||||
data: {
|
|
||||||
file: 'table_devices_tiles.json', // Pass the file parameter
|
|
||||||
nocache: Date.now() // Prevent caching with a timestamp
|
|
||||||
},
|
|
||||||
success: function(response) {
|
|
||||||
if (response && response.data) {
|
|
||||||
resultJSON = response.data[0]; // Assuming the structure {"data": [ ... ]}
|
|
||||||
|
|
||||||
// Save the result to cache
|
|
||||||
setCache("getDevicesTotals", JSON.stringify(resultJSON));
|
|
||||||
|
|
||||||
// Process the fetched data
|
function fetchDataWithBackoff() {
|
||||||
processDeviceTotals(resultJSON);
|
// Calculate the delay (2^attempt seconds, capped at maxDelay seconds)
|
||||||
} else {
|
const delay = Math.min(2 ** attempt, maxDelay) * 1000;
|
||||||
console.error("Invalid response format from API");
|
|
||||||
}
|
|
||||||
},
|
|
||||||
error: function(xhr, status, error) {
|
|
||||||
console.error("Failed to fetch devices data:", error);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
// Attempt to fetch data
|
||||||
|
$.ajax({
|
||||||
|
url: '/php/server/query_json.php',
|
||||||
|
type: "GET",
|
||||||
|
dataType: "json",
|
||||||
|
data: {
|
||||||
|
file: 'table_devices_tiles.json', // Pass the file parameter
|
||||||
|
nocache: Date.now() // Prevent caching with a timestamp
|
||||||
|
},
|
||||||
|
success: function(response) {
|
||||||
|
if (response && response.data) {
|
||||||
|
const resultJSON = response.data[0]; // Assuming the structure {"data": [ ... ]}
|
||||||
|
|
||||||
|
// Save the result to cache
|
||||||
|
setCache("getDevicesTotals", JSON.stringify(resultJSON));
|
||||||
|
|
||||||
|
// Process the fetched data
|
||||||
|
processDeviceTotals(resultJSON);
|
||||||
|
} else {
|
||||||
|
console.error("Invalid response format from API");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function(xhr, status, error) {
|
||||||
|
console.error("Failed to fetch devices data (Attempt " + (attempt + 1) + "):", error);
|
||||||
|
|
||||||
|
// try updating the API once
|
||||||
|
if(calledUpdateAPI == false)
|
||||||
|
{
|
||||||
|
calledUpdateAPI = true;
|
||||||
|
updateApi("devices_tiles");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retry logic
|
||||||
|
if (attempt < maxRetries) {
|
||||||
|
attempt++;
|
||||||
|
setTimeout(fetchDataWithBackoff, delay);
|
||||||
|
} else {
|
||||||
|
console.error("Maximum retries reached. Unable to fetch devices data.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start the first fetch attempt
|
||||||
|
fetchDataWithBackoff();
|
||||||
}
|
}
|
||||||
|
|
||||||
function processDeviceTotals(devicesData) {
|
function processDeviceTotals(devicesData) {
|
||||||
|
|||||||
@@ -10,8 +10,12 @@
|
|||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// DB File Path
|
// DB File Path
|
||||||
$DBFILE = dirname(__FILE__).'/../../../db/app.db';
|
// $DBFILE = dirname(__FILE__).'/../../../db/app.db';
|
||||||
$DBFILE_LOCKED_FILE = dirname(__FILE__).'/../../../log/db_is_locked.log';
|
// $DBFILE_LOCKED_FILE = dirname(__FILE__).'/../../../log/db_is_locked.log';
|
||||||
|
$scriptDir = realpath(dirname(__FILE__)); // Resolves symlinks to the actual physical path
|
||||||
|
$DBFILE = $scriptDir . '/../../../db/app.db';
|
||||||
|
$DBFILE_LOCKED_FILE = $scriptDir . '/../../../log/db_is_locked.log';
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// check if authenticated
|
// check if authenticated
|
||||||
@@ -32,6 +36,14 @@ function SQLite3_connect($trytoreconnect = true, $retryCount = 0) {
|
|||||||
global $db_locked;
|
global $db_locked;
|
||||||
$db_locked = false;
|
$db_locked = false;
|
||||||
|
|
||||||
|
if (!file_exists($DBFILE)) {
|
||||||
|
die("Database file not found: $DBFILE");
|
||||||
|
}
|
||||||
|
if (!file_exists(dirname($DBFILE_LOCKED_FILE))) {
|
||||||
|
die("Log directory not found: " . dirname($DBFILE_LOCKED_FILE));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Write unlock status to the locked file
|
// Write unlock status to the locked file
|
||||||
file_put_contents($DBFILE_LOCKED_FILE, '0');
|
file_put_contents($DBFILE_LOCKED_FILE, '0');
|
||||||
|
|
||||||
@@ -70,7 +82,7 @@ class CustomDatabaseWrapper {
|
|||||||
private $maxRetries;
|
private $maxRetries;
|
||||||
private $retryDelay;
|
private $retryDelay;
|
||||||
|
|
||||||
public function __construct($filename, $flags = SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE, $maxRetries = 10, $retryDelay = 1000, $encryptionKey = null) {
|
public function __construct($filename, $flags = SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE, $maxRetries = 3, $retryDelay = 1000, $encryptionKey = null) {
|
||||||
$this->sqlite = new SQLite3($filename, $flags, $encryptionKey);
|
$this->sqlite = new SQLite3($filename, $flags, $encryptionKey);
|
||||||
$this->maxRetries = $maxRetries;
|
$this->maxRetries = $maxRetries;
|
||||||
$this->retryDelay = $retryDelay;
|
$this->retryDelay = $retryDelay;
|
||||||
@@ -116,7 +128,7 @@ class CustomDatabaseWrapper {
|
|||||||
file_put_contents($DBFILE_LOCKED_FILE, '0');
|
file_put_contents($DBFILE_LOCKED_FILE, '0');
|
||||||
|
|
||||||
$message = 'Error executing query (attempts: ' . $attempts . '), query: ' . $query;
|
$message = 'Error executing query (attempts: ' . $attempts . '), query: ' . $query;
|
||||||
write_notification($message);
|
// write_notification($message);
|
||||||
error_log("Query failed after {$this->maxRetries} attempts: " . $this->sqlite->lastErrorMsg());
|
error_log("Query failed after {$this->maxRetries} attempts: " . $this->sqlite->lastErrorMsg());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"API_CUSTOM_SQL_description": "You can specify a custom SQL query which will generate a JSON file and then expose it via the <a href=\"/api/table_custom_endpoint.json\" target=\"_blank\"><code>table_custom_endpoint.json</code> file endpoint</a>.",
|
"API_CUSTOM_SQL_description": "You can specify a custom SQL query which will generate a JSON file and then expose it via the <a href=\"/api/table_custom_endpoint.json\" target=\"_blank\"><code>table_custom_endpoint.json</code> file endpoint</a>.",
|
||||||
"API_CUSTOM_SQL_name": "Custom endpoint",
|
"API_CUSTOM_SQL_name": "Custom endpoint",
|
||||||
"API_TOKEN_description": "API token for secure communication. Generate one or enter any value. It's sent in the request header and used in the <code>SYNC</code> plugin, GraphQL server and other API endpoints. You can use the API endpoints to create custom integrations as descibed in the a href=\"https://github.com/jokob-sk/NetAlertX/blob/main/docs/API.md\" target=\"_blank\">API documentation</a>.",
|
"API_TOKEN_description": "API token for secure communication. Generate one or enter any value. It's sent in the request header and used in the <code>SYNC</code> plugin, GraphQL server and other API endpoints. You can use the API endpoints to create custom integrations as descibed in the <a href=\"https://github.com/jokob-sk/NetAlertX/blob/main/docs/API.md\" target=\"_blank\">API documentation</a>.",
|
||||||
"API_TOKEN_name": "API token",
|
"API_TOKEN_name": "API token",
|
||||||
"API_display_name": "API",
|
"API_display_name": "API",
|
||||||
"API_icon": "<i class=\"fa fa-arrow-down-up-across-line\"></i>",
|
"API_icon": "<i class=\"fa fa-arrow-down-up-across-line\"></i>",
|
||||||
|
|||||||
2
front/php/templates/language/it_it.json
Normal file → Executable file
2
front/php/templates/language/it_it.json
Normal file → Executable file
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"API_CUSTOM_SQL_description": "Puoi specificare una query SQL personalizzata che genererà un file JSON e quindi lo esporrà tramite l'<a href=\"/api/table_custom_endpoint.json\" target=\"_blank\"><code>table_custom_endpoint.json</code>endpoint del file</a>.",
|
"API_CUSTOM_SQL_description": "Puoi specificare una query SQL personalizzata che genererà un file JSON e quindi lo esporrà tramite l'<a href=\"/api/table_custom_endpoint.json\" target=\"_blank\"><code>table_custom_endpoint.json</code>endpoint del file</a>.",
|
||||||
"API_CUSTOM_SQL_name": "Endpoint personalizzato",
|
"API_CUSTOM_SQL_name": "Endpoint personalizzato",
|
||||||
"API_TOKEN_description": "Token API per comunicazioni sicure. Generane uno o inserisci un valore qualsiasi. Viene inviato nell'intestazione della richiesta e utilizzato nel plugin <code>SYNC</code>, nel server GraphQL e in altri endpoint API. Puoi utilizzare gli endpoint API per creare integrazioni personalizzate come descritto nella a href=\"https://github.com/jokob-sk/NetAlertX/blob/main/docs/API.md\" target=\"_blank\">documentazione API</a>.",
|
"API_TOKEN_description": "Token API per comunicazioni sicure. Generane uno o inserisci un valore qualsiasi. Viene inviato nell'intestazione della richiesta e utilizzato nel plugin <code>SYNC</code>, nel server GraphQL e in altri endpoint API. Puoi utilizzare gli endpoint API per creare integrazioni personalizzate come descritto nella <a href=\"https://github.com/jokob-sk/NetAlertX/blob/main/docs/API.md\" target=\"_blank\">documentazione API</a>.",
|
||||||
"API_TOKEN_name": "Token API",
|
"API_TOKEN_name": "Token API",
|
||||||
"API_display_name": "API",
|
"API_display_name": "API",
|
||||||
"API_icon": "<i class=\"fa fa-arrow-down-up-across-line\"></i>",
|
"API_icon": "<i class=\"fa fa-arrow-down-up-across-line\"></i>",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"API_CUSTOM_SQL_description": "Вы можете указать собственный SQL-запрос, который будет генерировать файл JSON, а затем предоставлять его через конечную точку файла <a href=\"/api/table_custom_endpoint.json\" target=\"_blank\"><code>table_custom_endpoint.json</code></a>.",
|
"API_CUSTOM_SQL_description": "Вы можете указать собственный SQL-запрос, который будет генерировать файл JSON, а затем предоставлять его через конечную точку файла <a href=\"/api/table_custom_endpoint.json\" target=\"_blank\"><code>table_custom_endpoint.json</code></a>.",
|
||||||
"API_CUSTOM_SQL_name": "Пользовательская конечная точка",
|
"API_CUSTOM_SQL_name": "Пользовательская конечная точка",
|
||||||
"API_TOKEN_description": "API-токен для безопасной связи. Сгенерируйте его или введите любое значение. Он передается в заголовке запроса и используется в плагине <code>SYNC</code>, сервере GraphQL и других конечных точках API. Вы можете использовать конечные точки API для создания пользовательских интеграций, как описано в a href=\"https://github.com/jokob-sk/NetAlertX/blob/main/docs/API.md\" target=\"_blank\">документации по API</a>.",
|
"API_TOKEN_description": "API-токен для безопасной связи. Сгенерируйте его или введите любое значение. Он передается в заголовке запроса и используется в плагине <code>SYNC</code>, сервере GraphQL и других конечных точках API. Вы можете использовать конечные точки API для создания пользовательских интеграций, как описано в <a href=\"https://github.com/jokob-sk/NetAlertX/blob/main/docs/API.md\" target=\"_blank\">документации по API</a>.",
|
||||||
"API_TOKEN_name": "API token",
|
"API_TOKEN_name": "API token",
|
||||||
"API_display_name": "API",
|
"API_display_name": "API",
|
||||||
"API_icon": "<i class=\"fa fa-arrow-down-up-across-line\"></i>",
|
"API_icon": "<i class=\"fa fa-arrow-down-up-across-line\"></i>",
|
||||||
|
|||||||
Reference in New Issue
Block a user